https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100896
Fangrui Song <i at maskray dot me> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |i at maskray dot me --- Comment #4 from Fangrui Song <i at maskray dot me> --- In gcc/acinclude.m4:285, if cross-compiling, (`if test "x${build}" = "x${target}" && test "x${build}" = "x${host}"; then `) will not be taken. else case "${target}" in aarch64*-linux-gnu*) # AArch64 postdates glibc support for .init_array/.fini_array, # so we don't need the preprocessor test above. gcc_cv_initfini_array=yes ;; *) AC_MSG_CHECKING(cross compile... guessing) gcc_cv_initfini_array=no ;; esac fi]) On non-aarch64, `gcc_cv_initfini_array=no` will run, `HAVE_INITFINI_ARRAY_SUPPORT` will therefore be 0. compilers/powerpc64le-linux-gnu/gcc/gcc/auto-host.h 1578:#define HAVE_INITFINI_ARRAY_SUPPORT 0 compilers/powerpc64le-linux-gnu/gcc/gcc/config.status 1257:D["HAVE_INITFINI_ARRAY_SUPPORT"]=" 0" compilers/powerpc64le-linux-gnu/gcc/gcc/config.log 6900:| #define HAVE_INITFINI_ARRAY_SUPPORT 0 7169:| #define HAVE_INITFINI_ARRAY_SUPPORT 0 7484:| #define HAVE_INITFINI_ARRAY_SUPPORT 0 8557:#define HAVE_INITFINI_ARRAY_SUPPORT 0 The built GCC will use the legacy .ctors % many=/tmp/glibc-many % cat a.c __attribute__ ((constructor)) static int foo (void) { return 42; } % /tmp/glibc-many/install/compilers/powerpc64le-linux-gnu/bin/powerpc64le-glibc-linux-gnu-gcc -c a.c && readelf -WS a.o | egrep 'ctors|init_array' [ 4] .ctors PROGBITS 0000000000000000 000070 000008 00 WA 0 0 8 [ 5] .rela.ctors RELA 0000000000000000 000218 000018 18 I 10 4 8 --- Noticed the problem when using scripts/build-many-glibcs.py built GCC (cd ~/Dev/glibc) scripts/build-many-glibcs.py /tmp/glibc-many checkout --shallow scripts/build-many-glibcs.py /tmp/glibc-many host-libraries scripts/build-many-glibcs.py /tmp/glibc-many compilers powerpc64le-linux-gnu --keep all