From 4b22b07655d8faee67de2ad3528ac4658a204770 Mon Sep 17 00:00:00 2001 From: Jonas Rembser Date: Wed, 29 Apr 2026 15:40:44 +0200 Subject: [PATCH] only inject `-resource-dir` when we actually have a path Only inject -resource-dir when we actually have a path. An empty value would cause clang to consume the next argument (e.g. "-std=c++14") as the resource-dir value, silently dropping it. This fixes running the tests in my setup where I use a different Clang version as the default on the system from the one I build CppInterOp against. This makes `DetectResourceDir()` fail because it just uses the `clang` executable. One could imagine also to improve `DetectResourceDir()` to deal with this case, but it's not necessary for now because my setup also works without passing `-resource-dir` at all (using CppInterOp inside ROOT with Cling). --- lib/CppInterOp/CppInterOp.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/CppInterOp/CppInterOp.cpp b/lib/CppInterOp/CppInterOp.cpp index 90c934d19..f7ca8dfe9 100644 --- a/lib/CppInterOp/CppInterOp.cpp +++ b/lib/CppInterOp/CppInterOp.cpp @@ -3812,8 +3812,10 @@ TInterp_t CreateInterpreter(const std::vector& Args /*={}*/, (T.isOSDarwin() || T.isOSLinux())) ResourceDir = DetectResourceDir(); - std::vector ClingArgv = {"-resource-dir", ResourceDir.c_str(), - "-std=c++14"}; + std::vector ClingArgv = {"-std=c++14"}; + if (!ResourceDir.empty()) { + ClingArgv.insert(ClingArgv.begin(), {"-resource-dir", ResourceDir.c_str()}); + } ClingArgv.insert(ClingArgv.begin(), MainExecutableName.c_str()); #ifdef _WIN32 // FIXME : Workaround Sema::PushDeclContext assert on windows