Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions interpreter/cling/lib/Interpreter/CIFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1428,6 +1428,23 @@ namespace {
#endif
// Add host specific includes, -resource-dir if necessary, and -isysroot
std::string ClingBin = GetExecutablePath(argv[0]);
#ifdef __linux__
// On Linux GetExecutablePath() resolves /proc/self/exe, i.e. the path of
// the *embedding* application rather than of ROOT/cling itself. clang's
// driver derives its installed-dir (and hence its GCC-installation and
// C-system-header sysroot detection) from this path. When libCore is loaded
// by an executable that does not live next to the ROOT installation, the
// sysroot is misdetected and the interpreter fails to find the C system
// headers (e.g. assert.h) even though they are present in the installation.
// Anchor the driver on $ROOTSYS/bin instead, mirroring how -resource-dir is
// already made ROOTSYS-relative below. LLVMDir is $ROOTSYS/etc/cling.
if (LLVMDir) {
llvm::SmallString<512> rootDriver(LLVMDir);
llvm::sys::path::append(rootDriver, "..", "..", "bin", "rootcling");

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.

Does this also work with builtin_cling=OFF or builtin_llvm=OFF ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Conda-forge is only using external clang/llvm. I had to leave before testing the build but I'll definitely test that case.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've confirmed now that this works as expected.

llvm::sys::path::remove_dots(rootDriver, /*remove_dot_dot=*/true);
ClingBin.assign(rootDriver.data(), rootDriver.size());
}
#endif
AddHostArguments(ClingBin, argvCompile, LLVMDir, COpts);

// Be explicit about the stdlib on OS X
Expand Down
Loading