[PATCH] D141907: [CMake] Ensure `CLANG_RESOURCE_DIR` is respected

Junchang Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 5 17:22:29 PDT 2023


paperchalice added inline comments.


================
Comment at: cmake/Modules/GetClangResourceDir.cmake:13
+  if(DEFINED CLANG_RESOURCE_DIR AND NOT CLANG_RESOURCE_DIR STREQUAL "")
+    set(ret_dir bin/${CLANG_RESOURCE_DIR})
+  else()
----------------
tstellar wrote:
> tstellar wrote:
> > tstellar wrote:
> > > paperchalice wrote:
> > > > tstellar wrote:
> > > > > Why is the bin prefix here?
> > > > See https://clang.llvm.org/doxygen/classclang_1_1driver_1_1Driver.html#acda8dfdf4f80efa84df98157e1779152
> > > > `GetResourcesPath` will return `<prefix>/lib/<version>` when `CLANG_RESOURCE_DIR` is empty, `<prefix>/bin/CLANG_RESOURCE_DIR` otherwise.
> > > > 
> > > `GetResourcesPath` calls `sys::path::parent_path` twice on the path to the clang executable which is going to give you `/usr ` on most Linux systems, so it's returning `<prefix>/CLANG_RESOURCE_DIR` not `<prefix>/bin/CLANG_RESOURCE_DIR`.
> > Sorry, you are correct.  I was looking at the wrong branch.  It's really strange that it does that.
> @paperchalice Can you update the description of the CLANG_RESOURCE_DIR cache variable in clang/CMakeLists.txt to mention that the path should be relative to the directory with the clang executable.
Already in [[ https://github.com/llvm/llvm-project/blob/c5fefbc8dbc49d1c3133615b46fc9a3ca93dcdc2/clang/CMakeLists.txt#LL178C53-L178C53 | codebase ]]:
```
set(CLANG_RESOURCE_DIR "" CACHE STRING
  "Relative directory from the Clang binary to its resource files.")
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141907/new/

https://reviews.llvm.org/D141907



More information about the cfe-commits mailing list