This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Cross-compiler --sysroot discrepancy with default library and include paths
- From: Bryan Drewery <bdrewery at FreeBSD dot org>
- To: gcc at gcc dot gnu dot org
- Date: Thu, 24 Mar 2016 14:13:12 -0700
- Subject: Cross-compiler --sysroot discrepancy with default library and include paths
- Authentication-results: sourceware.org; auth=none
- Dkim-filter: OpenDKIM Filter v2.9.2 mail.xzibition.com 5A5041DEB2
- Openpgp: id=F9173CB2C3AAEA7A5C8A1F0935D771BB6E4697CF; url=http://www.shatow.net/bryan/bryan2.asc
(Please CC me as I am not subscribed)
It seems that when building a cross-compiler with a default --target but
no default --with-sysroot, the default -isystem =/usr/include path is
not automatically included when using --sysroot but default -L =/lib and
-L =/usr/lib are included.
(Full example output at end)
I did not realize that --sysroot would not add in -isystem
=/usr/include. Clang does auto include -isystem =/usr/include with
--sysroot.
The use-case here is for cross-building FreeBSD's userland against a
fully populated sysroot that has target headers and libraries. The
cross-compiler is provided in a pre-built package and does not have a
hard-coded default TARGET_SYSTEM_ROOT in it. It is required to pass
-isystem =/usr/include to do what I'm expecting.
This behavior of not including =/usr/include is not documented in
--sysroot or otherwise as far as I can tell.
Adding the library search paths in but not /usr/include seems odd. In
gcc.c the default library paths (standard_startfile_prefix_1,
standard_startfile_prefix_2) are added in when cross_compile == '0' (not
the case here) or if there is a target_system_root set. The
target_system_root comes from both TARGET_SYSTEM_ROOT or dynamically
from --sysroot. The include paths are only hard-coded at build time in
cppdefault.c and the "native paths" of /usr/include are not added using
basically the same logic as in gcc.c but only relies on the build-time
TARGET_SYSTEM_ROOT not being defined. Granted the logic in cppdefault.c
is intended to only bring in /usr/include and not =/usr/include, I think
that --sysroot should also default to adding in -isystem =/usr/include.
Otherwise something should be documented here.
Here's the cross-compiler being used:
> # /usr/local/bin/powerpc64-portbld-freebsd11.0-g++ -v
> Using built-in specs.
> COLLECT_GCC=/usr/local/bin/powerpc64-portbld-freebsd11.0-g++
> COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/powerpc64-portbld-freebsd11.0/5.3.0/lto-wrapper
> Target: powerpc64-portbld-freebsd11.0
> Configured with: ./../gcc-5.3.0/configure --target=powerpc64-portbld-freebsd11.0 --disable-nls --enable-languages=c,c++ --without-headers --with-gmp=/usr/local --with-pkgversion='FreeBSD Ports Collection for powerpc64' --with-system-zlib --with-as=/usr/local/bin/powerpc64-freebsd-as --with-ld=/usr/local/bin/powerpc64-freebsd-ld --prefix=/usr/local --localstatedir=/var --mandir=/usr/local/man --infodir=/usr/local/info/ --build=x86_64-portbld-freebsd11.0
> Thread model: posix
> gcc version 5.3.0 (FreeBSD Ports Collection for powerpc64)
Library search paths with and without sysroot:
> # /usr/obj/sparc64.sparc64/root/git/freebsd/tmp/usr/bin/cc -print-search-dirs
> install: /usr/obj/sparc64.sparc64/root/git/freebsd/tmp/usr/libexec/
> programs: =/usr/obj/sparc64.sparc64/root/git/freebsd/tmp/usr/bin/:/usr/obj/sparc64.sparc64/root/git/freebsd/tmp/usr/bin/:/usr/obj/sparc64.sparc64/root/git/freebsd/tmp/usr/libexec/:/usr/obj/sparc64.sparc64/root/git/freebsd/tmp/usr/libexec/:/usr/obj/sparc64.sparc64/root/git/freebsd/tmp/usr/libexec/
> libraries: =/usr/obj/sparc64.sparc64/root/git/freebsd/tmp/usr/lib/:/usr/obj/sparc64.sparc64/root/git/freebsd/tmp/usr/lib/
> # /usr/local/bin/powerpc64-portbld-freebsd11.0-g++ -print-search-dirs --sysroot /usr/obj/powerpc.powerpc64/root/git/freebsd/tmp
> install: /usr/local/lib/gcc/powerpc64-portbld-freebsd11.0/5.3.0/
> programs: =/usr/local/libexec/gcc/powerpc64-portbld-freebsd11.0/5.3.0/:/usr/local/libexec/gcc/powerpc64-portbld-freebsd11.0/5.3.0/:/usr/local/libexec/gcc/powerpc64-portbld-freebsd11.0/:/usr/local/lib/gcc/powerpc64-portbld-freebsd11.0/5.3.0/:/usr/local/lib/gcc/powerpc64-portbld-freebsd11.0/:/usr/local/lib/gcc/powerpc64-portbld-freebsd11.0/5.3.0/../../../../powerpc64-portbld-freebsd11.0/bin/powerpc64-portbld-freebsd11.0/5.3.0/:/usr/local/lib/gcc/powerpc64-portbld-freebsd11.0/5.3.0/../../../../powerpc64-portbld-freebsd11.0/bin/
> libraries: =/usr/local/lib/gcc/powerpc64-portbld-freebsd11.0/5.3.0/:/usr/local/lib/gcc/powerpc64-portbld-freebsd11.0/5.3.0/../../../../powerpc64-portbld-freebsd11.0/lib/powerpc64-portbld-freebsd11.0/5.3.0/:/usr/local/lib/gcc/powerpc64-portbld-freebsd11.0/5.3.0/../../../../powerpc64-portbld-freebsd11.0/lib/:/usr/obj/powerpc.powerpc64/root/git/freebsd/tmp/lib/powerpc64-portbld-freebsd11.0/5.3.0/:/usr/obj/powerpc.powerpc64/root/git/freebsd/tmp/lib/:/usr/obj/powerpc.powerpc64/root/git/freebsd/tmp/usr/lib/powerpc64-portbld-freebsd11.0/5.3.0/:/usr/obj/powerpc.powerpc64/root/git/freebsd/tmp/usr/lib/
Include path with --sysroot:
> # echo '' | /usr/local/bin/powerpc64-portbld-freebsd11.0-g++ -v -x c - -o /dev/null --sysroot /usr/obj/powerpc.powerpc64/root/git/freebsd/tmp
> Using built-in specs.
> COLLECT_GCC=/usr/local/bin/powerpc64-portbld-freebsd11.0-g++
> COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/powerpc64-portbld-freebsd11.0/5.3.0/lto-wrapper
> Target: powerpc64-portbld-freebsd11.0
> Configured with: ./../gcc-5.3.0/configure --target=powerpc64-portbld-freebsd11.0 --disable-nls --enable-languages=c,c++ --without-headers --with-gmp=/usr/local --with-pkgversion='FreeBSD Ports Collection for powerpc64' --with-system-zlib --with-as=/usr/local/bin/powerpc64-freebsd-as --with-ld=/usr/local/bin/powerpc64-freebsd-ld --prefix=/usr/local --localstatedir=/var --mandir=/usr/local/man --infodir=/usr/local/info/ --build=x86_64-portbld-freebsd11.0
> Thread model: posix
> gcc version 5.3.0 (FreeBSD Ports Collection for powerpc64)
> COLLECT_GCC_OPTIONS='-v' '-o' '/dev/null' '-shared-libgcc'
> /usr/local/libexec/gcc/powerpc64-portbld-freebsd11.0/5.3.0/cc1 -quiet -v -isysroot /usr/obj/powerpc.powerpc64/root/git/freebsd/tmp - -quiet -dumpbase - -auxbase - -version -o /tmp//ccfwtn99.s
> GNU C11 (FreeBSD Ports Collection for powerpc64) version 5.3.0 (powerpc64-portbld-freebsd11.0)
> compiled by GNU C version 4.2.1 Compatible FreeBSD Clang 3.8.0 (tags/RELEASE_380/final 262564), GMP version 5.1.3, MPFR version 3.1.3, MPC version 1.0.3
> GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
> ignoring nonexistent directory "/usr/local/lib/gcc/powerpc64-portbld-freebsd11.0/5.3.0/../../../../powerpc64-portbld-freebsd11.0/sys-include"
> ignoring nonexistent directory "/usr/local/lib/gcc/powerpc64-portbld-freebsd11.0/5.3.0/../../../../powerpc64-portbld-freebsd11.0/include"
> #include "..." search starts here:
> #include <...> search starts here:
> /usr/local/lib/gcc/powerpc64-portbld-freebsd11.0/5.3.0/include
> /usr/local/lib/gcc/powerpc64-portbld-freebsd11.0/5.3.0/include-fixed
> End of search list.
With -isystem =/usr/include:
> # echo '' |/usr/local/bin/powerpc64-portbld-freebsd11.0-g++ -v -x c - -o /dev/null --sysroot /usr/obj/powerpc.powerpc64/root/git/freebsd/tmp -isystem '=/usr/include'
> Using built-in specs.
> COLLECT_GCC=/usr/local/bin/powerpc64-portbld-freebsd11.0-g++
> COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/powerpc64-portbld-freebsd11.0/5.3.0/lto-wrapper
> Target: powerpc64-portbld-freebsd11.0
> Configured with: ./../gcc-5.3.0/configure --target=powerpc64-portbld-freebsd11.0 --disable-nls --enable-languages=c,c++ --without-headers --with-gmp=/usr/local --with-pkgversion='FreeBSD Ports Collection for powerpc64' --with-system-zlib --with-as=/usr/local/bin/powerpc64-freebsd-as --with-ld=/usr/local/bin/powerpc64-freebsd-ld --prefix=/usr/local --localstatedir=/var --mandir=/usr/local/man --infodir=/usr/local/info/ --build=x86_64-portbld-freebsd11.0
> Thread model: posix
> gcc version 5.3.0 (FreeBSD Ports Collection for powerpc64)
> COLLECT_GCC_OPTIONS='-v' '-o' '/dev/null' '-isystem' '=/usr/include' '-shared-libgcc'
> /usr/local/libexec/gcc/powerpc64-portbld-freebsd11.0/5.3.0/cc1 -quiet -v -isysroot /usr/obj/powerpc.powerpc64/root/git/freebsd/tmp -isystem =/usr/include - -quiet -dumpbase - -auxbase - -version -o /tmp//ccYf1oTQ.s
> GNU C11 (FreeBSD Ports Collection for powerpc64) version 5.3.0 (powerpc64-portbld-freebsd11.0)
> compiled by GNU C version 4.2.1 Compatible FreeBSD Clang 3.8.0 (tags/RELEASE_380/final 262564), GMP version 5.1.3, MPFR version 3.1.3, MPC version 1.0.3
> GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
> ignoring nonexistent directory "/usr/local/lib/gcc/powerpc64-portbld-freebsd11.0/5.3.0/../../../../powerpc64-portbld-freebsd11.0/sys-include"
> ignoring nonexistent directory "/usr/local/lib/gcc/powerpc64-portbld-freebsd11.0/5.3.0/../../../../powerpc64-portbld-freebsd11.0/include"
> #include "..." search starts here:
> #include <...> search starts here:
> /usr/obj/powerpc.powerpc64/root/git/freebsd/tmp/usr/include
> /usr/local/lib/gcc/powerpc64-portbld-freebsd11.0/5.3.0/include
> /usr/local/lib/gcc/powerpc64-portbld-freebsd11.0/5.3.0/include-fixed
> End of search list.
--
Regards,
Bryan Drewery