Bug 6872 - GCC bails out with "undefined reference to `_restgpr_??_x'" errors
Summary: GCC bails out with "undefined reference to `_restgpr_??_x'" errors
Status: VERIFIED NOTABUG
Alias: None
Product: General Runtime
Classification: Runtime
Component: General Runtime (show other bugs)
Version: 1.7
Hardware: All ppc
: Medium+ major
Target Milestone: 1.8 M3
Assignee: Richard Purdie
QA Contact: Alexandru Georgescu
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2014-10-23 13:00 UTC by Wolfgang Denk
Modified: 2015-03-26 11:41 UTC (History)
2 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments
Full build log (10.75 KB, application/gzip)
2014-10-23 13:00 UTC, Wolfgang Denk
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Wolfgang Denk 2014-10-23 13:00:11 UTC
Created attachment 2208 [details]
Full build log

I'm trying to use the /pub/releases/yocto-1.7.rc3/toolchain/x86_64 images for PowerPC to build a plain standard mainline U-Boot (lasest realease = v2014.10).

-> . /opt/poky/1.7/environment-setup-ppc7400-poky-linux 
-> unset LDFLAGS
-> make mrproper ; make CONFIG_USE_PRIVATE_LIBGCC=y TQM5200S_defconfig ; make CONFIG_USE_PRIVATE_LIBGCC=y -j8 all
...
  LD      post/built-in.o
  LD      lib/built-in.o
  LD      u-boot
arch/powerpc/cpu/mpc5xxx/traps.o: In function `show_regs':
/home/wd/git/u-boot/work/arch/powerpc/cpu/mpc5xxx/traps.c:81: undefined reference to `_restgpr_25_x'
arch/powerpc/cpu/mpc5xxx/traps.o: In function `MachineCheckException':
/home/wd/git/u-boot/work/arch/powerpc/cpu/mpc5xxx/traps.c:134: undefined reference to `_restgpr_30_x'
arch/powerpc/cpu/mpc5xxx/built-in.o: In function `wait_for_pin':
/home/wd/git/u-boot/work/arch/powerpc/cpu/mpc5xxx/i2c.c:118: undefined reference to `_restgpr_28_x'
arch/powerpc/cpu/mpc5xxx/built-in.o: In function `wait_for_bb':
/home/wd/git/u-boot/work/arch/powerpc/cpu/mpc5xxx/i2c.c:97: undefined reference to `_restgpr_28_x'
arch/powerpc/cpu/mpc5xxx/built-in.o: In function `do_address':
/home/wd/git/u-boot/work/arch/powerpc/cpu/mpc5xxx/i2c.c:143: undefined reference to `_restgpr_31_x'
arch/powerpc/cpu/mpc5xxx/built-in.o: In function `send_bytes':
/home/wd/git/u-boot/work/arch/powerpc/cpu/mpc5xxx/i2c.c:166: undefined reference to `_restgpr_26_x'
arch/powerpc/cpu/mpc5xxx/built-in.o: In function `i2c_probe':
/home/wd/git/u-boot/work/arch/powerpc/cpu/mpc5xxx/i2c.c:343: undefined reference to `_restgpr_29_x'
arch/powerpc/cpu/mpc5xxx/built-in.o: In function `i2c_read':
/home/wd/git/u-boot/work/arch/powerpc/cpu/mpc5xxx/i2c.c:387: undefined reference to `_restgpr_25_x'
arch/powerpc/cpu/mpc5xxx/built-in.o: In function `i2c_write':
/home/wd/git/u-boot/work/arch/powerpc/cpu/mpc5xxx/i2c.c:425: undefined reference to `_restgpr_27_x'
arch/powerpc/cpu/mpc5xxx/built-in.o: In function `checkcpu':
/home/wd/git/u-boot/work/arch/powerpc/cpu/mpc5xxx/cpu.c:59: undefined reference to `_restgpr_28_x'
arch/powerpc/cpu/mpc5xxx/built-in.o: In function `ft_cpu_setup':
/home/wd/git/u-boot/work/arch/powerpc/cpu/mpc5xxx/cpu.c:137: undefined reference to `_restgpr_26_x'
arch/powerpc/cpu/mpc5xxx/built-in.o: In function `ide_preinit':
/home/wd/git/u-boot/work/arch/powerpc/cpu/mpc5xxx/ide.c:82: undefined reference to `_restgpr_31_x'
arch/powerpc/cpu/mpc5xxx/built-in.o: In function `mpc5xxx_ic_disable':
/home/wd/git/u-boot/work/arch/powerpc/cpu/mpc5xxx/interrupts.c:67: undefined reference to `_restgpr_30_x'
arch/powerpc/cpu/mpc5xxx/built-in.o: In function `mpc5xxx_ic_enable':
/home/wd/git/u-boot/work/arch/powerpc/cpu/mpc5xxx/interrupts.c:96: undefined reference to `_restgpr_30_x'
arch/powerpc/cpu/mpc5xxx/built-in.o: In function `interrupt_init_cpu':
/home/wd/git/u-boot/work/arch/powerpc/cpu/mpc5xxx/interrupts.c:221: undefined reference to `_restgpr_31_x'
arch/powerpc/cpu/mpc5xxx/built-in.o: In function `irq_free_handler':
/home/wd/git/u-boot/work/arch/powerpc/cpu/mpc5xxx/interrupts.c:293: undefined reference to `_restgpr_30_x'
...
etc.

The same problem happens both with poky-glibc-x86_64-core-image-sato-ppc7400-toolchain-1.7.sh and with poky-glibc-x86_64-core-image-sato-ppce500v2-toolchain-1.7.sh
Comment 1 Saul Wold 2014-10-23 14:59:43 UTC
There was possibly some breakage in the rc3 build, so re-verification with the rc5 toolchain would be best. Also, can you confirm if it works without "unset LDFLAGS" or do you get different breakage?
Comment 2 Wolfgang Denk 2014-10-24 10:20:26 UTC
(In reply to comment #1)
> There was possibly some breakage in the rc3 build, so re-verification with
> the rc5 toolchain would be best.

rc5 shows much less of these errors, but they are still present:

...
  LD      examples/standalone/libstubs.o
  LD      examples/standalone/hello_world
  LD      examples/standalone/interrupt
examples/standalone/hello_world.oexamples/standalone/interrupt.o: In function `: In function `interrupthello_world':
':
/home/wd/git/u-boot/work/examples/standalone/hello_world.c:38: undefined reference to `/home/wd/git/u-boot/work/examples/standalone/interrupt.c:_restgpr_27_x'
56: undefined reference to `_restgpr_30_x'
make[2]: *** [examples/standalone/hello_world] Error 1
make[2]: *** [examples/standalone/interrupt] Error 1
  LD      examples/standalone/sched
examples/standalone/sched.o: In function `sched':
/home/wd/git/u-boot/work/examples/standalone/sched.c:140: undefined reference to `_restgpr_16_x'
examples/standalone/sched.o: In function `testthread':
/home/wd/git/u-boot/work/examples/standalone/sched.c:166: undefined reference to `_restgpr_30_x'
examples/standalone/sched.o: In function `thread_yield':
/home/wd/git/u-boot/work/examples/standalone/sched.c:218: undefined reference to `_restgpr_21_x'
make[2]: *** [examples/standalone/sched] Error 1
make[2]: Target `__build' not remade because of errors.
make[1]: *** [examples/standalone] Error 2
make[1]: Target `__build' not remade because of errors.
make: *** [examples] Error 2
make: Target `all' not remade because of errors.



> Also, can you confirm if it works without
> "unset LDFLAGS" or do you get different breakage?

LDFLAGS must be unset when compiling U-Boot or the Linux kernel - both
pass this directly to the linker, which will fail with linker errors
like this:

powerpc-linux-ld.bfd: unrecognized option '-Wl,-O1'
powerpc-linux-ld.bfd: use the --help option for usage information

The Yocto setting of

	export LDFLAGS="-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed"

will only work when passed through GCC.
Comment 3 Stephen K Jolley 2014-12-01 18:47:31 UTC
An answer appears to have been given by Wolfgang.  Richard, Saul do you still NEEDINFO?
Comment 4 Richard Purdie 2015-02-12 12:22:57 UTC
I had a look at this and it appears this isn't really an issue with our toolchain but more the way u-boot is using it. See for example:

https://lists.ozlabs.org/pipermail/linuxppc-dev/2008-May/055727.html

I'm guessing u-boot would need more pieces of libgcc internally to make this work. If I remove CONFIG_USE_PRIVATE_LIBGCC=y it builds ok. I'm therefore marking this as a not a bug (in the Yocto Project). If you believe there is a problem with the toolchain, please provide more info about cases where it works and how we'd fix this.
Comment 5 Alexandru Georgescu 2015-03-26 11:41:18 UTC
(In reply to comment #4)
> I had a look at this and it appears this isn't really an issue with our
> toolchain but more the way u-boot is using it. See for example:
> 
> https://lists.ozlabs.org/pipermail/linuxppc-dev/2008-May/055727.html
> 
> I'm guessing u-boot would need more pieces of libgcc internally to make this
> work. If I remove CONFIG_USE_PRIVATE_LIBGCC=y it builds ok. I'm therefore
> marking this as a not a bug (in the Yocto Project). If you believe there is
> a problem with the toolchain, please provide more info about cases where it
> works and how we'd fix this.

Verified as per above comments.