After migrating to gcc 4.5.0 my build is reporting these kinds of errors at link time: undefined reference to `_savegpr_31' undefined reference to `_restgpr_31_x' gcc 4.4.3 didn't emit _savegpr_* _restgpr_* etc. symbols when configured this way. powerpc-eabispe-gcc -v Using built-in specs. COLLECT_GCC=powerpc-eabispe-gcc COLLECT_LTO_WRAPPER=/home/patrick/src/e7/toolchain/stage2/libexec/gcc/powerpc-eabispe/4.5.0/lto-wrapper Target: powerpc-eabispe Configured with: /home/patrick/src/e7/toolchain/src/gcc-4.5.0/configure --prefix=/home/patrick/src/e7/toolchain/stage2 --build=x86_64-unknown-linux-gnu --host=x86_64-unknown-linux-gnu --target=powerpc-eabispe --enable-languages=c,c++ --with-sysroot=/home/patrick/src/e7/prex_sysroot --disable-nls --disable-werror --with-newlib --disable-shared --disable-debug --disable-libssp --with-cpu=8540 Thread model: single gcc version 4.5.0 (GCC) Unfortunately I'm not familiar enough with the internals of gcc to take this any further. Is there any more debugging I can provide?
Those functions are part of the ABI and should be provided by your libc. Does this error happen while you are linking your program or while building GCC?
Happens while linking my program. Where in libc are they intended to live? Looking through the source it looks like they may be part of libgcc.a but for powerpc-eabispe they aren't built.
I've just done a fresh gcc build and crtsavgpr.asm crtresgpr.asm and friends definitely aren't being assembled. Am I expected to provide these functions in the library layer of my operating system?
libgcc.a should provide these and libgcc.so should be a linker script.
Running powerpc-eabispe-objdump -t `powerpc-eabispe-gcc --print-libgcc-file-name` |grep _save shows no symbols so I assume something in the build process has gone wrong. Do you need me to attach my libgcc.a or any object dump output?
I have similar problem when building glibc for 603e. When I dump libgcc.a then it shows these symbols but they are hidden crtsavfpr.o: file format elf32-powerpc 00000000 g F .text 0000004c .hidden _savefpr_14 00000004 g F .text 00000048 .hidden _savefpr_15 00000008 g F .text 00000044 .hidden _savefpr_16 0000000c g F .text 00000040 .hidden _savefpr_17 00000010 g F .text 0000003c .hidden _savefpr_18 00000014 g F .text 00000038 .hidden _savefpr_19 00000018 g F .text 00000034 .hidden _savefpr_20 0000001c g F .text 00000030 .hidden _savefpr_21 00000020 g F .text 0000002c .hidden _savefpr_22 00000024 g F .text 00000028 .hidden _savefpr_23 00000028 g F .text 00000024 .hidden _savefpr_24 0000002c g F .text 00000020 .hidden _savefpr_25 00000030 g F .text 0000001c .hidden _savefpr_26 00000034 g F .text 00000018 .hidden _savefpr_27 00000038 g F .text 00000014 .hidden _savefpr_28 0000003c g F .text 00000010 .hidden _savefpr_29 00000040 g F .text 0000000c .hidden _savefpr_30 00000044 g F .text 00000008 .hidden _savefpr_31 crtsavgpr.o: file format elf32-powerpc 00000000 g F .text 0000004c .hidden _savegpr_14 00000004 g F .text 00000048 .hidden _savegpr_15 00000008 g F .text 00000044 .hidden _savegpr_16 0000000c g F .text 00000040 .hidden _savegpr_17 00000010 g F .text 0000003c .hidden _savegpr_18 00000014 g F .text 00000038 .hidden _savegpr_19 00000018 g F .text 00000034 .hidden _savegpr_20 0000001c g F .text 00000030 .hidden _savegpr_21 00000020 g F .text 0000002c .hidden _savegpr_22 00000024 g F .text 00000028 .hidden _savegpr_23 00000028 g F .text 00000024 .hidden _savegpr_24 0000002c g F .text 00000020 .hidden _savegpr_25 00000030 g F .text 0000001c .hidden _savegpr_26 00000034 g F .text 00000018 .hidden _savegpr_27 00000038 g F .text 00000014 .hidden _savegpr_28 0000003c g F .text 00000010 .hidden _savegpr_29 00000040 g F .text 0000000c .hidden _savegpr_30 00000044 g F .text 00000008 .hidden _savegpr_31
calls to _savegpr_31 and _restgpr_31_x are only generated when compiling libgcc with -Os same compiled with -O2 it does not emit the calls here is a reduced testcase from crtstuff.c compile it will -Os and then with -O2 typedef void (*func_ptr) (void); static func_ptr __CTOR_END__[1] __attribute__((section(".ctors"), aligned(sizeof(func_ptr)))) = { (func_ptr) 0 }; static void __attribute__((used)) __do_global_ctors_aux (void) { func_ptr *p; for (p = __CTOR_END__ - 1; *p != (func_ptr) -1; p--) (*p) (); }
below is the linker command that reports liking error. /scratch/oe/efika/cross/ppc603e/lib/gcc/powerpc-oe-linux/4.5.0/crtend.o: In function `__do_global_ctors_aux': crtstuff.c:(.text+0xc): undefined reference to `_savegpr_31' collect2: ld returned 1 exit status as we can see the failure is seen in crtend.o and in the linking order libgcc is specified before crtend.o therefore it does not pick the required object from libgcc.a if I add -lgcc after crtend.o then it links successfully. /scratch/oe/efika/cross/ppc603e/bin/powerpc-oe-linux-gcc -nostdlib -nostartfiles -o /scratch/oe/efika/work/ppc603e-oe-linux/eglibc-2.11-r10.4/build-powerpc-oe-linux/posix/getconf -Wl,-dynamic-linker=/lib/ld.so.1 -Wl,-z,combreloc -Wl,-z,relro -Wl,--hash-style=both /scratch/oe/efika/work/ppc603e-oe-linux/eglibc-2.11-r10.4/build-powerpc-oe-linux/csu/crt1.o /scratch/oe/efika/work/ppc603e-oe-linux/eglibc-2.11-r10.4/build-powerpc-oe-linux/csu/crti.o `/scratch/oe/efika/cross/ppc603e/bin/powerpc-oe-linux-gcc -mcpu=603e -mhard-float --print-file-name=crtbegin.o` /scratch/oe/efika/work/ppc603e-oe-linux/eglibc-2.11-r10.4/build-powerpc-oe-linux/posix/getconf.o -Wl,-rpath-link=/scratch/oe/efika/work/ppc603e-oe-linux/eglibc-2.11-r10.4/build-powerpc-oe-linux:/scratch/oe/efika/work/ppc603e-oe-linux/eglibc-2.11-r10.4/build-powerpc-oe-linux/math:/scratch/oe/efika/work/ppc603e-oe-linux/eglibc-2.11-r10.4/build-powerpc-oe-linux/elf:/scratch/oe/efika/work/ppc603e-oe-linux/eglibc-2.11-r10.4/build-powerpc-oe-linux/dlfcn:/scratch/oe/efika/work/ppc603e-oe-linux/eglibc-2.11-r10.4/build-powerpc-oe-linux/nss:/scratch/oe/efika/work/ppc603e-oe-linux/eglibc-2.11-r10.4/build-powerpc-oe-linux/nis:/scratch/oe/efika/work/ppc603e-oe-linux/eglibc-2.11-r10.4/build-powerpc-oe-linux/rt:/scratch/oe/efika/work/ppc603e-oe-linux/eglibc-2.11-r10.4/build-powerpc-oe-linux/resolv:/scratch/oe/efika/work/ppc603e-oe-linux/eglibc-2.11-r10.4/build-powerpc-oe-linux/crypt:/scratch/oe/efika/work/ppc603e-oe-linux/eglibc-2.11-r10.4/build-powerpc-oe-linux/nptl /scratch/oe/efika/work/ppc603e-oe-linux/eglibc-2.11-r10.4/build-powerpc-oe-linux/libc.so.6 /scratch/oe/efika/work/ppc603e-oe-linux/eglibc-2.11-r10.4/build-powerpc-oe-linux/libc_nonshared.a -lgcc `/scratch/oe/efika/cross/ppc603e/bin/powerpc-oe-linux-gcc -mcpu=603e -mhard-float --print-file-name=crtend.o` /scratch/oe/efika/work/ppc603e-oe-linux/eglibc-2.11-r10.4/build-powerpc-oe-linux/csu/crtn.o
Khem, Your libgcc.a looks fine. As far as I know, libgcc.a is supposed to be the last library listed when linking so the behaviour you are seeing is normal. My problem is that libgcc.a does not contain _savegpr_* and _restgpr_* functions at all. It looks like they are only built for linux and gnu targets, not eabispe.
See comment #4. I believe this is a pilot error.
(In reply to comment #10) > See comment #4. I believe this is a pilot error. > yeah on 4.5.0 libgcc.so is a linker script but 4.4 is still broken with this issues I guess http://gcc.gnu.org/ml/gcc-cvs/2009-09/msg00315.html needs backported to 4.4 branch as well.
(In reply to comment #10) > See comment #4. I believe this is a pilot error. > Richard, Are you referring to my original bug report or to Khem's link problem. I don't think (unless I've messed up my gcc build) that my original report is misuse.
GCC 4.5.1 is being released, adjusting target milestone.
GCC 4.5.2 is being released, adjusting target milestone.
For the record: the problem appears to be still present in 4.5.1 (at least I run into the same symptoms when trying to build poky with "--enable-target-optspace" enabled.
4.5.2 also carries the issue.
Author: froydnj Date: Wed Feb 23 18:06:29 2011 New Revision: 170443 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=170443 Log: PR target/43810 Backport from mainline: 2010-07-23 Nathan Froyd <froydnj@codesourcery.com> * config.host (powerpc*-eabispe*): Set tmake_file. (powerpc*-eabi*): Likewise. * config/rs6000/t-ppccomm (EXTRA_PARTS): Add crtbegin, crtend, crtbeginS, crtendS, crtbeginT. Modified: branches/gcc-4_5-branch/libgcc/ChangeLog branches/gcc-4_5-branch/libgcc/config.host branches/gcc-4_5-branch/libgcc/config/rs6000/t-ppccomm
Fixed on the 4.5 branch. If there are still problems with --enable-target-optspace, please open a separate bug for those.
I still get the error similar to Khem's one with gcc 4.5.1 and proposed patch applied: ccache powerpc-poky-linux-gcc -mcpu=603e -msoft-float --sysroot=/opt/work/yanok/poky/build/tmp/sysroots/ppc603e-poky-linux -nostdlib -nostartfiles -o /opt/work/yanok/poky/build/tmp/work/ppc603e-poky-linux/eglibc-2.12-r13/build-powerpc-poky-linux/iconv/iconv_prog -msoft-float -Wl,-dynamic-linker=/lib/ld.so.1 -Wl,-z,combreloc -Wl,-z,relro -Wl,--hash-style=both /opt/work/yanok/poky/build/tmp/work/ppc603e-poky-linux/eglibc-2.12-r13/build-powerpc-poky-linux/csu/crt1.o /opt/work/yanok/poky/build/tmp/work/ppc603e-poky-linux/eglibc-2.12-r13/build-powerpc-poky-linux/csu/crti.o `ccache powerpc-poky-linux-gcc -mcpu=603e -msoft-float --sysroot=/opt/work/yanok/poky/build/tmp/sysroots/ppc603e-poky-linux -msoft-float --print-file-name=crtbegin.o` /opt/work/yanok/poky/build/tmp/work/ppc603e-poky-linux/eglibc-2.12-r13/build-powerpc-poky-linux/iconv/iconv_prog.o /opt/work/yanok/poky/build/tmp/work/ppc603e-poky-linux/eglibc-2.12-r13/build-powerpc-poky-linux/iconv/iconv_charmap.o /opt/work/yanok/poky/build/tmp/work/ppc603e-poky-linux/eglibc-2.12-r13/build-powerpc-poky-linux/iconv/charmap.o /opt/work/yanok/poky/build/tmp/work/ppc603e-poky-linux/eglibc-2.12-r13/build-powerpc-poky-linux/iconv/charmap-dir.o /opt/work/yanok/poky/build/tmp/work/ppc603e-poky-linux/eglibc-2.12-r13/build-powerpc-poky-linux/iconv/linereader.o /opt/work/yanok/poky/build/tmp/work/ppc603e-poky-linux/eglibc-2.12-r13/build-powerpc-poky-linux/iconv/dummy-repertoire.o /opt/work/yanok/poky/build/tmp/work/ppc603e-poky-linux/eglibc-2.12-r13/build-powerpc-poky-linux/iconv/simple-hash.o /opt/work/yanok/poky/build/tmp/work/ppc603e-poky-linux/eglibc-2.12-r13/build-powerpc-poky-linux/iconv/xstrdup.o /opt/work/yanok/poky/build/tmp/work/ppc603e-poky-linux/eglibc-2.12-r13/build-powerpc-poky-linux/iconv/xmalloc.o -Wl,-rpath-link=/opt/work/yanok/poky/build/tmp/work/ppc603e-poky-linux/eglibc-2.12-r13/build-powerpc-poky-linux:/opt/work/yanok/poky/build/tmp/work/ppc603e-poky-linux/eglibc-2.12-r13/build-powerpc-poky-linux/math:/opt/work/yanok/poky/build/tmp/work/ppc603e-poky-linux/eglibc-2.12-r13/build-powerpc-poky-linux/elf:/opt/work/yanok/poky/build/tmp/work/ppc603e-poky-linux/eglibc-2.12-r13/build-powerpc-poky-linux/dlfcn:/opt/work/yanok/poky/build/tmp/work/ppc603e-poky-linux/eglibc-2.12-r13/build-powerpc-poky-linux/nss:/opt/work/yanok/poky/build/tmp/work/ppc603e-poky-linux/eglibc-2.12-r13/build-powerpc-poky-linux/nis:/opt/work/yanok/poky/build/tmp/work/ppc603e-poky-linux/eglibc-2.12-r13/build-powerpc-poky-linux/rt:/opt/work/yanok/poky/build/tmp/work/ppc603e-poky-linux/eglibc-2.12-r13/build-powerpc-poky-linux/resolv:/opt/work/yanok/poky/build/tmp/work/ppc603e-poky-linux/eglibc-2.12-r13/build-powerpc-poky-linux/crypt:/opt/work/yanok/poky/build/tmp/work/ppc603e-poky-linux/eglibc-2.12-r13/build-powerpc-poky-linux/nptl /opt/work/yanok/poky/build/tmp/work/ppc603e-poky-linux/eglibc-2.12-r13/build-powerpc-poky-linux/libc.so.6 /opt/work/yanok/poky/build/tmp/work/ppc603e-poky-linux/eglibc-2.12-r13/build-powerpc-poky-linux/libc_nonshared.a -Wl,--as-needed /opt/work/yanok/poky/build/tmp/work/ppc603e-poky-linux/eglibc-2.12-r13/build-powerpc-poky-linux/elf/ld.so -Wl,--no-as-needed -lgcc -Wl,--as-needed -lgcc_s -Wl,--no-as-needed `ccache powerpc-poky-linux-gcc -mcpu=603e -msoft-float --sysroot=/opt/work/yanok/poky/build/tmp/sysroots/ppc603e-poky-linux -msoft-float --print-file-name=crtend.o` /opt/work/yanok/poky/build/tmp/work/ppc603e-poky-linux/eglibc-2.12-r13/build-powerpc-poky-linux/csu/crtn.o /opt/work/yanok/poky/build/tmp/sysroots/x86_64-linux/usr/lib/ppc603e-poky-linux/gcc/powerpc-poky-linux/4.5.1/crtend.o: In function `__do_global_ctors_aux': crtstuff.c:(.text+0xc): undefined reference to `_savegpr_31' collect2: ld returned 1 exit status Though libgcc.a does contain _savegpr_31.