[clang] [clang] Match -isysroot behaviour with system compiler on Darwin (PR #80524)

Liviu Ionescu via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 7 13:41:12 PST 2024


ilg-ul wrote:

I did a test with this patch, and, as expected, the resulting behaviour is wrong.

The verbose build of a hello-world test resulted in:

```
[/Users/ilg/Work/xpack-dev-tools-build/clang-18.1.0-1/darwin-x64/application/bin/clang++ simple-hello.cpp -o simple-hello-cpp-one -v -v]
xPack x86_64 clang version 18.1.0rc
Target: x86_64-apple-darwin23.2.0
Thread model: posix
InstalledDir: /Users/ilg/Work/xpack-dev-tools-build/clang-18.1.0-1/darwin-x64/application/bin
 "/Users/ilg/Work/xpack-dev-tools-build/clang-18.1.0-1/darwin-x64/application/bin/clang-18" -cc1 -triple x86_64-apple-macosx10.13.0 -Wundef-prefix=TARGET_OS_ -Werror=undef-prefix -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -dumpdir simple-hello-cpp-one- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name simple-hello.cpp -mrelocation-model pic -pic-level 2 -mframe-pointer=all -ffp-contract=on -fno-rounding-math -funwind-tables=2 -fcompatibility-qualified-id-block-type-checking -fvisibility-inlines-hidden-static-local-var -fbuiltin-headers-in-system-modules -fdefine-target-os-macros -target-cpu penryn -tune-cpu generic -debugger-tuning=lldb -fdebug-compilation-dir=/Users/ilg/Work/xpack-dev-tools-build/clang-18.1.0-1/darwin-x64/x86_64-apple-darwin23.2.0/tests/clang/c-cpp -target-linker-version 1022.1 -v -v -fcoverage-compilation-dir=/Users/ilg/Work/xpack-dev-tools-build/clang-18.1.0-1/darwin-x64/x86_64-apple-darwin23.2.0/tests/clang/c-cpp -resource-dir /Users/ilg/Work/xpack-dev-tools-build/clang-18.1.0-1/darwin-x64/application/lib/clang/18 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -internal-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1 -internal-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/local/include -internal-isystem /Users/ilg/Work/xpack-dev-tools-build/clang-18.1.0-1/darwin-x64/application/lib/clang/18/include -internal-externc-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -fdeprecated-macro -ferror-limit 19 -stack-protector 1 -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -fmax-type-align=16 -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /var/folders/gr/13tt3vcd7m1gnbhwtkmf5cnw0000gn/T/simple-hello-6b5d6d.o -x c++ simple-hello.cpp
clang -cc1 version 18.1.0rc based upon LLVM 18.1.0rc default target x86_64-apple-darwin23.2.0
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/local/include"
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
 /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1   <---  INCORRECT!
 /Users/ilg/Work/xpack-dev-tools-build/clang-18.1.0-1/darwin-x64/application/lib/clang/18/include
 /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
 /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks (framework directory)
End of search list.
 "/usr/bin/ld" -demangle -lto_library /Users/ilg/Work/xpack-dev-tools-build/clang-18.1.0-1/darwin-x64/application/lib/libLTO.dylib -no_deduplicate -dynamic -arch x86_64 -platform_version macos 10.13.0 10.13.0 -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -mllvm -enable-linkonceodr-outlining -o simple-hello-cpp-one /var/folders/gr/13tt3vcd7m1gnbhwtkmf5cnw0000gn/T/simple-hello-6b5d6d.o -lc++ -lSystem /Users/ilg/Work/xpack-dev-tools-build/clang-18.1.0-1/darwin-x64/application/lib/clang/18/lib/darwin/libclang_rt.osx.a
```

The same run with the un-patched source:

```
[/Users/ilg/Work/xpack-dev-tools-build/clang-18.1.0-1/darwin-x64/application/bin/clang++ simple-hello.cpp -o simple-hello-cpp-one -v -v]
xPack x86_64 clang version 18.1.0rc
Target: x86_64-apple-darwin23.2.0
Thread model: posix
InstalledDir: /Users/ilg/Work/xpack-dev-tools-build/clang-18.1.0-1/darwin-x64/application/bin
 "/Users/ilg/Work/xpack-dev-tools-build/clang-18.1.0-1/darwin-x64/application/bin/clang-18" -cc1 -triple x86_64-apple-macosx10.13.0 -Wundef-prefix=TARGET_OS_ -Werror=undef-prefix -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -dumpdir simple-hello-cpp-one- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name simple-hello.cpp -mrelocation-model pic -pic-level 2 -mframe-pointer=all -ffp-contract=on -fno-rounding-math -funwind-tables=2 -fcompatibility-qualified-id-block-type-checking -fvisibility-inlines-hidden-static-local-var -fbuiltin-headers-in-system-modules -fdefine-target-os-macros -target-cpu penryn -tune-cpu generic -debugger-tuning=lldb -fdebug-compilation-dir=/Users/ilg/Work/xpack-dev-tools-build/clang-18.1.0-1/darwin-x64/x86_64-apple-darwin23.2.0/tests/clang/c-cpp -target-linker-version 1022.1 -v -v -fcoverage-compilation-dir=/Users/ilg/Work/xpack-dev-tools-build/clang-18.1.0-1/darwin-x64/x86_64-apple-darwin23.2.0/tests/clang/c-cpp -resource-dir /Users/ilg/Work/xpack-dev-tools-build/clang-18.1.0-1/darwin-x64/application/lib/clang/18 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -internal-isystem /Users/ilg/Work/xpack-dev-tools-build/clang-18.1.0-1/darwin-x64/application/bin/../include/c++/v1 -internal-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/local/include -internal-isystem /Users/ilg/Work/xpack-dev-tools-build/clang-18.1.0-1/darwin-x64/application/lib/clang/18/include -internal-externc-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -fdeprecated-macro -ferror-limit 19 -stack-protector 1 -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -fmax-type-align=16 -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /var/folders/gr/13tt3vcd7m1gnbhwtkmf5cnw0000gn/T/simple-hello-c935cf.o -x c++ simple-hello.cpp
clang -cc1 version 18.1.0rc based upon LLVM 18.1.0rc default target x86_64-apple-darwin23.2.0
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/local/include"
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
 /Users/ilg/Work/xpack-dev-tools-build/clang-18.1.0-1/darwin-x64/application/bin/../include/c++/v1   <---  CORRECT!
 /Users/ilg/Work/xpack-dev-tools-build/clang-18.1.0-1/darwin-x64/application/lib/clang/18/include
 /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
 /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks (framework directory)
End of search list.
 "/usr/bin/ld" -demangle -lto_library /Users/ilg/Work/xpack-dev-tools-build/clang-18.1.0-1/darwin-x64/application/lib/libLTO.dylib -no_deduplicate -dynamic -arch x86_64 -platform_version macos 10.13.0 10.13.0 -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -mllvm -enable-linkonceodr-outlining -o simple-hello-cpp-one /var/folders/gr/13tt3vcd7m1gnbhwtkmf5cnw0000gn/T/simple-hello-c935cf.o -lc++ -lSystem /Users/ilg/Work/xpack-dev-tools-build/clang-18.1.0-1/darwin-x64/application/lib/clang/18/lib/darwin/libclang_rt.osx.a
```

So, from my point of view, this patch is not acceptable.


https://github.com/llvm/llvm-project/pull/80524


More information about the cfe-commits mailing list