Skip to content

After b18cb9c4716, --sysroot no longer applies to C++ system include directory #44268

@DimitryAndric

Description

@DimitryAndric
Bugzilla Link 44923
Resolution FIXED
Resolved on Feb 19, 2020 04:32
Version trunk
OS All
Blocks #43900
CC @zmodem,@zygoloid,@sthibaul,@smeenai

Extended Description

In b50e8c5 the -stdlib++-isystem flag is introduced, for reasons explained in the commit message.

However, the way it is implemented appears to break --sysroot, where such a sysroot points to a directory with correctly populated C and C++ headers. For instance, during the FreeBSD buildworld process, we set up a directory:

/usr/obj/usr/src/amd64.amd64/tmp/usr/include

which has the C headers, and under it also the libc++ headers, in:

/usr/obj/usr/src/amd64.amd64/tmp/usr/include/c++/v1

With clang++ 9.0.1, pointing to such a sysroot with --sysroot, and compiling a simple "hello world" program, the C++ system include directory is correctly appended to the sysroot path, e.g.:

$ clang++-9.0.1 --sysroot=/usr/obj/usr/src/amd64.amd64/tmp -v -c helloworld.cpp
FreeBSD clang version 9.0.1 ([email protected]:llvm/llvm-project.git c1a0a21) (based on LLVM 9.0.1)
Target: x86_64-unknown-freebsd13.0
Thread model: posix
InstalledDir: /usr/bin
"/usr/bin/clang++-9.0.1" -cc1 -triple x86_64-unknown-freebsd13.0 -emit-obj -mrelax-all -disable-free -main-file-name helloworld.cpp -mrelocation-model static -mthread-model posix -mdisable-fp-elim -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -v -coverage-notes-file /tmp/helloworld.gcno -resource-dir /usr/lib/clang/9.0.1 -isysroot /usr/obj/usr/src/amd64.amd64/tmp -internal-isystem /usr/obj/usr/src/amd64.amd64/tmp/usr/include/c++/v1 -fdeprecated-macro -fdebug-compilation-dir /tmp -ferror-limit 19 -fmessage-length 160 -fobjc-runtime=gnustep -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -faddrsig -o helloworld.o -x c++ helloworld.cpp
clang -cc1 version 9.0.1 based upon LLVM 9.0.1 default target x86_64-unknown-freebsd13.0
ignoring nonexistent directory "/usr/lib/clang/9.0.1/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/obj/usr/src/amd64.amd64/tmp/usr/include/c++/v1 <--- THIS IS CORRECT
/usr/obj/usr/src/amd64.amd64/tmp/usr/include
End of search list.

With clang++ 10.0.0 (so after b50e8c5), this no longer happens, and it reverts back to the host system's C++ include directory instead:

$ clang++-10.0.0 --sysroot=/usr/obj/usr/src/amd64.amd64/tmp -v -c helloworld.cpp
FreeBSD clang version 10.0.0 ([email protected]:llvm/llvm-project.git 90c7807)
Target: x86_64-unknown-freebsd13.0
Thread model: posix
InstalledDir: /usr/bin
(in-process)
"/usr/bin/clang++-10.0.0" -cc1 -triple x86_64-unknown-freebsd13.0 -emit-obj -mrelax-all -disable-free -main-file-name helloworld.cpp -mrelocation-model static -mthread-model posix -mframe-pointer=all -fno-rounding-math -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -dwarf-column-info -fno-split-dwarf-inlining -debugger-tuning=gdb -v -resource-dir /usr/lib/clang/10.0.0 -isysroot /usr/obj/usr/src/amd64.amd64/tmp -internal-isystem /usr/bin/../include/c++/v1 -fdeprecated-macro -fdebug-compilation-dir /tmp -ferror-limit 19 -fmessage-length 160 -fgnuc-version=4.2.1 -fobjc-runtime=gnustep -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -faddrsig -o helloworld.o -x c++ helloworld.cpp
clang -cc1 version 10.0.0 based upon LLVM 10.0.0git default target x86_64-unknown-freebsd13.0
#include "..." search starts here:
#include <...> search starts here:
/usr/bin/../include/c++/v1 <--- THIS IS WRONG
/usr/lib/clang/10.0.0/include
/usr/obj/usr/src/amd64.amd64/tmp/usr/include
End of search list.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillaclangClang issues not falling into any other category

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions