Page MenuHomeSolus

clang cannot find gcc toolchain libstdc++ headers when using rust's x86_64-unknown-linux-gnu triplet
Closed, ResolvedPublic

Description

When building mozilla projects such as firefox and thunderbird, when building with clang we hit a bug where the type_traits from libstdc++ cannot be found. This is also an issue when building the bundled mozjs from 0ad.

As a workaround we are using libc++ in firefox and thunderbird currently.

Error message from 0ad

running: "/usr/lib64/ccache/bin/clang++" "-std=gnu++17" "-O1" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=x86_64-unknown-linux-gnu" "-I/home/build/YPKG/root/0ad/build/0ad-0.0.25b-alpha/libraries/source/spidermonkey/mozjs-78.6.0/build-debug/dist/system_wrappers" "-include" "/home/build/YPKG/root/0ad/build/0ad-0.0.25b-alpha/libraries/source/spidermonkey/mozjs-78.6.0/config/gcc_hidden.h" "-fstack-protector-strong" "-ftrivial-auto-var-init=pattern" "-DDEBUG=1" "-DEXPORT_JS_API" "-DMOZ_HAS_MOZGLUE" "-I/home/build/YPKG/root/0ad/build/0ad-0.0.25b-alpha/libraries/source/spidermonkey/mozjs-78.6.0/js/src/rust" "-I/home/build/YPKG/root/0ad/build/0ad-0.0.25b-alpha/libraries/source/spidermonkey/mozjs-78.6.0/build-debug/js/src/rust" "-I/home/build/YPKG/root/0ad/build/0ad-0.0.25b-alpha/libraries/source/spidermonkey/mozjs-78.6.0/build-debug/dist/include" "-fPIC" "-DMOZILLA_CLIENT" "-include" "/home/build/YPKG/root/0ad/build/0ad-0.0.25b-alpha/libraries/source/spidermonkey/mozjs-78.6.0/build-debug/js/src/js-confdefs.h" "-Qunused-arguments" "-Qunused-arguments" "-Wall" "-Wbitfield-enum-conversion" "-Wempty-body" "-Wignored-qualifiers" "-Woverloaded-virtual" "-Wpointer-arith" "-Wshadow-field-in-constructor-modified" "-Wsign-compare" "-Wtype-limits" "-Wunreachable-code" "-Wunreachable-code-return" "-Wwrite-strings" "-Wno-invalid-offsetof" "-Wclass-varargs" "-Wempty-init-stmt" "-Wfloat-overflow-conversion" "-Wfloat-zero-conversion" "-Wloop-analysis" "-Wc++2a-compat" "-Wcomma" "-Wimplicit-fallthrough" "-Wunused-function" "-Wunused-variable" "-Wstring-conversion" "-Wtautological-overlap-compare" "-Wtautological-unsigned-enum-zero-compare" "-Wtautological-unsigned-zero-compare" "-Wno-error=tautological-type-limit-compare" "-Wno-inline-new-delete" "-Wno-error=deprecated-declarations" "-Wno-error=array-bounds" "-Wno-error=backend-plugin" "-Wno-error=free-nonheap-object" "-Wno-error=return-std-move" "-Wno-error=atomic-alignment" "-Wno-error=deprecated-copy" "-Wformat" "-Wformat-security" "-Wno-gnu-zero-variadic-macro-arguments" "-Wno-noexcept-type" "-Wno-unknown-warning-option" "-fno-sized-deallocation" "-fno-aligned-new" "-mtune=generic" "-march=x86-64" "-g2" "-O2" "-fno-plt" "-pipe" "-fPIC" "-D_FORTIFY_SOURCE=2" "-fstack-protector-strong" "--param=ssp-buffer-size=32" "-fasynchronous-unwind-tables" "-ftree-vectorize" "-feliminate-unused-debug-types" "-Wall" "-Wno-error" "-Wp,-D_REENTRANT" "-fno-rtti" "-ffunction-sections" "-fdata-sections" "-fno-exceptions" "-fno-math-errno" "-pthread" "-pipe" "-g" "-fno-omit-frame-pointer" "-funwind-tables" "-fexperimental-new-pass-manager" "-DMOZILLA_CONFIG_H" "-I" "/home/build/YPKG/root/0ad/build/0ad-0.0.25b-alpha/libraries/source/spidermonkey/mozjs-78.6.0/build-debug/js/src" "-I" "/home/build/YPKG/root/0ad/build/0ad-0.0.25b-alpha/libraries/source/spidermonkey/mozjs-78.6.0/build-debug/dist/include" "-DMOZ_HAS_MOZGLUE" "-o" "/home/build/YPKG/root/0ad/build/0ad-0.0.25b-alpha/libraries/source/spidermonkey/mozjs-78.6.0/build-debug/x86_64-unknown-linux-gnu/debug/build/mozglue-static-f6570a138dd09dff/out/wrappers.o" "-c" "wrappers.cpp"
cargo:warning=In file included from wrappers.cpp:11:
cargo:warning=In file included from /home/build/YPKG/root/0ad/build/0ad-0.0.25b-alpha/libraries/source/spidermonkey/mozjs-78.6.0/build-debug/dist/include/mozilla/Assertions.h:418:
cargo:warning=/home/build/YPKG/root/0ad/build/0ad-0.0.25b-alpha/libraries/source/spidermonkey/mozjs-78.6.0/build-debug/dist/system_wrappers/type_traits:3:15: fatal error: 'type_traits' file not found
cargo:warning=#include_next <type_traits>
cargo:warning=              ^~~~~~~~~~~~~
cargo:warning=1 error generated.
exit status: 1

Similar issue: https://bugzilla.mozilla.org/show_bug.cgi?id=1628567

Related Objects

Event Timeline

joebonrichie triaged this task as Normal priority.Jun 20 2022, 9:48 PM
joebonrichie edited projects, added Software; removed Lacks Project.

Probably worth looking at clang config/defaults: clang has defaults for various distros redhat/ubuntu, etc. solus is very unlikely to be there we may be missing a switch.

joebonrichie moved this task from Backlog to Package Fixes on the Software board.Jun 20 2022, 9:48 PM

Could also be mismatching triplet targets between rustc/clang/gcc e.g.

$ rustc -Vv
rustc 1.61.0 (Solus)
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-unknown-linux-gnu
release: 1.61.0
LLVM version: 13.0.1
$ clang++ --version
clang version 13.0.1
Target: x86_64-solus-linux
Thread model: posix
InstalledDir: /usr/bin

The firefox build gives a warning about mismatching targets when doing cross-lang PGO/LTO.

Jacek added a subscriber: Jacek.Jun 21 2022, 1:40 PM

So when using the x86_64-unknown-linux-gnu triplet (which is the default rust triplet and cannot be easily changed) it is not searching our gcc include directories. See related upstream issue for rust https://github.com/rust-lang/rust/issues/63417

ninya@b450-mortar ~/solus/rust $ clang++ -E -x c++ - -v < /dev/null
clang version 13.0.1
Target: x86_64-solus-linux
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-solus-linux/12
Found candidate GCC installation: /usr/bin/../lib64/gcc/x86_64-solus-linux/12
Selected GCC installation: /usr/bin/../lib64/gcc/x86_64-solus-linux/12
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
 (in-process)
 "/usr/bin/clang-13" -cc1 -triple x86_64-solus-linux -E -disable-free -disable-llvm-verifier -discard-value-names -main-file-name - -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -v -fcoverage-compilation-dir=/home/ninya/solus/rust -resource-dir /usr/lib64/clang/13.0.1 -internal-isystem /usr/bin/../lib64/gcc/x86_64-solus-linux/12/../../../../include/c++/12 -internal-isystem /usr/bin/../lib64/gcc/x86_64-solus-linux/12/../../../../include/c++/12/x86_64-solus-linux -internal-isystem /usr/bin/../lib64/gcc/x86_64-solus-linux/12/../../../../include/c++/12/backward -internal-isystem /usr/lib64/clang/13.0.1/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib64/gcc/x86_64-solus-linux/12/../../../../x86_64-solus-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -fdebug-compilation-dir=/home/ninya/solus/rust -ferror-limit 19 -stack-protector 2 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o - -x c++ -
clang -cc1 version 13.0.1 based upon LLVM 13.0.1 default target x86_64-solus-linux
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/usr/bin/../lib64/gcc/x86_64-solus-linux/12/../../../../x86_64-solus-linux/include"
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/bin/../lib64/gcc/x86_64-solus-linux/12/../../../../include/c++/12
 /usr/bin/../lib64/gcc/x86_64-solus-linux/12/../../../../include/c++/12/x86_64-solus-linux
 /usr/bin/../lib64/gcc/x86_64-solus-linux/12/../../../../include/c++/12/backward
 /usr/lib64/clang/13.0.1/include
 /usr/include
End of search list.
# 1 "<stdin>"
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 391 "<built-in>" 3
# 1 "<command line>" 1
# 1 "<built-in>" 2
# 1 "<stdin>" 2

ninya@b450-mortar ~/solus/rust $ clang++ --target=x86_64-unknown-linux-gnu -E -x c++ - -v < /dev/null
clang version 13.0.1
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
 (in-process)
 "/usr/bin/clang-13" -cc1 -triple x86_64-unknown-linux-gnu -E -disable-free -disable-llvm-verifier -discard-value-names -main-file-name - -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -v -fcoverage-compilation-dir=/home/ninya/solus/rust -resource-dir /usr/lib64/clang/13.0.1 -internal-isystem /usr/lib64/clang/13.0.1/include -internal-isystem /usr/local/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -fdebug-compilation-dir=/home/ninya/solus/rust -ferror-limit 19 -stack-protector 2 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o - -x c++ -
clang -cc1 version 13.0.1 based upon LLVM 13.0.1 default target x86_64-solus-linux
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib64/clang/13.0.1/include
 /usr/include
End of search list.
# 1 "<stdin>"
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 391 "<built-in>" 3
# 1 "<command line>" 1
# 1 "<built-in>" 2
# 1 "<stdin>" 2
joebonrichie renamed this task from clang cannot find libstdc++ headers (type_traits) building mozilla projects to clang cannot find gcc toolchain libstdc++ headers when using rust's x86_64-unknown-linux-gnu triplet.Jul 8 2022, 12:46 PM

Fixed locally, will be included in llvm 14.

Jacek awarded a token.Fri, Jul 8, 8:09 PM