For each absolute path given to C_INCLUDE_DIRS, we want it to be added as-is to
the include search path. Relative paths should be prefixed with the sysroot.
Details
Details
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Comment Actions
Good find! The following drivers (at least) appear to have the same problem:
clang/lib/Driver/ToolChains/WebAssembly.cpp:236 clang/lib/Driver/ToolChains/Solaris.cpp:247 clang/lib/Driver/ToolChains/Linux.cpp:677 clang/lib/Driver/ToolChains/Hurd.cpp:148 clang/lib/Driver/ToolChains/Fuchsia.cpp:289 clang/lib/Driver/ToolChains/Darwin.cpp:1862
This makes me wonder whether C_INCLUDE_DIRS is useful at all. Does anybody use it? Also, if we keep C_INCLUDE_DIRS, it would be nice to add a test for this.
Comment Actions
I applied the fix to all toolchains now, but I'm unsure how to write a test for it. Neither could I find tests for similar options like -DDEFAULT_SYSROOT.
My use case: I want to build a clang that has the same search path as the clang shipped with macOS.
$ /usr/bin/clang -E -xc -v /dev/null [snip] #include <...> search starts here: /usr/local/include /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.0/include /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks (framework directory) End of search list. [snip]
For this, I need to pass this to cmake:
-DC_INCLUDE_DIRS="/usr/local/include:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include:/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include" -DDEFAULT_SYSROOT="$(xcrun --show-sdk-path)"