Skip to content

Read CppInterOp location from CPPINTEROP_BIN_DIR env var#211

Open
conrade-ctc wants to merge 1 commit into
compiler-research:masterfrom
conrade-ctc:unify_path_defines_and_env
Open

Read CppInterOp location from CPPINTEROP_BIN_DIR env var#211
conrade-ctc wants to merge 1 commit into
compiler-research:masterfrom
conrade-ctc:unify_path_defines_and_env

Conversation

@conrade-ctc

Copy link
Copy Markdown

Summary

  • The CppInterOp install prefix was baked into a CPPINTEROP_DIR macro at build time, so a relocated backend could not find libclangCppInterOp.
  • Add cppinterop_dir() / cppinterop_lib_path() helpers that prefer the CPPINTEROP_BIN_DIR environment variable, fall back to the compile-time default, and report a clear error (instead of relying on the macro always being defined) when the location is unknown.
  • Rename the macro to CPPINTEROP_BIN_DIR to match.

Test plan

  • Rebuilt the cppyy stack; test_cppyy: 501 passed, 69 skipped, 19 xfailed, 2 xpassed.
  • Verified import cppyy with a bogus CPPINTEROP_BIN_DIR prints a clear diagnostic instead of crashing.

Note: this pairs with compiler-research/CppInterOp#1037, which introduces the same CPPINTEROP_BIN_DIR convention on the CppInterOp side.

🤖 Done with the help of Claude Code (Claude Opus 4.8)

Comment thread clingwrapper/src/clingwrapper.cxx Outdated
Comment on lines +135 to +140
#elif defined(_WIN32)
return dir + "/lib/libclangCppInterOp.dll";
#elif defined(__APPLE__)
return dir + "/lib/libclangCppInterOp.dylib";
#else
return dir + "/lib/libclangCppInterOp.so";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we need these branches? Seems unlikely that this variable isn't set, do you have an example where this was the case?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

We're not using cmake in our env, so setting it feels artificial... however, since cmake will set the suffix, the WIN32 and APPLE special cases seem unnecessary, and maybe we just go with the main CMAKE_SHARED_LIBRARY_SUFFIX branch with ".so" as the default if not defined. I'll update, let me know if that doesn't seem reasonable.

The CppInterOp install prefix was baked into a CPPINTEROP_DIR macro at
build time, so a relocated backend could not find libclangCppInterOp.
Add cppinterop_dir()/cppinterop_lib_path() helpers that prefer the
CPPINTEROP_BIN_DIR environment variable, fall back to the compile-time
default, and report a clear error (instead of relying on the macro
always being defined) when the location is unknown. Rename the macro to
CPPINTEROP_BIN_DIR to match.

Co-developed-with-the-help-of: Claude Code (Claude Opus 4.8)
@conrade-ctc conrade-ctc force-pushed the unify_path_defines_and_env branch from 198aceb to 98c296c Compare June 29, 2026 19:02
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.

2 participants