From 0022d04ce0717b25b79309c617df2ae848cb1433 Mon Sep 17 00:00:00 2001 From: Vipul Cariappa Date: Fri, 30 Jan 2026 12:51:28 +0100 Subject: [PATCH 1/2] prioritize resource-dir provided by user over auto-detecting --- lib/CppInterOp/CppInterOp.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/CppInterOp/CppInterOp.cpp b/lib/CppInterOp/CppInterOp.cpp index 9154c0947..7025311bf 100644 --- a/lib/CppInterOp/CppInterOp.cpp +++ b/lib/CppInterOp/CppInterOp.cpp @@ -3310,12 +3310,30 @@ void AddLibrarySearchPaths(const std::string& ResourceDir, false, false); } } +std::string ExtractArgument(const std::vector& Args, + const std::string& Arg) { + size_t I = 0; + for (auto i = Args.begin(); i != Args.end(); i++) { + if ((++I < Args.size()) && (*i == Arg)) { + return *(++i); + } + } + return ""; +} } // namespace TInterp_t CreateInterpreter(const std::vector& Args /*={}*/, const std::vector& GpuArgs /*={}*/) { std::string MainExecutableName = sys::fs::getMainExecutable(nullptr, nullptr); - std::string ResourceDir = MakeResourcesPath(); + // In some systems, CppInterOp cannot manually detect the correct resource. + // Then the -resource-dir passed by the user is assumed to be the correct + // location. Prioritising it over detecting it within CppInterOp. Extracting + // the resource-dir from the arguments is required because we set the + // necessary library search location explicitly below. Because by default, + // linker flags are ignored in repl (issue #748) + std::string ResourceDir = ExtractArgument(Args, "-resource-dir"); + if (ResourceDir.empty()) + ResourceDir = MakeResourcesPath(); llvm::Triple T(llvm::sys::getProcessTriple()); namespace fs = std::filesystem; if ((!fs::is_directory(ResourceDir)) && (T.isOSDarwin() || T.isOSLinux())) From e5b9ae123ac6ecf423487e5f3c4303251e229180 Mon Sep 17 00:00:00 2001 From: Vipul Cariappa Date: Mon, 2 Feb 2026 19:34:08 +0530 Subject: [PATCH 2/2] Update lib/CppInterOp/CppInterOp.cpp Co-authored-by: Vassil Vassilev --- lib/CppInterOp/CppInterOp.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/CppInterOp/CppInterOp.cpp b/lib/CppInterOp/CppInterOp.cpp index 7025311bf..3554ac15d 100644 --- a/lib/CppInterOp/CppInterOp.cpp +++ b/lib/CppInterOp/CppInterOp.cpp @@ -3313,11 +3313,9 @@ void AddLibrarySearchPaths(const std::string& ResourceDir, std::string ExtractArgument(const std::vector& Args, const std::string& Arg) { size_t I = 0; - for (auto i = Args.begin(); i != Args.end(); i++) { - if ((++I < Args.size()) && (*i == Arg)) { + for (auto i = Args.begin(); i != Args.end(); i++) + if ((++I < Args.size()) && (*i == Arg)) return *(++i); - } - } return ""; } } // namespace