Issue 133994
Summary [clang/Driver] MacOS issue with SDK include dir auto detection
Labels
Assignees
Reporter mizvekov
    Homebrew recently made llvm 20 formula available.

With the clang binary available in that formula, there is trouble when using libc++ and adding the Xcode SDK include dir in the command line.

Simple reproducer:
```C++
#include <vector>
```
Compile with `clang++ -isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -fsyntax-only test.cc`

Results in:
```
/opt/homebrew/Cellar/llvm/20.1.1/bin/../include/c++/v1/cstdlib:93:5: error: <cstdlib> tried including <stdlib.h> but didn't find libc++'s <stdlib.h> header.           This usually means that your header search paths are not configured properly.           The header search paths should contain the C++ Standard Library headers before           any C Standard Library, and you are probably using compiler flags that make that           not be the case.
   93 | #   error <cstdlib> tried including <stdlib.h> but didn't find libc++'s <stdlib.h> header. \
```

This makes it problematic to build llvm itself from that compiler.

Here is a workaround:
1) Install homebrew versions of zlib, libxml2 and libedit:
`brew install zlib libxml2 libedit`
2) Add the following variables to your cmake invocation:
```
"CMAKE_OSX_SYSROOT": "",
"Backtrace_INCLUDE_DIR": "",
"CMAKE_PREFIX_PATH": "/opt/homebrew/opt/zlib;/opt/homebrew/opt/libxml2;/opt/homebrew/opt/libedit"
```
3) If you are using LLVM_OPTIMIZED_TABLEGEN, then these flags are not automatically forwarded to the NATIVE cross compile target, you have to add the following variable as well:
```
"CROSS_TOOLCHAIN_FLAGS_NATIVE": "-DCMAKE_OSX_SYSROOT= -DBacktrace_INCLUDE_DIR= -DCMAKE_PREFIX_PATH=\"/opt/homebrew/opt/zlib;/opt/homebrew/opt/libxml2;/opt/homebrew/opt/libedit\""
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to