1

When I'm trying to run Chapter 6.18 of the LFS (with systemd) book, make fails because in the file crtstuff.c, line 695, there is an undefined reference to __CTOR_END__. This seems like some sort of g++ error to me (C doesn't have constructors, so I guess this is c++). I reviewed the commands a few times and all my ./configure arguments are correct, so I do not know what the problem is here, unfortunately.

EDIT: If you came here with the same problem looking for a fix, you messed up building the cross gcc. rebuild gcc and look closely, it's --enable-initfini-array, not --disable-initfini--array.

The command I am using is:

../configure --build=$(../config.guess) --host=$LFS_TGT --prefix=/usr CC_FOR_TARGET=$LFS_TGT-gcc --with-build-sysroot=$LFS --enable-initfini-array --disable-nls --disable-multilib --disable-decimal-float --disable--libatomic --disable-libgomp --disable-libquadmath --disable-libssp --disable-libvtv --disable-libstdcxx --enable-languages=c,c++ && make && make DESTDIR=$LFS install && ln -sv gcc $LFS/usr/bin/cc

I don't think I messed up libgcc because I don't think I would have made it this far otherwise, or am I completely off on this one?

Edit: I was asked to provide the full make error, this is it:

Most of it is make telling me nothing to do because I ran this command before a few times.

<code>
make[1]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build'
make[2]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/intl'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/intl'
make[2]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/build-x86_64-pc-linux-gnu/libiberty'
make[2]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp'
make[2]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/libiberty'
make[2]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/libbacktrace'
make  all-recursive
make[2]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/libdecnumber'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/libdecnumber'
make  all-am
make[3]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp'
make[3]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/libbacktrace'
true  DO=all multi-do # make
make[3]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/build-x86_64-pc-linux-gnu/libiberty/testsuite'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/build-x86_64-pc-linux-gnu/libiberty/testsuite'
Making all in tests
make[3]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/libbacktrace'
make[2]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/libbacktrace'
make[3]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/libiberty/testsuite'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/libiberty/testsuite'
make[2]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/build-x86_64-pc-linux-gnu/libiberty'
make[4]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/tests'
make[2]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/libiberty'
make[2]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/zlib'
true "AR_FLAGS=rc" "CC_FOR_BUILD=gcc" "CFLAGS=-g -O2" "CXXFLAGS=-g -O2" "CFLAGS_FOR_BUILD=" "CFLAGS_FOR_TARGET=-g -O2" "INSTALL=/usr/bin/install -c" "INSTALL_DATA=/usr/bin/install -c -m 644" "INSTALL_PROGRAM=/usr/bin/install -c" "INSTALL_SCRIPT=/usr/bin/install -c" "LDFLAGS=-static-libstdc++ -static-libgcc " "LIBCFLAGS=-g -O2" "LIBCFLAGS_FOR_TARGET=-g -O2" "MAKE=make" "MAKEINFO=makeinfo --split-size=5000000 --split-size=5000000 " "PICFLAG=" "PICFLAG_FOR_TARGET=" "SHELL=/bin/sh" "EXPECT=expect" "RUNTEST=runtest" "RUNTESTFLAGS=" "exec_prefix=/usr" "infodir=/usr/share/info" "libdir=/usr/lib" "prefix=/usr" "tooldir=/usr/x86_64-lfs-linux-gnu" "AR=x86_64-lfs-linux-gnu-ar" "AS=x86_64-lfs-linux-gnu-as" "CC=x86_64-lfs-linux-gnu-gcc" "CXX=x86_64-lfs-linux-gnu-g++" "LD=/mnt/lfs/tools/lib/gcc/x86_64-lfs-linux-gnu/10.2.0/../../../../x86_64-lfs-linux-gnu/bin/ld" "LIBCFLAGS=-g -O2" "NM=x86_64-lfs-linux-gnu-nm" "PICFLAG=" "RANLIB=x86_64-lfs-linux-gnu-ranlib" "DESTDIR=" DO=all multi-do # make
make[2]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/zlib'
Making all in .
make[5]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/tests'
make[5]: Nothing to be done for 'all-am'.
make[5]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/tests'
Making all in devel
make[5]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/tests/devel'
make[5]: Nothing to be done for 'all'.
make[5]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/tests/devel'
Making all in mpn
make[2]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/build-x86_64-pc-linux-gnu/fixincludes'
make[5]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/tests/mpn'
make[5]: Nothing to be done for 'all'.
make[5]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/tests/mpn'
Making all in mpz
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/build-x86_64-pc-linux-gnu/fixincludes'
make[2]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/build-x86_64-pc-linux-gnu/libcpp'
test -f config.h || (rm -f stamp-h1 && make stamp-h1)
make[2]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/fixincludes'
make[2]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/lto-plugin'
make[5]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/tests/mpz'
make[5]: Nothing to be done for 'all'.
make[5]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/tests/mpz'
make[2]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/build-x86_64-pc-linux-gnu/libcpp'
Making all in mpq
make[2]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/libcpp'
test -f config.h || (rm -f stamp-h1 && make stamp-h1)
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/fixincludes'
make[5]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/tests/mpq'
make[5]: Nothing to be done for 'all'.
make[5]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/tests/mpq'
Making all in mpf
make  all-am
make[2]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/libcpp'
make[3]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/lto-plugin'
make[5]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/tests/mpf'
make[5]: Nothing to be done for 'all'.
make[5]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/tests/mpf'
Making all in rand
make[5]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/tests/rand'
make[5]: Nothing to be done for 'all'.
make[5]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/tests/rand'
Making all in misc
make[3]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/lto-plugin'
make[2]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/lto-plugin'
make[5]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/tests/misc'
make[5]: Nothing to be done for 'all'.
make[5]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/tests/misc'
Making all in cxx
make[5]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/tests/cxx'
make[5]: Nothing to be done for 'all'.
make[5]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/tests/cxx'
make[4]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/tests'
Making all in mpn
make[4]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/mpn'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/mpn'
Making all in mpz
make[4]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/mpz'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/mpz'
Making all in mpq
make[4]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/mpq'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/mpq'
Making all in mpf
make[4]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/mpf'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/mpf'
Making all in printf
make[4]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/printf'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/printf'
Making all in scanf
make[4]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/scanf'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/scanf'
Making all in rand
make[4]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/rand'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/rand'
Making all in cxx
make[4]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/cxx'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/cxx'
Making all in demos
make[4]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/demos'
Making all in calc
make[5]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/demos/calc'
make  all-am
make[6]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/demos/calc'
make[6]: Nothing to be done for 'all-am'.
make[6]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/demos/calc'
make[5]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/demos/calc'
Making all in expr
make[5]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/demos/expr'
make[5]: Nothing to be done for 'all'.
make[5]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/demos/expr'
make[5]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/demos'
make[5]: Nothing to be done for 'all-am'.
make[5]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/demos'
make[4]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/demos'
Making all in tune
make[4]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/tune'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/tune'
Making all in doc
make[4]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/doc'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp/doc'
make[4]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp'
make[4]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp'
make[3]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp'
make[2]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/gmp'
make[2]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/mpfr'
Making all in doc
make[3]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/mpfr/doc'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/mpfr/doc'
Making all in src
make[3]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/mpfr/src'
make  all-am
make[4]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/mpfr/src'
make[4]: Nothing to be done for 'all-am'.
make[4]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/mpfr/src'
make[3]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/mpfr/src'
Making all in tests
make[3]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/mpfr/tests'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/mpfr/tests'
Making all in tune
make[3]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/mpfr/tune'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/mpfr/tune'
Making all in tools/bench
make[3]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/mpfr/tools/bench'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/mpfr/tools/bench'
make[3]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/mpfr'
make[3]: Nothing to be done for 'all-am'.
make[3]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/mpfr'
make[2]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/mpfr'
make[2]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/mpc'
make  all-recursive
make[3]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/mpc'
Making all in src
make[4]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/mpc/src'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/mpc/src'
Making all in tests
make[4]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/mpc/tests'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/mpc/tests'
Making all in doc
make[4]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/mpc/doc'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/mpc/doc'
Making all in tools
make[4]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/mpc/tools'
Making all in bench
make[5]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/mpc/tools/bench'
make[5]: Nothing to be done for 'all'.
make[5]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/mpc/tools/bench'
Making all in mpcheck
make[5]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/mpc/tools/mpcheck'
make[5]: Nothing to be done for 'all'.
make[5]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/mpc/tools/mpcheck'
make[5]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/mpc/tools'
make[5]: Nothing to be done for 'all-am'.
make[5]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/mpc/tools'
make[4]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/mpc/tools'
make[4]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/mpc'
make[4]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/mpc'
make[3]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/mpc'
make[2]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/mpc'
make[2]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/gcc'
make[2]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/gcc'
Checking multilib configuration for libgcc...
make[2]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/libcc1'
make  all-am
make[2]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/x86_64-lfs-linux-gnu/libgcc'
make[3]: Entering directory '/mnt/lfs/sources/gcc-10.2.0/build/libcc1'
make[3]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/libcc1'
make[2]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/libcc1'
# If this is the top-level multilib, build all the other
# multilibs.
x86_64-lfs-linux-gnu-gcc --sysroot=/mnt/lfs   -g -O2 -O2 -g -O2 -DIN_GCC    -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-error=format-diag -Wstrict-prototypes -Wmissing-prototypes -Wno-error=format-diag -Wold-style-definition  -isystem ./include  -I. -I. -I../.././gcc -I../../../libgcc -I../../../libgcc/. -I../../../libgcc/../gcc -I../../../libgcc/../include   -g0  -finhibit-size-directive -fno-inline -fno-exceptions -fno-zero-initialized-in-bss -fno-toplevel-reorder -fno-tree-vectorize -fbuilding-libgcc -fno-stack-protector    -I. -I. -I../.././gcc -I../../../libgcc -I../../../libgcc/. -I../../../libgcc/../gcc -I../../../libgcc/../include  -o crtend.o -MT crtend.o -MD -MP -MF crtend.dep -fno-omit-frame-pointer -fno-asynchronous-unwind-tables  -c ../../../libgcc/crtstuff.c -DCRT_END
x86_64-lfs-linux-gnu-gcc --sysroot=/mnt/lfs   -g -O2 -O2 -g -O2 -DIN_GCC    -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-error=format-diag -Wstrict-prototypes -Wmissing-prototypes -Wno-error=format-diag -Wold-style-definition  -isystem ./include  -I. -I. -I../.././gcc -I../../../libgcc -I../../../libgcc/. -I../../../libgcc/../gcc -I../../../libgcc/../include   -g0  -finhibit-size-directive -fno-inline -fno-exceptions -fno-zero-initialized-in-bss -fno-toplevel-reorder -fno-tree-vectorize -fbuilding-libgcc -fno-stack-protector    -I. -I. -I../.././gcc -I../../../libgcc -I../../../libgcc/. -I../../../libgcc/../gcc -I../../../libgcc/../include  -o crtendS.o -MT crtendS.o -MD -MP -MF crtendS.dep -fno-omit-frame-pointer -fno-asynchronous-unwind-tables  -fpic -c ../../../libgcc/crtstuff.c -DCRT_END -DCRTSTUFFS_O
dest=../.././gcc/include/tmp$$-unwind.h; \
cp unwind.h $dest; \
chmod a+r $dest; \
sh ../../../libgcc/../move-if-change $dest ../.././gcc/include/unwind.h
rm -f libgcc.a
objects="_muldi3.o _negdi2.o _lshrdi3.o _ashldi3.o _ashrdi3.o _cmpdi2.o _ucmpdi2.o _clear_cache.o _trampoline.o __main.o _absvsi2.o _absvdi2.o _addvsi3.o _addvdi3.o _subvsi3.o _subvdi3.o _mulvsi3.o _mulvdi3.o _negvsi2.o _negvdi2.o _ctors.o _ffssi2.o _ffsdi2.o _clz.o _clzsi2.o _clzdi2.o _ctzsi2.o _ctzdi2.o _popcount_tab.o _popcountsi2.o _popcountdi2.o _paritysi2.o _paritydi2.o _powisf2.o _powidf2.o _powixf2.o _mulhc3.o _mulsc3.o _muldc3.o _mulxc3.o _divhc3.o _divsc3.o _divdc3.o _divxc3.o _bswapsi2.o _bswapdi2.o _clrsbsi2.o _clrsbdi2.o _fixunssfsi.o _fixunsdfsi.o _fixunsxfsi.o _fixsfdi.o _fixdfdi.o _fixxfdi.o _fixunssfdi.o _fixunsdfdi.o _fixunsxfdi.o _floatdisf.o _floatdidf.o _floatdixf.o _floatundisf.o _floatundidf.o _floatundixf.o _eprintf.o __gcc_bcmp.o _divdi3.o _moddi3.o _divmoddi4.o _udivdi3.o _umoddi3.o _udivmoddi4.o _udiv_w_sdiv.o cpuinfo.o sfp-exceptions.o addtf3.o divtf3.o multf3.o negtf2.o subtf3.o unordtf2.o fixtfsi.o fixunstfsi.o floatsitf.o floatunsitf.o fixtfdi.o fixunstfdi.o floatditf.o floatunditf.o fixtfti.o fixunstfti.o floattitf.o floatuntitf.o extendsftf2.o extenddftf2.o extendxftf2.o trunctfsf2.o trunctfdf2.o trunctfxf2.o getf2.o letf2.o eqtf2.o _divtc3.o _multc3.o _powitf2.o enable-execute-stack.o avx_savms64.o avx_resms64.o avx_resms64x.o avx_savms64f.o avx_resms64f.o avx_resms64fx.o sse_savms64.o sse_resms64.o sse_resms64x.o sse_savms64f.o sse_resms64f.o sse_resms64fx.o generic-morestack.o generic-morestack-thread.o morestack.o";                                  \
if test -z "$objects"; then                             \
  echo 'int __libgcc_eh_dummy;' > eh_dummy.c;           \
  x86_64-lfs-linux-gnu-gcc --sysroot=/mnt/lfs   -g -O2 -O2  -g -O2 -DIN_GCC    -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-error=format-diag -Wstrict-prototypes -Wmissing-prototypes -Wno-error=format-diag -Wold-style-definition  -isystem ./include  -fpic -mlong-double-80 -DUSE_ELF_SYMVER  -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector  -fpic -mlong-double-80 -DUSE_ELF_SYMVER  -I. -I. -I../.././gcc -I../../../libgcc -I../../../libgcc/. -I../../../libgcc/../gcc -I../../../libgcc/../include  -DHAVE_CC_TLS  -DUSE_TLS -fvisibility=hidden -DHIDE_EXPORTS -c eh_dummy.c                \
     -o eh_dummy.o;                             \
  objects=eh_dummy.o;                           \
fi;                                                     \
/mnt/lfs/tools/lib/gcc/x86_64-lfs-linux-gnu/10.2.0/../../../../x86_64-lfs-linux-gnu/bin/ar  rc libgcc.a $objects
/mnt/lfs/tools/lib/gcc/x86_64-lfs-linux-gnu/10.2.0/../../../../x86_64-lfs-linux-gnu/bin/ranlib libgcc.a
../../../libgcc/crtstuff.c: In function '__do_global_ctors_aux':
../../../libgcc/crtstuff.c:695:12: error: '__CTOR_END__' undeclared (first use in this function); did you mean '__TMC_END__'?
  695 |   for (p = __CTOR_END__ - 1; *p != (func_ptr) -1; p--)
      |            ^~~~~~~~~~~~
      |            __TMC_END__
../../../libgcc/crtstuff.c:695:12: note: each undeclared identifier is reported only once for each function it appears in
make[2]: *** [Makefile:1035: crtendS.o] Error 1
make[2]: *** Waiting for unfinished jobs....
../../../libgcc/crtstuff.c: In function '__do_global_ctors_aux':
../../../libgcc/crtstuff.c:695:12: error: '__CTOR_END__' undeclared (first use in this function); did you mean '__TMC_END__'?
  695 |   for (p = __CTOR_END__ - 1; *p != (func_ptr) -1; p--)
      |            ^~~~~~~~~~~~
      |            __TMC_END__
../../../libgcc/crtstuff.c:695:12: note: each undeclared identifier is reported only once for each function it appears in
make[2]: *** [Makefile:1028: crtend.o] Error 1
make[2]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build/x86_64-lfs-linux-gnu/libgcc'
make[1]: *** [Makefile:12920: all-target-libgcc] Error 2
make[1]: Leaving directory '/mnt/lfs/sources/gcc-10.2.0/build'
make: *** [Makefile:945: all] Error 2
12
  • This may not be related to C++. GCC allows some C functions to be tagged with the "constructor" (resp. "destructor") attribute so that they are executed just before (resp. after, similarly to atexit()) the main() function. See the GCC manual. See also this question on SO for an example of use.
    – xhienne
    Commented May 10, 2021 at 0:05
  • This is good to know (thank you), but I'm not sure how that is helping me fix my problem. the cross-gcc complains that it isn't valid syntax. Commented May 10, 2021 at 0:13
  • Let's slow down, run each command individually, and post the full error message(s). Commented May 10, 2021 at 0:15
  • I edited my post, pardon the formatting, I don't know how to embed spoilers. Sorry :/ Commented May 10, 2021 at 0:19
  • @AlexanderP The purpose of my comment is to help you focus on the actual problem: instead of looking for an illegitimate call to g++ somewhere in the building process, I would search for an inadequate linker (ld) version or an inadequate crtstuff.c file. As I understand it, this is either a linker issue (no __CTOR_END__ symbol in the resulting binary but there should be one), or you are using a wrong crtstuff.c file (it expects a __CTOR_END__ symbol whereas this compiler chain does not provide one). Update: your output shows this is a compilation issue, not a linker one.
    – xhienne
    Commented May 10, 2021 at 0:29

1 Answer 1

0

Anyone else coming here with a similar problem: You messed up your cross-gcc. Make sure you have the --enable-initfini-array option set. I didn't need to rebuild the rest of the toolchain, but I wouldn't rely on it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .