Add an optional reason out-parameter to LoadLibrary - #1107
Open
conrade-ctc wants to merge 2 commits into
Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1107 +/- ##
==========================================
+ Coverage 87.78% 87.98% +0.19%
==========================================
Files 23 23
Lines 6444 6449 +5
==========================================
+ Hits 5657 5674 +17
+ Misses 787 775 -12
... and 1 file with indirect coverage changes
🚀 New features to boost your workflow:
|
Contributor
|
clang-tidy review says "All clean, LGTM! 👍" |
conrade-ctc
pushed a commit
to chicagotrading/cppjit
that referenced
this pull request
Sep 3, 2026
Cpp::LoadLibrary now hands back the loader's reason through an optional out-parameter (compiler-research/CppInterOp#1107), so the ctypes re-dlopen probe goes away. The pin bump to a CppInterOp commit that carries #1107 is folded in when it lands. Co-developed-with-the-help-of: Claude Code (Fable 5.1, human in the loop)
conrade-ctc
force-pushed
the
loadlib-reason-upstream
branch
from
September 3, 2026 18:40
27bf3f9 to
78629c5
Compare
Contributor
|
clang-tidy review says "All clean, LGTM! 👍" |
conrade-ctc
force-pushed
the
loadlib-reason-upstream
branch
from
September 4, 2026 15:39
78629c5 to
c0245ee
Compare
added 2 commits
September 4, 2026 11:01
DynamicLibraryManager::loadLibrary got the dlerror() text from platform::DLOpen but only emitted it under LLVM_DEBUG. cppjit's load_library builds its Python error from captured stderr, so the reason was empty. Emit the text to std::cerr; cppjit captures only std::cerr's rdbuf, not llvm::errs(). Paths.cpp already calls ::dlerror() to build this text. Co-developed-with-the-help-of: Claude Code (Fable 5, human in the loop)
cppjit builds its Python error from the text a failed LoadLibrary writes to stderr, which the caller has to capture. Callers can now pass a std::string* and get the dlerror() text, or a not-found note when the lookup fails, directly. When the pointer is set the reason is not also written to stderr. std::string* cannot cross the C ABI, so the generated C wrapper is suppressed and cppinterop_LoadLibrary(const char*, bool) is kept by hand in CXCppInterOp.cpp. Co-developed-with-the-help-of: Claude Code (Fable 5.1, human in the loop)
conrade-ctc
force-pushed
the
loadlib-reason-upstream
branch
from
September 4, 2026 16:03
c0245ee to
1764cbc
Compare
Contributor
|
clang-tidy review says "All clean, LGTM! 👍" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #1101 from the discussion on compiler-research/cppjit#63; this branch is stacked on #1101.
Cpp::LoadLibrary(lib_stem, lookup, std::string* error = nullptr). Whenerroris set it receives the dlerror() text, or<stem>: library not foundwhen the search-path lookup fails, and the reason is not also printed to stderr. The two-argument form keeps the #1101 behaviour.std::string*cannot cross the C ABI, so the .td entry isNoCWrapperandcppinterop_LoadLibrary(const char*, bool)is kept by hand in CXCppInterOp.cpp, with a test.DynamicLibraryManager_LoadFailureReasonnow covers a dlopen failure, a failed lookup, and that success clears a stale reason.Once this lands, cppjit#63 bumps its pin and reads the reason from here instead of the ctypes probe.
Coverage: the wasm branch of
Interpreter::loadLibraryis wrapped inLCOV_EXCL_START/STOP, since no coverage lane runs it.