[U-Boot] [PATCH] Makefile: prevent libgcc to be linked twice

Nicolas Ferre
2011-10-18T08:30:27Z

On 10/17/2011 07:25 PM, Mike Frysinger :
> On Monday 17 October 2011 09:41:15 Nicolas Ferre wrote:
>> If we define USE_PRIVATE_LIBGCC, PLATFORM_LIBS is used during
>> link. During this last link editing, libgcc may be listed twice
>> and fail.
>> Prevent this using "filter-out" in top Makefile.
>
> could you please provide more details ? libgcc should not be listed twice.

I compile current u-boot with the flowing command line:
make -j5 CROSS_COMPILE=arm-linux-gnueabi- USE_PRIVATE_LIBGCC=yes at91sam9m10g45ek_nandflash

On an Ubuntu 11.10 with Linaro's cross-toolchain (targeting ARMv7). My SoC is an ARM926 so I use the "USE_PRIVATE_LIBGCC=yes" switch. This will prevent the build to take libgcc from my host but compile the u-boot embedded libgcc: everything is fine, good feature.

But, here is the final link editing stage:

UNDEF_SYM=`arm-linux-gnueabi-objdump -x board/atmel/at91sam9m10g45ek/libat91sam9m10g45ek.o api/libapi.o arch/arm/cpu/arm926ejs/at91/libat91.o arch/arm/cpu/arm926ejs/libarm926ejs.o arch/arm/lib/libarm.o common/libcommon.o disk/libdisk.o drivers/bios_emulator/libatibiosemu.o drivers/block/libblock.o drivers/dma/libdma.o drivers/fpga/libfpga.o drivers/gpio/libgpio.o drivers/hwmon/libhwmon.o drivers/i2c/libi2c.o drivers/input/libinput.o drivers/misc/libmisc.o drivers/mmc/libmmc.o drivers/mtd/libmtd.o drivers/mtd/nand/libnand.o drivers/mtd/onenand/libonenand.o drivers/mtd/spi/libspi_flash.o drivers/mtd/ubi/libubi.o drivers/net/libnet.o drivers/net/phy/libphy.o drivers/pci/libpci.o drivers/pcmcia/libpcmcia.o drivers/power/libpower.o drivers/rtc/librtc.o drivers/serial/libserial.o drivers/spi/libspi.o drivers/twserial/libtws.o drivers/usb/eth/libusb_eth.o drivers/usb/gadget/libusb_gadget.o drivers/usb/host/libusb_host.o drivers/usb/musb/libusb_musb.o drivers/usb/phy/libusb_phy.o dri
vers/video/libvideo.o drivers/watchdog/libwatchdog.o fs/cramfs/libcramfs.o fs/ext2/libext2fs.o fs/fat/libfat.o fs/fdos/libfdos.o fs/jffs2/libjffs2.o fs/reiserfs/libreiserfs.o fs/ubifs/libubifs.o fs/yaffs2/libyaffs2.o lib/libfdt/libfdt.o lib/libgeneric.o lib/lzma/liblzma.o lib/lzo/liblzo.o lib/zlib/libz.o net/libnet.o post/libpost.o | sed -n -e 's/.*\(__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`; cd /home/nferre/workspace/u-boot/u-boot-git && arm-linux-gnueabi-ld -pie -T u-boot.lds -Bstatic -Ttext 0x73f00000 $UNDEF_SYM arch/arm/cpu/arm926ejs/start.o --start-group api/libapi.o arch/arm/cpu/arm926ejs/at91/libat91.o arch/arm/cpu/arm926ejs/libarm926ejs.o arch/arm/lib/libarm.o common/libcommon.o disk/libdisk.o drivers/bios_emulator/libatibiosemu.o drivers/block/libblock.o drivers/dma/libdma.o drivers/fpga/libfpga.o drivers/gpio/libgpio.o drivers/hwmon/libhwmon.o drivers/i2c/libi2c.o drivers/input/libinput.o drivers/misc/libmisc.o drivers/mmc/libmmc.o drivers/mtd/libmtd.o drivers/mtd/nand
/libnand.o drivers/mtd/onenand/libonenand.o drivers/mtd/spi/libspi_flash.o drivers/mtd/ubi/libubi.o drivers/net/libnet.o drivers/net/phy/libphy.o drivers/pci/libpci.o drivers/pcmcia/libpcmcia.o drivers/power/libpower.o drivers/rtc/librtc.o drivers/serial/libserial.o drivers/spi/libspi.o drivers/twserial/libtws.o drivers/usb/eth/libusb_eth.o drivers/usb/gadget/libusb_gadget.o drivers/usb/host/libusb_host.o drivers/usb/musb/libusb_musb.o drivers/usb/phy/libusb_phy.o drivers/video/libvideo.o drivers/watchdog/libwatchdog.o fs/cramfs/libcramfs.o fs/ext2/libext2fs.o fs/fat/libfat.o fs/fdos/libfdos.o fs/jffs2/libjffs2.o fs/reiserfs/libreiserfs.o fs/ubifs/libubifs.o fs/yaffs2/libyaffs2.o lib/libfdt/libfdt.o lib/libgeneric.o lib/lzma/liblzma.o lib/lzo/liblzo.o lib/zlib/libz.o net/libnet.o post/libpost.o board/atmel/at91sam9m10g45ek/libat91sam9m10g45ek.o --end-group /home/nferre/workspace/u-boot/u-boot-git/arch/arm/lib/eabi_compat.o /home/nferre/workspace/u-boot/u-boot-git/arch/arm/lib
/libgcc.o /home/nferre/workspace/u-boot/u-boot-git/arch/arm/lib/libgcc.o -Map u-boot.map -o u-boot

And you see that there is arch/arm/lib/libgcc.o included twice in object files that have to be linked together. I think that it is coming from the PLATFORM_LIBS variable so I modified like in my patch which solves the problem.

Best regards,
--
Nicolas Ferre