https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125882
Bug ID: 125882
Summary: Wrong ordering of lib(std)c++ headers in a relocated
toolchain.
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Keywords: rejects-valid
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: iains at gcc dot gnu.org
CC: feedabl3 at gmail dot com, redi at gcc dot gnu.org
Target Milestone: ---
Under the conditions:
- we have a toolchain with specified prefix /path/to/install
- we have a sys root at /path/to/sysroot and that is != prefix, and not a
sub-dir of prefix.
- the libstdc++ install is part of the sysroot - e.g. the headers are found
at /path/to/sysroot/uar/include/c++/<version>
- we specify this with
--with-gxx-include-dir=/path/to/sysroot/uar/include/c++/<version>
... build the toolchain
- now we want to make a trial install "make install DESTDIR=somewhere"
- We now have a situation where (even if the sysroot properly contains the
required headers) the search order looks like:
#include "..." search starts here:
#include <...> search starts here:
/...somehwere/path/to/install/bin/../lib/gcc/x86_64-pc-linux-gnu/17.0.0/include
/...somehwere/path/to/install/bin/../lib/gcc/x86_64-pc-linux-gnu/17.0.0/include-fixed
/path/to/sysroot/usr/include/c++/17.0.0
/path/to/sysroot/usr/include/c++/17.0.0/x86_64-pc-linux-gnu
/path/to/sysroot/usr/include/c++/17.0.0/backward
/path/to/sysroot/usr/local/include
/path/to/sysroot/usr/include
which does _not_ work, because the <cxxxxx> headers need to be before the
compiler ones.
-----
NOTE: when the toolchain is installed into prefix, it does work as expected.
However, it is my understanding that GCC toolchains are supposed to be
relocatable and that's not working in this case. I concede that this might be
an unusual situation for hosted GCC - but probably not for embedded .. Also it
is a regular scenario for libc++ (e.g. that's the default for both Darwin and
webasm)