Skip to content

Add an optional reason out-parameter to LoadLibrary - #2

Open
conrade-ctc wants to merge 1 commit into
ctc-masterfrom
loadlib-reason
Open

Add an optional reason out-parameter to LoadLibrary#2
conrade-ctc wants to merge 1 commit into
ctc-masterfrom
loadlib-reason

Conversation

@conrade-ctc

Copy link
Copy Markdown
Collaborator

Cpp::LoadLibrary(lib_stem, lookup, std::string* error = nullptr). When error is set it receives the dlerror() text, or <stem>: library not found when 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 is NoCWrapper and cppinterop_LoadLibrary(const char*, bool) is kept by hand in CXCppInterOp.cpp, with a test.
  • DynamicLibraryManager_LoadFailureReason now 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.

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown

clang-tidy review says "All clean, LGTM! 👍"

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown

clang-tidy review says "All clean, LGTM! 👍"

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

Comment thread lib/CppInterOp/CppInterOpInterpreter.h Outdated
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)
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

clang-tidy review says "All clean, LGTM! 👍"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant