Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Runner] Adjust clang flags to make it work slightly better on Linux #405

Merged
merged 4 commits into from
Jan 23, 2025

Conversation

giordano
Copy link
Member

@giordano giordano commented Jan 23, 2025

The current order of header search paths of clang targeting platforms different than macOS and FreeBSD makes it somewhat broken:

% julia -e 'using BinaryBuilderBase; BinaryBuilderBase.runshell(Platform("aarch64", "linux"))'
sandbox:${WORKSPACE} # echo -e '#include <cstdint>\nint main(){return 0;}'|clang -x c++ - -H -o /dev/null
. /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/4.8.5/cstdint
.. /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/4.8.5/aarch64-linux-gnu/bits/c++config.h
... /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/4.8.5/aarch64-linux-gnu/bits/os_defines.h
.... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/features.h
..... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/stdc-predef.h
..... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/sys/cdefs.h
...... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/bits/wordsize.h
..... /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/gnu/stubs.h
... /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/4.8.5/aarch64-linux-gnu/bits/cpu_defines.h
.. /opt/x86_64-linux-musl/bin/../include/c++/v1/stdint.h
... /opt/x86_64-linux-musl/bin/../include/c++/v1/__config
In file included from <stdin>:1:
In file included from /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/4.8.5/cstdint:41:
In file included from /opt/x86_64-linux-musl/bin/../include/c++/v1/stdint.h:106:
/opt/x86_64-linux-musl/bin/../include/c++/v1/__config:13:10: fatal error: '__config_site' file not found
   13 | #include <__config_site>
      |          ^~~~~~~~~~~~~~~
... /opt/x86_64-linux-musl/lib/clang/18/include/stdint.h
.... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/stdint.h
..... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/bits/wchar.h
..... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/bits/wordsize.h
1 error generated.

By moving /opt/${target}/${target}/sys-root/usr/include further up we get a more functional C++ compiler:

% julia -e 'using BinaryBuilderBase; BinaryBuilderBase.runshell(Platform("aarch64", "linux"))'
sandbox:${WORKSPACE} # echo -e '#include <cstdint>\nint main(){return 0;}'|clang -x c++ - -H -o /dev/null
. /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/4.8.5/cstdint
.. /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/4.8.5/aarch64-linux-gnu/bits/c++config.h
... /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/4.8.5/aarch64-linux-gnu/bits/os_defines.h
.... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/features.h
..... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/stdc-predef.h
..... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/sys/cdefs.h
...... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/bits/wordsize.h
..... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/gnu/stubs.h
...... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/bits/wordsize.h
...... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/gnu/stubs-lp64.h
... /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/4.8.5/aarch64-linux-gnu/bits/cpu_defines.h
.. /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/stdint.h
... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/bits/wchar.h
... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/bits/wordsize.h
sandbox:${WORKSPACE} # echo -e '#include <cmath>\nint main(){return 0;}'|clang -x c++ - -H -o /dev/null
. /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/4.8.5/cmath
.. /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/4.8.5/aarch64-linux-gnu/bits/c++config.h
... /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/4.8.5/aarch64-linux-gnu/bits/os_defines.h
.... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/features.h
..... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/stdc-predef.h
..... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/sys/cdefs.h
...... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/bits/wordsize.h
..... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/gnu/stubs.h
...... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/bits/wordsize.h
...... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/gnu/stubs-lp64.h
... /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/4.8.5/aarch64-linux-gnu/bits/cpu_defines.h
.. /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/4.8.5/bits/cpp_type_traits.h
.. /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/4.8.5/ext/type_traits.h
.. /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/math.h
... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/bits/huge_val.h
... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/bits/huge_valf.h
... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/bits/huge_vall.h
... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/bits/inf.h
... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/bits/nan.h
... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/bits/mathdef.h
... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/bits/mathcalls.h
... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/bits/mathcalls.h
... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/bits/mathcalls.h

Also, do some general cleanup.

…aths for clang

Doesn't seem to be useful (it's empty for all platforms as far as I could see)
and it's in the default search path anyway:

```console
sandbox:${WORKSPACE} # /opt/x86_64-linux-musl/bin/clang -target ${target} --sysroot=/opt/${target}/${target}/sys-root -v -E -x c - < /dev/null
clang version 18.1.7 (/home/tim/.cache/BinaryBuilder/downloads/clones/llvm-project.git-1df819a03ecf6890e3787b27bfd4f160aeeeeacd50a98d003be8b0893f11a9be 768118d1ad38bf13c545828f67bd6b474d61fc55)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/x86_64-linux-musl/bin
 (in-process)
 "/opt/x86_64-linux-musl/bin/clang-18" -cc1 -triple aarch64-unknown-linux-gnu -E -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name - -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=non-leaf -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu generic -target-feature +v8a -target-feature +fp-armv8 -target-feature +neon -target-abi aapcs -debugger-tuning=gdb -fdebug-compilation-dir=/workspace -v -fcoverage-compilation-dir=/workspace -resource-dir /opt/x86_64-linux-musl/lib/clang/18 -isysroot /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root -internal-isystem /opt/x86_64-linux-musl/lib/clang/18/include -internal-isystem /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/local/include -internal-externc-isystem /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/include -internal-externc-isystem /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include -source-date-epoch 0 -ferror-limit 19 -fno-signed-char -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -target-feature +outline-atomics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o - -x c -
clang -cc1 version 18.1.7 based upon LLVM 18.1.7 default target x86_64-alpine-linux-musl
ignoring nonexistent directory "/opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/local/include"
ignoring nonexistent directory "/opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/include"
 /opt/x86_64-linux-musl/lib/clang/18/include
 /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include
End of search list.
```
@giordano
Copy link
Member Author

It turns out clang -x c++ does different things than clang++, the latter works fine out-of-the-box:

sandbox:${WORKSPACE} # echo -e '#include <cstdint>\nint main(){return 0;}'|clang++ -x c++ - -H -o /dev/null
. /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/4.8.5/cstdint
.. /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/4.8.5/aarch64-linux-gnu/bits/c++config.h
... /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/4.8.5/aarch64-linux-gnu/bits/os_defines.h
.... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/features.h
..... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/stdc-predef.h
..... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/sys/cdefs.h
...... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/bits/wordsize.h
..... /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/gnu/stubs.h
... /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/4.8.5/aarch64-linux-gnu/bits/cpu_defines.h
.. /opt/x86_64-linux-musl/lib/clang/18/include/stdint.h
... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/stdint.h
.... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/bits/wchar.h
.... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/bits/wordsize.h
sandbox:${WORKSPACE} # echo -e '#include <cmath>\nint main(){return 0;}'|clang++ -x c++ - -H -o /dev/null
. /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/4.8.5/cmath
.. /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/4.8.5/aarch64-linux-gnu/bits/c++config.h
... /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/4.8.5/aarch64-linux-gnu/bits/os_defines.h
.... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/features.h
..... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/stdc-predef.h
..... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/sys/cdefs.h
...... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/bits/wordsize.h
..... /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/gnu/stubs.h
... /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/4.8.5/aarch64-linux-gnu/bits/cpu_defines.h
.. /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/4.8.5/bits/cpp_type_traits.h
.. /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/4.8.5/ext/type_traits.h
.. /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/math.h
... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/bits/huge_val.h
... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/bits/huge_valf.h
... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/bits/huge_vall.h
... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/bits/inf.h
... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/bits/nan.h
... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/bits/mathdef.h
... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/bits/mathcalls.h
... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/bits/mathcalls.h
... /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/bits/mathcalls.h

However I believe making clang -x c++ work reliably would be worthwhile too.

@giordano
Copy link
Member Author

More breadcrumbs: clang -x c++ vs clang++ -x c++: search paths are different

sandbox:${WORKSPACE} # clang -v -E -x c++ - < /dev/null 
clang version 18.1.7 (/home/tim/.cache/BinaryBuilder/downloads/clones/llvm-project.git-1df819a03ecf6890e3787b27bfd4f160aeeeeacd50a98d003be8b0893f11a9be 768118d1ad38bf13c545828f67bd6b474d61fc55)
Target: arm64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/x86_64-linux-musl/bin
Selected GCC installation: /opt/aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/4.8.5
Candidate multilib: .;@m64
Selected multilib: .;@m64
 (in-process)
 "/opt/x86_64-linux-musl/bin/clang-18" -cc1 -triple arm64-unknown-linux-gnu -E -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name - -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=non-leaf -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu cortex-a57 -target-feature +v8a -target-feature +fp-armv8 -target-feature +neon -target-abi aapcs -debugger-tuning=gdb -fdebug-compilation-dir=/workspace -v -fcoverage-compilation-dir=/workspace -resource-dir /opt/x86_64-linux-musl/lib/clang/18 -isystem /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/4.8.5 -isystem /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/4.8.5/aarch64-linux-gnu -isystem /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/4.8.5/backward -isystem /opt/aarch64-linux-gnu/aarch64-linux-gnu/include -isystem /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/include -D _GLIBCXX_USE_CXX11_ABI=0 -isysroot /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root -internal-isystem /opt/x86_64-linux-musl/bin/../include/c++/v1 -internal-isystem /opt/x86_64-linux-musl/lib/clang/18/include -internal-isystem /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/local/include -internal-isystem /opt/aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/4.8.5/../../../../aarch64-linux-gnu/include -internal-externc-isystem /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/include -internal-externc-isystem /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include -source-date-epoch 0 -fdeprecated-macro -ferror-limit 19 -fno-signed-char -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -fcolor-diagnostics -target-feature +outline-atomics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o - -x c++ -
clang -cc1 version 18.1.7 based upon LLVM 18.1.7 default target x86_64-alpine-linux-musl
ignoring nonexistent directory "/opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/include"
ignoring nonexistent directory "/opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/local/include"
ignoring nonexistent directory "/opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/include"
ignoring duplicate directory "/opt/aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/4.8.5/../../../../aarch64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/4.8.5
 /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/4.8.5/aarch64-linux-gnu
 /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/4.8.5/backward
 /opt/aarch64-linux-gnu/aarch64-linux-gnu/include
 /opt/x86_64-linux-musl/bin/../include/c++/v1
 /opt/x86_64-linux-musl/lib/clang/18/include
 /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include
End of search list.
# 1 "<stdin>"
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 468 "<built-in>" 3
# 1 "<command line>" 1
# 1 "<built-in>" 2
# 1 "<stdin>" 2

sandbox:${WORKSPACE} # clang++ -v -E -x c++ - < /dev/null 
clang version 18.1.7 (/home/tim/.cache/BinaryBuilder/downloads/clones/llvm-project.git-1df819a03ecf6890e3787b27bfd4f160aeeeeacd50a98d003be8b0893f11a9be 768118d1ad38bf13c545828f67bd6b474d61fc55)
Target: arm64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/x86_64-linux-musl/bin
Selected GCC installation: /opt/aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/4.8.5
Candidate multilib: .;@m64
Selected multilib: .;@m64
 (in-process)
 "/opt/x86_64-linux-musl/bin/clang-18" -cc1 -triple arm64-unknown-linux-gnu -E -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name - -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=non-leaf -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu cortex-a57 -target-feature +v8a -target-feature +fp-armv8 -target-feature +neon -target-abi aapcs -debugger-tuning=gdb -fdebug-compilation-dir=/workspace -v -fcoverage-compilation-dir=/workspace -resource-dir /opt/x86_64-linux-musl/lib/clang/18 -isystem /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/4.8.5 -isystem /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/4.8.5/aarch64-linux-gnu -isystem /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/4.8.5/backward -isystem /opt/aarch64-linux-gnu/aarch64-linux-gnu/include -isystem /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/include -D _GLIBCXX_USE_CXX11_ABI=0 -isysroot /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root -internal-isystem /opt/aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/4.8.5/../../../../aarch64-linux-gnu/include/c++/4.8.5 -internal-isystem /opt/aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/4.8.5/../../../../aarch64-linux-gnu/include/c++/4.8.5/aarch64-linux-gnu -internal-isystem /opt/aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/4.8.5/../../../../aarch64-linux-gnu/include/c++/4.8.5/backward -internal-isystem /opt/x86_64-linux-musl/lib/clang/18/include -internal-isystem /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/local/include -internal-isystem /opt/aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/4.8.5/../../../../aarch64-linux-gnu/include -internal-externc-isystem /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/include -internal-externc-isystem /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include -source-date-epoch 0 -fdeprecated-macro -ferror-limit 19 -fno-signed-char -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -fcolor-diagnostics -target-feature +outline-atomics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o - -x c++ -
clang -cc1 version 18.1.7 based upon LLVM 18.1.7 default target x86_64-alpine-linux-musl
ignoring nonexistent directory "/opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/include"
ignoring nonexistent directory "/opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/local/include"
ignoring nonexistent directory "/opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/include"
ignoring duplicate directory "/opt/aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/4.8.5/../../../../aarch64-linux-gnu/include/c++/4.8.5"
ignoring duplicate directory "/opt/aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/4.8.5/../../../../aarch64-linux-gnu/include/c++/4.8.5/aarch64-linux-gnu"
ignoring duplicate directory "/opt/aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/4.8.5/../../../../aarch64-linux-gnu/include/c++/4.8.5/backward"
ignoring duplicate directory "/opt/aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/4.8.5/../../../../aarch64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/4.8.5
 /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/4.8.5/aarch64-linux-gnu
 /opt/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/4.8.5/backward
 /opt/aarch64-linux-gnu/aarch64-linux-gnu/include
 /opt/x86_64-linux-musl/lib/clang/18/include
 /opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include
End of search list.
# 1 "<stdin>"
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 468 "<built-in>" 3
# 1 "<command line>" 1
# 1 "<built-in>" 2
# 1 "<stdin>" 2

gcc -x c++ vs g++ -x c++: search paths are the same

sandbox:${WORKSPACE} # gcc -v -E -x c++ - < /dev/null 
Using built-in specs.
COLLECT_GCC=/opt/aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc
Target: aarch64-linux-gnu
Configured with: /workspace/srcdir/gcc-4.8.5/configure --prefix=/workspace/destdir --target=aarch64-linux-gnu --host=x86_64-linux-musl --build=x86_64-linux-musl --disable-multilib --disable-werror --enable-shared --enable-host-shared --enable-threads=posix --with-sysroot=/workspace/destdir/aarch64-linux-gnu/sys-root --program-prefix=aarch64-linux-gnu- --disable-bootstrap --enable-languages=c,c++,fortran,objc,obj-c++
Thread model: posix
gcc version 4.8.5 (GCC) 
COLLECT_GCC_OPTIONS='-D' '_GLIBCXX_USE_CXX11_ABI=0' '-frandom-seed=0x2828f238' '-L/opt/aarch64-linux-gnu/aarch64-linux-gnu/lib64' '-march=armv8-a' '-mcpu=cortex-a57' '-v' '-E'
 /opt/aarch64-linux-gnu/bin/../libexec/gcc/aarch64-linux-gnu/4.8.5/cc1plus -E -quiet -v -iprefix /opt/aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/4.8.5/ -isysroot /opt/aarch64-linux-gnu/bin/../aarch64-linux-gnu/sys-root -D_GNU_SOURCE -D _GLIBCXX_USE_CXX11_ABI=0 - -march=armv8-a -mcpu=cortex-a57 -frandom-seed=0x2828f238
ignoring duplicate directory "/opt/aarch64-linux-gnu/bin/../lib/gcc/../../lib/gcc/aarch64-linux-gnu/4.8.5/../../../../aarch64-linux-gnu/include/c++/4.8.5"
ignoring duplicate directory "/opt/aarch64-linux-gnu/bin/../lib/gcc/../../lib/gcc/aarch64-linux-gnu/4.8.5/../../../../aarch64-linux-gnu/include/c++/4.8.5/aarch64-linux-gnu"
ignoring duplicate directory "/opt/aarch64-linux-gnu/bin/../lib/gcc/../../lib/gcc/aarch64-linux-gnu/4.8.5/../../../../aarch64-linux-gnu/include/c++/4.8.5/backward"
ignoring duplicate directory "/opt/aarch64-linux-gnu/bin/../lib/gcc/../../lib/gcc/aarch64-linux-gnu/4.8.5/include"
ignoring nonexistent directory "/opt/aarch64-linux-gnu/bin/../aarch64-linux-gnu/sys-root/usr/local/include"
ignoring duplicate directory "/opt/aarch64-linux-gnu/bin/../lib/gcc/../../lib/gcc/aarch64-linux-gnu/4.8.5/include-fixed"
ignoring duplicate directory "/opt/aarch64-linux-gnu/bin/../lib/gcc/../../lib/gcc/aarch64-linux-gnu/4.8.5/../../../../aarch64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /opt/aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/4.8.5/../../../../aarch64-linux-gnu/include/c++/4.8.5
 /opt/aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/4.8.5/../../../../aarch64-linux-gnu/include/c++/4.8.5/aarch64-linux-gnu
 /opt/aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/4.8.5/../../../../aarch64-linux-gnu/include/c++/4.8.5/backward
 /opt/aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/4.8.5/include
 /opt/aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/4.8.5/include-fixed
 /opt/aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/4.8.5/../../../../aarch64-linux-gnu/include
 /opt/aarch64-linux-gnu/bin/../aarch64-linux-gnu/sys-root/usr/include
End of search list.
# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "/opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/stdc-predef.h" 1 3 4
# 1 "<command-line>" 2
# 1 "<stdin>"
COMPILER_PATH=/opt/aarch64-linux-gnu/bin/../libexec/gcc/aarch64-linux-gnu/4.8.5/:/opt/aarch64-linux-gnu/bin/../libexec/gcc/:/opt/aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/4.8.5/../../../../aarch64-linux-gnu/bin/
LIBRARY_PATH=/opt/aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/4.8.5/:/opt/aarch64-linux-gnu/bin/../lib/gcc/:/opt/aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/4.8.5/../../../../aarch64-linux-gnu/lib/../lib64/:/opt/aarch64-linux-gnu/bin/../aarch64-linux-gnu/sys-root/lib/../lib64/:/opt/aarch64-linux-gnu/bin/../aarch64-linux-gnu/sys-root/usr/lib/../lib64/:/opt/aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/4.8.5/../../../../aarch64-linux-gnu/lib/:/opt/aarch64-linux-gnu/bin/../aarch64-linux-gnu/sys-root/lib/:/opt/aarch64-linux-gnu/bin/../aarch64-linux-gnu/sys-root/usr/lib/
COLLECT_GCC_OPTIONS='-D' '_GLIBCXX_USE_CXX11_ABI=0' '-frandom-seed=0x2828f238' '-L/opt/aarch64-linux-gnu/aarch64-linux-gnu/lib64' '-march=armv8-a' '-mcpu=cortex-a57' '-v' '-E'
sandbox:${WORKSPACE} # g++ -v -E -x c++ - < /dev/null 
Using built-in specs.
COLLECT_GCC=/opt/aarch64-linux-gnu/bin/aarch64-linux-gnu-g++
Target: aarch64-linux-gnu
Configured with: /workspace/srcdir/gcc-4.8.5/configure --prefix=/workspace/destdir --target=aarch64-linux-gnu --host=x86_64-linux-musl --build=x86_64-linux-musl --disable-multilib --disable-werror --enable-shared --enable-host-shared --enable-threads=posix --with-sysroot=/workspace/destdir/aarch64-linux-gnu/sys-root --program-prefix=aarch64-linux-gnu- --disable-bootstrap --enable-languages=c,c++,fortran,objc,obj-c++
Thread model: posix
gcc version 4.8.5 (GCC) 
COLLECT_GCC_OPTIONS='-D' '_GLIBCXX_USE_CXX11_ABI=0' '-frandom-seed=0x2828f238' '-L/opt/aarch64-linux-gnu/aarch64-linux-gnu/lib64' '-march=armv8-a' '-mcpu=cortex-a57' '-v' '-E' '-shared-libgcc'
 /opt/aarch64-linux-gnu/bin/../libexec/gcc/aarch64-linux-gnu/4.8.5/cc1plus -E -quiet -v -iprefix /opt/aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/4.8.5/ -isysroot /opt/aarch64-linux-gnu/bin/../aarch64-linux-gnu/sys-root -D_GNU_SOURCE -D _GLIBCXX_USE_CXX11_ABI=0 - -march=armv8-a -mcpu=cortex-a57 -frandom-seed=0x2828f238
ignoring duplicate directory "/opt/aarch64-linux-gnu/bin/../lib/gcc/../../lib/gcc/aarch64-linux-gnu/4.8.5/../../../../aarch64-linux-gnu/include/c++/4.8.5"
ignoring duplicate directory "/opt/aarch64-linux-gnu/bin/../lib/gcc/../../lib/gcc/aarch64-linux-gnu/4.8.5/../../../../aarch64-linux-gnu/include/c++/4.8.5/aarch64-linux-gnu"
ignoring duplicate directory "/opt/aarch64-linux-gnu/bin/../lib/gcc/../../lib/gcc/aarch64-linux-gnu/4.8.5/../../../../aarch64-linux-gnu/include/c++/4.8.5/backward"
ignoring duplicate directory "/opt/aarch64-linux-gnu/bin/../lib/gcc/../../lib/gcc/aarch64-linux-gnu/4.8.5/include"
ignoring nonexistent directory "/opt/aarch64-linux-gnu/bin/../aarch64-linux-gnu/sys-root/usr/local/include"
ignoring duplicate directory "/opt/aarch64-linux-gnu/bin/../lib/gcc/../../lib/gcc/aarch64-linux-gnu/4.8.5/include-fixed"
ignoring duplicate directory "/opt/aarch64-linux-gnu/bin/../lib/gcc/../../lib/gcc/aarch64-linux-gnu/4.8.5/../../../../aarch64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /opt/aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/4.8.5/../../../../aarch64-linux-gnu/include/c++/4.8.5
 /opt/aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/4.8.5/../../../../aarch64-linux-gnu/include/c++/4.8.5/aarch64-linux-gnu
 /opt/aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/4.8.5/../../../../aarch64-linux-gnu/include/c++/4.8.5/backward
 /opt/aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/4.8.5/include
 /opt/aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/4.8.5/include-fixed
 /opt/aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/4.8.5/../../../../aarch64-linux-gnu/include
 /opt/aarch64-linux-gnu/bin/../aarch64-linux-gnu/sys-root/usr/include
End of search list.
# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "/opt/aarch64-linux-gnu/aarch64-linux-gnu/sys-root/usr/include/stdc-predef.h" 1 3 4
# 1 "<command-line>" 2
# 1 "<stdin>"
COMPILER_PATH=/opt/aarch64-linux-gnu/bin/../libexec/gcc/aarch64-linux-gnu/4.8.5/:/opt/aarch64-linux-gnu/bin/../libexec/gcc/:/opt/aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/4.8.5/../../../../aarch64-linux-gnu/bin/
LIBRARY_PATH=/opt/aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/4.8.5/:/opt/aarch64-linux-gnu/bin/../lib/gcc/:/opt/aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/4.8.5/../../../../aarch64-linux-gnu/lib/../lib64/:/opt/aarch64-linux-gnu/bin/../aarch64-linux-gnu/sys-root/lib/../lib64/:/opt/aarch64-linux-gnu/bin/../aarch64-linux-gnu/sys-root/usr/lib/../lib64/:/opt/aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/4.8.5/../../../../aarch64-linux-gnu/lib/:/opt/aarch64-linux-gnu/bin/../aarch64-linux-gnu/sys-root/lib/:/opt/aarch64-linux-gnu/bin/../aarch64-linux-gnu/sys-root/usr/lib/
COLLECT_GCC_OPTIONS='-D' '_GLIBCXX_USE_CXX11_ABI=0' '-frandom-seed=0x2828f238' '-L/opt/aarch64-linux-gnu/aarch64-linux-gnu/lib64' '-march=armv8-a' '-mcpu=cortex-a57' '-v' '-E' '-shared-libgcc'

@giordano
Copy link
Member Author

For the record, my solution to make the damned /opt/x86_64-linux-musl/bin/../include/c++/v1 directory (which is a host directory and was screwing up all the includes when picked up) go away from the search paths of clang -x c++ was to use -nostdinc++: we were already using it, but only when targeting macOS.

@giordano giordano force-pushed the mg/clang-linux branch 2 times, most recently from cd867fd to 94f8629 Compare January 23, 2025 17:33
@giordano giordano merged commit 087e705 into master Jan 23, 2025
7 checks passed
@giordano giordano deleted the mg/clang-linux branch January 23, 2025 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant