From 2238e676c0c8b7e5d1997f7a494eda54bcc7a8a0 Mon Sep 17 00:00:00 2001 From: jeaye Date: Tue, 1 Apr 2025 13:38:29 -0700 Subject: [PATCH] Support NixOS resource dirs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, CppInterOp assumed that the resource dir would end in the clang major version. This is common, but it's not always the case. On NixOS, for example, we have something like this: ``` ❯ clang++ -print-resource-dir /nix/store/xl0vlc2wdchfbq8536zs19pj2r3xdmma-clang-wrapper-19.1.5/resource-root ``` I have updated the function to check that the path contains the major version, rather than ending in it. This is still a useful version check, though it's not as precise as it was before. --- lib/Interpreter/CppInterOp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Interpreter/CppInterOp.cpp b/lib/Interpreter/CppInterOp.cpp index 3575bb2fa..d0a5115a4 100755 --- a/lib/Interpreter/CppInterOp.cpp +++ b/lib/Interpreter/CppInterOp.cpp @@ -3042,7 +3042,7 @@ namespace Cpp { CLANG_VERSION_MAJOR_STRING; #endif // We need to check if the detected resource directory is compatible. - if (llvm::sys::path::filename(detected_resource_dir) != version) + if (detected_resource_dir.find(version) == std::string::npos) return ""; return detected_resource_dir;