public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* sysroot issue when cross-compiling a native compiler (gcc 7.3.0)
@ 2018-12-08 10:11 Stefan Ring
  2018-12-08 10:26 ` Stefan Ring
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Ring @ 2018-12-08 10:11 UTC (permalink / raw)
  To: gcc-help

I want to build a native compiler for a very dated ARM machine
(SheevaPlug) running Fedora 18 and have to use a cross-compiler due to
the limited amount of memory available (and also 24h builds not being
fun). The cross compiler is gcc 7.3.0 as well and is running on
x86_64. I configure like this:

/tmp/gcc-7.3.0/configure --build= --host=arm-unknown-linux-gnueabi
--target=arm-unknown-linux-gnueabi --prefix=/home/sr/gcc7
--with-build-sysroot=$HOME/xtools-arm5/arm-unknown-linux-gnueabi/arm-unknown-linux-gnueabi/sysroot
--with-float=soft --with-abi=aapcs-linux --with-arch=armv5te
--with-mode=arm --enable-languages=c,c++ --enable-__cxa_atexit
--disable-nls --disable-multilib

The build and the resulting compiler does work if I also add
'--with-sysroot=/'. The only problem with this is that I have to build
binutils myself on the target because the system ld complains about
not supporting sysroots. Therefore I'd like to leave it out. This
works mostly fine except for the value of the 'target_header_dir'
variable in gcc/configure which does not get set up to what I consider
the correct value. When I observe the value there, I notice that (this
part of) the script is run twice. The first time the result is
'/usr/local/arm-unknown-linux-gnueabi/sys-include', which does not
exist, and the second time '/usr/include'. I don't quite understand
why with_build_sysroot does not seem to evaluate to the correct value
(specified on the command line).

[snippet from gcc/configure]
if test x$host != x$target || test "x$TARGET_SYSTEM_ROOT" != x; then
  if test "x$with_headers" != x && test "x$with_headers" != xyes; then
    target_header_dir=$with_headers
  elif test "x$with_sysroot" = x; then
    target_header_dir="${test_exec_prefix}/${target_noncanonical}/sys-include"
  elif test "x$with_build_sysroot" != "x"; then
    target_header_dir="${with_build_sysroot}${native_system_header_dir}"
  elif test "x$with_sysroot" = xyes; then
    target_header_dir="${test_exec_prefix}/${target_noncanonical}/sys-root${native_system_header_dir}"
  else
    target_header_dir="${with_sysroot}${native_system_header_dir}"
  fi
else
  target_header_dir=${native_system_header_dir}
fi
#target_header_dir=/home/sr/xtools-arm5/arm-unknown-linux-gnueabi/arm-unknown-linux-gnueabi/sysroot/usr/include
echo Final target_header_dir $target_header_dir

I noticed the problem because it would break like this late in the build:

In file included from /tmp/gcc-7.3.0/libgcc/config/arm/unwind-arm.c:143:0:
/tmp/gcc-7.3.0/libgcc/unwind-arm-common.inc:30:10: fatal error:
sys/sdt.h: No such file or directory
 #include <sys/sdt.h>
          ^~~~~~~~~~~
compilation terminated.
make[2]: *** [unwind-arm.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory
`/home/sr/temp/gcbuild-testcross/arm-unknown-linux-gnueabi/libgcc'
make[1]: *** [all-target-libgcc] Error 2
make[1]: Leaving directory `/home/sr/temp/gcbuild-testcross'
make: *** [all] Error 2

Because the configure script looked at the system include directory to
determine the presence of 'sys/sdt.h'. I hard-coded the correct path
for 'target_header_dir' into the configure script (commented out
above), and everything worked perfectly. Maybe it did not use the
correct header files after all during the build, but at least this
does not seem to have an adverse effect.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-12-11  9:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-08 10:11 sysroot issue when cross-compiling a native compiler (gcc 7.3.0) Stefan Ring
2018-12-08 10:26 ` Stefan Ring
2018-12-09  2:21   ` Stefan Ring
2018-12-11 17:37     ` Stefan Ring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).