Opened 8 years ago

Closed 7 years ago

Last modified 5 years ago

#53726 closed defect (fixed)

libgcc / gcc fails to build against SDK (i.e. without system headers installed)

Reported by: jeremyhu (Jeremy Huddleston Sequoia) Owned by: jeremyhu (Jeremy Huddleston Sequoia)
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc: cooljeanius (Eric Gallager)
Port: libgcc

Description

libgcc (and gccXY) fail to build on systems that do not contain system headers (i.e., installs configured to use a real SDK rather than the DevSDK from CLTools).

The tail of the failure is:

/bin/sh /opt/local/var/macports/build/_Users_jeremy_src_macports_macports-ports_lang_gcc6/libgcc/work/gcc-6.3.0/gcc/../move-if-change tmp-macro_list macro_list
echo timestamp > s-macro_list
rm -rf include-fixed; mkdir include-fixed
chmod a+rx include-fixed
if [ -d ../prev-gcc ]; then \
	  cd ../prev-gcc && \
	  /Applications/Xcode.app/Contents/Developer/usr/bin/make real-install-headers-tar DESTDIR=`pwd`/../gcc/ \
	    libsubdir=. ; \
	else \
	  set -e; for ml in `cat fixinc_list`; do \
	    sysroot_headers_suffix=`echo ${ml} | sed -e 's/;.*$//'`; \
	    multi_dir=`echo ${ml} | sed -e 's/^[^;]*;//'`; \
	    fix_dir=include-fixed${multi_dir}; \
	    if ! false && test ! -d `echo /usr/include | sed -e :a -e 's,[^/]*/\.\.\/,,' -e ta`; then \
	      echo The directory that should contain system headers does not exist: >&2 ; \
	      echo "  `echo /usr/include | sed -e :a -e 's,[^/]*/\.\.\/,,' -e ta`" >&2 ; \
	      tooldir_sysinc=`echo "/opt/local/lib/libgcc/gcc/x86_64-apple-darwin17/6.3.0/../../../../../x86_64-apple-darwin17/sys-include" | sed -e :a -e "s,[^/]*/\.\.\/,," -e ta`; \
	      if test "x`echo /usr/include | sed -e :a -e 's,[^/]*/\.\.\/,,' -e ta`" = "x${tooldir_sysinc}"; \
	      then sleep 1; else exit 1; fi; \
	    fi; \
	    /bin/sh /opt/local/var/macports/build/_Users_jeremy_src_macports_macports-ports_lang_gcc6/libgcc/work/gcc-6.3.0/gcc/../mkinstalldirs ${fix_dir}; \
	    chmod a+rx ${fix_dir} || true; \
	    (TARGET_MACHINE='x86_64-apple-darwin17'; srcdir=`cd /opt/local/var/macports/build/_Users_jeremy_src_macports_macports-ports_lang_gcc6/libgcc/work/gcc-6.3.0/gcc; ${PWDCMD-pwd}`; \
	      SHELL='/bin/sh'; MACRO_LIST=`${PWDCMD-pwd}`/macro_list ; \
	      gcc_dir=`${PWDCMD-pwd}` ; \
	      export TARGET_MACHINE srcdir SHELL MACRO_LIST && \
	      cd ../build-x86_64-apple-darwin17/fixincludes && \
	      /bin/sh ./fixinc.sh "${gcc_dir}/${fix_dir}" \
	        `echo /usr/include | sed -e :a -e 's,[^/]*/\.\.\/,,' -e ta`  ); \
	    rm -f ${fix_dir}/syslimits.h; \
	    if [ -f ${fix_dir}/limits.h ]; then \
	      mv ${fix_dir}/limits.h ${fix_dir}/syslimits.h; \
	    else \
	      cp /opt/local/var/macports/build/_Users_jeremy_src_macports_macports-ports_lang_gcc6/libgcc/work/gcc-6.3.0/gcc/gsyslimits.h ${fix_dir}/syslimits.h; \
	    fi; \
	    chmod a+r ${fix_dir}/syslimits.h; \
	  done; \
	fi
The directory that should contain system headers does not exist:
  /usr/include
make[3]: *** [stmp-fixinc] Error 1
rm gcc.pod
make[3]: Leaving directory `/opt/local/var/macports/build/_Users_jeremy_src_macports_macports-ports_lang_gcc6/libgcc/work/build/gcc'
make[2]: *** [all-stage1-gcc] Error 2
make[2]: Leaving directory `/opt/local/var/macports/build/_Users_jeremy_src_macports_macports-ports_lang_gcc6/libgcc/work/build'
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory `/opt/local/var/macports/build/_Users_jeremy_src_macports_macports-ports_lang_gcc6/libgcc/work/build'
make: *** [bootstrap-lean] Error 2
make: Leaving directory `/opt/local/var/macports/build/_Users_jeremy_src_macports_macports-ports_lang_gcc6/libgcc/work/build'
Command failed:  cd "/opt/local/var/macports/build/_Users_jeremy_src_macports_macports-ports_lang_gcc6/libgcc/work/build" && /usr/bin/make -j8 -w bootstrap-lean 
Exit code: 2

Change History (11)

comment:1 Changed 8 years ago by jeremyhu (Jeremy Huddleston Sequoia)

I'll do my best to try and figure this out, but it's likely to not get fixed unless someone who is able to read GPLv3 code can fix the broken build.

comment:2 Changed 8 years ago by jeremyhu (Jeremy Huddleston Sequoia)

I suspected that this should work if I pass --with-build-sysroot=... to configure, but I still hit the same issue. I think that's likely an issue that upstream needs to fix, since it should be looking in the sysroot for /usr/include.

See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79885

Looking at gcc-4.2, I think this should work if I add SYSTEM_HEADER_DIR="${configure.sdkroot}/usr/include" to build.args, so giving that a try next...

comment:3 Changed 8 years ago by jeremyhu (Jeremy Huddleston Sequoia)

In cf631241/macports-ports:

gcc*: Fix building against an SDK

With this change, gcc now builds when configure.sdkroot is an SDK. The
intention is that the installed gcc should be identical to a build in which
configure.sdkroot is /, but GCC's build system is flawed and does not
properly implement their --with-build-sdkroot= configure option.

As a workaround, we are using --with-sdkroot= which causes the installed gcc
to look in the SDKROOT by default instead of / by default. Hopefully GCC
will provide a fix for this bug, or someone who is able to look at GPLv3 code
can provide a fix for them. In the mean time, this is better than failing
to build.

See #53726
See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79885

Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@…>

comment:4 Changed 8 years ago by kencu (Ken)

Something about this change appears to have broken the build of gcc48 (presently I'm doing this on 10.6 with Libcxx), working on fixing the gcc48 build with the new texinfo and new isl. With this change, this error comes up:

rm -f libgcov.a
objects="_gcov.o _gcov_merge_add.o _gcov_merge_single.o _gcov_merge_delta.o _gcov_fork.o _gcov_execl.o _gcov_execlp.o _gcov_execle.o _gcov_execv.o _gcov_execvp.o _gcov_execve.o _gcov_reset.o _gcov_dump.o _gcov_interval_profiler.o _gcov_pow2_profiler.o _gcov_one_value_profiler.o _gcov_indirect_call_profiler.o _gcov_average_profiler.o _gcov_ior_profiler.o _gcov_merge_ior.o";					\
	if test -z "$objects"; then				\
	  echo 'int __libgcc_eh_dummy;' > eh_dummy.c;		\
	  /opt/local/var/macports/build/_opt_macports-ports_lang_gcc48/gcc48/work/build/./gcc/xgcc -B/opt/local/var/macports/build/_opt_macports-ports_lang_gcc48/gcc48/work/build/./gcc/ -B/opt/local/x86_64-apple-darwin10/bin/ -B/opt/local/x86_64-apple-darwin10/lib/ -isystem /opt/local/x86_64-apple-darwin10/include -isystem /opt/local/x86_64-apple-darwin10/sys-include    -g -O2 -pipe -Os -O2  -g -O2 -pipe -Os -DIN_GCC   -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include   -pipe -fno-common -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector   -pipe -fno-common -I. -I. -I../.././gcc -I/opt/local/var/macports/build/_opt_macports-ports_lang_gcc48/gcc48/work/gcc-4.8.5/libgcc -I/opt/local/var/macports/build/_opt_macports-ports_lang_gcc48/gcc48/work/gcc-4.8.5/libgcc/. -I/opt/local/var/macports/build/_opt_macports-ports_lang_gcc48/gcc48/work/gcc-4.8.5/libgcc/../gcc -I/opt/local/var/macports/build/_opt_macports-ports_lang_gcc48/gcc48/work/gcc-4.8.5/libgcc/../include  -DHAVE_CC_TLS -DUSE_EMUTLS -fvisibility=hidden -DHIDE_EXPORTS -c eh_dummy.c		\
	     -o eh_dummy.o;				\
	  objects=eh_dummy.o;				\
	fi;							\
	/opt/local/bin/ar  rc libgcov.a $objects
ld: file not found: non-weak
collect2: error: ld returned 1 exit status
make[3]: *** [libgcc_s.dylib] Error 1

removing this change, this error disappears and the build proceeds:

rm -f libgcov.a
objects="_gcov.o _gcov_merge_add.o _gcov_merge_single.o _gcov_merge_delta.o _gcov_fork.o _gcov_execl.o _gcov_execlp.o _gcov_execle.o _gcov_execv.o _gcov_execvp.o _gcov_execve.o _gcov_reset.o _gcov_dump.o _gcov_interval_profiler.o _gcov_pow2_profiler.o _gcov_one_value_profiler.o _gcov_indirect_call_profiler.o _gcov_average_profiler.o _gcov_ior_profiler.o _gcov_merge_ior.o";					\
	if test -z "$objects"; then				\
	  echo 'int __libgcc_eh_dummy;' > eh_dummy.c;		\
	  /opt/local/var/macports/build/_opt_macports-ports_lang_gcc48/gcc48/work/build/./gcc/xgcc -B/opt/local/var/macports/build/_opt_macports-ports_lang_gcc48/gcc48/work/build/./gcc/ -B/opt/local/x86_64-apple-darwin10/bin/ -B/opt/local/x86_64-apple-darwin10/lib/ -isystem /opt/local/x86_64-apple-darwin10/include -isystem /opt/local/x86_64-apple-darwin10/sys-include    -g -O2 -pipe -Os -O2  -g -O2 -pipe -Os -DIN_GCC   -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include   -pipe -fno-common -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector   -pipe -fno-common -I. -I. -I../.././gcc -I/opt/local/var/macports/build/_opt_macports-ports_lang_gcc48/gcc48/work/gcc-4.8.5/libgcc -I/opt/local/var/macports/build/_opt_macports-ports_lang_gcc48/gcc48/work/gcc-4.8.5/libgcc/. -I/opt/local/var/macports/build/_opt_macports-ports_lang_gcc48/gcc48/work/gcc-4.8.5/libgcc/../gcc -I/opt/local/var/macports/build/_opt_macports-ports_lang_gcc48/gcc48/work/gcc-4.8.5/libgcc/../include  -DHAVE_CC_TLS -DUSE_EMUTLS -fvisibility=hidden -DHIDE_EXPORTS -c eh_dummy.c		\
	     -o eh_dummy.o;				\
	  objects=eh_dummy.o;				\
	fi;							\
	/opt/local/bin/ar  rc libgcov.a $objects
/opt/local/bin/ranlib libgcov.a
Last edited 8 years ago by kencu (Ken) (previous) (diff)

comment:5 Changed 8 years ago by jeremyhu (Jeremy Huddleston Sequoia)

This only changes the build if {${configure.sdkroot} ne "/"} ... Are you actually building against an SDK and it was working before?

What is ${configure.sdkroot} evaluating to for you? I wonder if I misread things and it's an empty string in some cases.

comment:6 Changed 8 years ago by kencu (Ken)

I think that's it exactly -- in my case, at least on this 10.6.8 machine I'm on right now, ${configure.sdkroot} evaluates to an empty string.

comment:7 Changed 8 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Thanks, Ken. Sorry about that.

comment:8 Changed 8 years ago by jeremyhu (Jeremy Huddleston Sequoia)

In 9d47963e/macports-ports:

gcc*: Fix test for unset SDKROOT

See #53726

Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@…>

comment:9 Changed 8 years ago by jeremyhu (Jeremy Huddleston Sequoia)

In 9d47963e/macports-ports:

gcc*: Fix test for unset SDKROOT

See #53726

Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@…>

comment:10 Changed 7 years ago by kencu (Ken)

Resolution: fixed
Status: newclosed

comment:11 Changed 5 years ago by cooljeanius (Eric Gallager)

Cc: cooljeanius added
Note: See TracTickets for help on using tickets.