llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-driver

@llvm/pr-subscribers-clang

Author: rgal

<details>
<summary>Changes</summary>

As discussed here: 
https://discourse.llvm.org/t/removing-clang-version-number-from-resource-dir-in-a-distribution/90234

If a distributor wishes to have stable include paths across LLVM versions, then 
they can build with `CLANG_RESOURCE_DIR=../lib/clang`. This results in a 
slightly untidy include path (E.g.`C:\Program 
Files\LLVM\bin\..\lib\clang\include`). This removes the ".." to make it 
`C:\Program Files\LLVM\lib\clang\include` in this configuration.

Also added test. This uses "SIE" vendor. Since 
https://github.com/llvm/llvm-zorg/commit/eac6791821f5104eb4c2b32f39ef5d20cda535a9,
 PS4 and PS5 buildbots use this configuration and define the vendor so this 
should be tested on at least these buildbots.

---
Full diff: https://github.com/llvm/llvm-project/pull/216996.diff


2 Files Affected:

- (modified) clang/lib/Options/OptionUtils.cpp (+4-2) 
- (added) clang/test/Driver/sie-resource-path.cpp (+9) 


``````````diff
diff --git a/clang/lib/Options/OptionUtils.cpp 
b/clang/lib/Options/OptionUtils.cpp
index 77f89552e852a..4ea312639d9de 100644
--- a/clang/lib/Options/OptionUtils.cpp
+++ b/clang/lib/Options/OptionUtils.cpp
@@ -219,10 +219,12 @@ std::string clang::GetResourcesPath(StringRef BinaryPath) 
{
   if (!ConfiguredResourceDir.empty()) {
     // FIXME: We should fix the behavior of llvm::sys::path::append so we don't
     // need to check for absolute paths here.
-    if (llvm::sys::path::is_absolute(ConfiguredResourceDir))
+    if (llvm::sys::path::is_absolute(ConfiguredResourceDir)) {
       P = ConfiguredResourceDir;
-    else
+    } else {
       llvm::sys::path::append(P, ConfiguredResourceDir);
+      llvm::sys::path::remove_dots(P, true);
+    }
   } else {
     // On Windows, libclang.dll is in bin/.
     // On non-Windows, libclang.so/.dylib is in lib/.
diff --git a/clang/test/Driver/sie-resource-path.cpp 
b/clang/test/Driver/sie-resource-path.cpp
new file mode 100644
index 0000000000000..11e716ca17447
--- /dev/null
+++ b/clang/test/Driver/sie-resource-path.cpp
@@ -0,0 +1,9 @@
+// REQUIRES: clang-vendor=SIE
+
+// Test relative CLANG_RESOURCE_PATH=../lib/clang configuration, as used on
+// SIE toolchains (PS4/PS5).
+// --target shouldn't have an impact on this as it's a build config.
+
+// RUN: %clang -c -### %s 2>&1 | FileCheck %s
+// Expected resource path doesn't have a . before, or a number after.
+// CHECK: "-resource-dir" "{{.*[^.]}}{{/|\\\\}}lib{{/|\\\\}}clang"

``````````

</details>


https://github.com/llvm/llvm-project/pull/216996
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to