Add an optional reason out-parameter to LoadLibrary - #2
Open
conrade-ctc wants to merge 1 commit into
Open
Conversation
|
clang-tidy review says "All clean, LGTM! 👍" |
conrade-ctc
force-pushed
the
loadlib-reason
branch
from
September 3, 2026 18:40
e92ab10 to
f07946b
Compare
|
clang-tidy review says "All clean, LGTM! 👍" |
conrade-ctc
force-pushed
the
loadlib-reason
branch
from
September 4, 2026 15:39
f07946b to
fc1946c
Compare
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
branch
from
September 4, 2026 16:03
fc1946c to
52fbf9e
Compare
|
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.
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 current 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.Same change goes upstream as a follow-up to compiler-research#1101 (link below once open). Targets the next ctc release after ctc.37.
Evidence: DynamicLibraryManagerTests, CAPI and Tracing suites pass on the upstream base with LLVM 22. Fork CI covers ctc-master; the downstream integration runs with the release bump.