llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
26.83k stars 11.01k forks source link

Option --rtlib=compiler-rt on Linux fails to work when cross compiling #20206

Open llvmbot opened 10 years ago

llvmbot commented 10 years ago
Bugzilla Link 19832
Version trunk
OS Linux
Reporter LLVM Bugzilla Contributor
CC @orivej,@rengolin

Extended Description

OK so this one is a bit of a pain to explain. Basically invoking the clang driver with both -target and --rtlib=compiler-rt does not work out because --rtlib=compiler-rt is erroneously passed on to GCC or LD depending how you pay about. Rather Clang should consume --rtlib=compiler-rt and call i386-elf-ld directly with the path to the right libclang_rt. The current sementics are questionable at best.

clang -v -target i386---elf -ccc-gcc-name i386-elf-gcc -m32 --rtlib=compiler-rt -Os -pipe -g -nostdinc -nostdlib -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings -Wredundant-decls -Wno-trigraphs -Wstrict-aliasing -Wshadow -Werror -fno-common -ffreestanding -fno-builtin -fomit-frame-pointer -no-integrated-as -Qunused-arguments -mno-mmx -march=k8-sse3 -mtune=k8-sse3 -fno-zero-initialized-in-bss -fno-strict-aliasing -nostdlib -nostartfiles -static -o build/cbfs/fallback/romstage_null.debug -Lbuild -Wl,--start-group build/generated/crt0.romstage.o build/mainboard/jetway/nf81-t56n-lf/static.romstage.o build/arch/x86/boot/cbmem.romstage.o build/arch/x86/lib/cbfs_and_run.romstage.o build/arch/x86/lib/memcpy.romstage.o build/arch/x86/lib/memmove.romstage.o build/arch/x86/lib/memset.romstage.o build/arch/x86/lib/rom_media.romstage.o build/console/console.romstage.o build/console/die.romstage.o build/console/init.romstage.o build/console/post.romstage.o build/console/printk.romstage.o build/console/vtxprintf.romstage.o build/cpu/amd/agesa/s3_resume.romstage.o build/cpu/x86/car.romstage.o build/cpu/x86/lapic/apic_timer.romstage.o build/cpu/x86/lapic/boot_cpu.romstage.o build/device/device_romstage.romstage.o build/device/pci_early.romstage.o build/drivers/uart/uart8250io.romstage.o build/drivers/uart/util.romstage.o build/lib/bootmode.romstage.o build/lib/cbfs.romstage.o build/lib/cbmem.romstage.o build/lib/clog2.romstage.o build/lib/compute_ip_checksum.romstage.o build/lib/hexdump.romstage.o build/lib/loaders/cbfs_ramstage_loader.romstage.o build/lib/loaders/load_and_run_ramstage.romstage.o build/lib/lzma.romstage.o build/lib/memchr.romstage.o build/lib/memcmp.romstage.o build/lib/ramtest.romstage.o build/mainboard/jetway/nf81-t56n-lf/BiosCallOuts.romstage.o build/mainboard/jetway/nf81-t56n-lf/PlatformGnbPcie.romstage.o build/mainboard/jetway/nf81-t56n-lf/agesawrapper.romstage.o build/mainboard/jetway/nf81-t56n-lf/buildOpts.romstage.o build/northbridge/amd/agesa/family14/dimmSpd.romstage.o build/northbridge/amd/agesa/family14/fam14_callouts.romstage.o build/southbridge/amd/cimx/cimx_util.romstage.o build/southbridge/amd/cimx/sb800/cfg.romstage.o build/southbridge/amd/cimx/sb800/early.romstage.o build/southbridge/amd/cimx/sb800/reset.romstage.o build/southbridge/amd/cimx/sb800/smbus.romstage.o build/superio/fintek/common/early_serial.romstage.o build/vendorcode/amd/cimx/sb800/ACPILIB.romstage.o build/vendorcode/amd/cimx/sb800/AMDLIB.romstage.o build/vendorcode/amd/cimx/sb800/AMDSBLIB.romstage.o build/vendorcode/amd/cimx/sb800/AZALIA.romstage.o build/vendorcode/amd/cimx/sb800/DISPATCHER.romstage.o build/vendorcode/amd/cimx/sb800/EC.romstage.o build/vendorcode/amd/cimx/sb800/ECLIB.romstage.o build/vendorcode/amd/cimx/sb800/ECfanLIB.romstage.o build/vendorcode/amd/cimx/sb800/ECfanc.romstage.o build/vendorcode/amd/cimx/sb800/GEC.romstage.o build/vendorcode/amd/cimx/sb800/Gpp.romstage.o build/vendorcode/amd/cimx/sb800/IOLIB.romstage.o build/vendorcode/amd/cimx/sb800/MEMLIB.romstage.o build/vendorcode/amd/cimx/sb800/PCILIB.romstage.o build/vendorcode/amd/cimx/sb800/PMIO2LIB.romstage.o build/vendorcode/amd/cimx/sb800/PMIOLIB.romstage.o build/vendorcode/amd/cimx/sb800/SATA.romstage.o build/vendorcode/amd/cimx/sb800/SBCMN.romstage.o build/vendorcode/amd/cimx/sb800/SBMAIN.romstage.o build/vendorcode/amd/cimx/sb800/SBPELIB.romstage.o build/vendorcode/amd/cimx/sb800/SBPOR.romstage.o build/vendorcode/amd/cimx/sb800/SMM.romstage.o build/vendorcode/amd/cimx/sb800/USB.romstage.o build/libagesa.fam14.a -Wl,--end-group -T build/generated/romstage_null.ld clang version 3.5.0 (209343) Target: i386---elf Thread model: posix "/home/edward/Work/MySelf/Company/coreboot/util/crossgcc/xgcc/bin/i386-elf-gcc" -v --rtlib=compiler-rt -Os -pipe -g -nostdinc -nostdlib -fno-common -ffreestanding -fno-builtin -fomit-frame-pointer -mno-mmx -march=k8-sse3 -mtune=k8-sse3 -fno-zero-initialized-in-bss -nostdlib -nostartfiles -static -Lbuild -T build/generated/romstage_null.ld -m32 -o build/cbfs/fallback/romstage_null.debug -Wl,--start-group build/generated/crt0.romstage.o build/mainboard/jetway/nf81-t56n-lf/static.romstage.o build/arch/x86/boot/cbmem.romstage.o build/arch/x86/lib/cbfs_and_run.romstage.o build/arch/x86/lib/memcpy.romstage.o build/arch/x86/lib/memmove.romstage.o build/arch/x86/lib/memset.romstage.o build/arch/x86/lib/rom_media.romstage.o build/console/console.romstage.o build/console/die.romstage.o build/console/init.romstage.o build/console/post.romstage.o build/console/printk.romstage.o build/console/vtxprintf.romstage.o build/cpu/amd/agesa/s3_resume.romstage.o build/cpu/x86/car.romstage.o build/cpu/x86/lapic/apic_timer.romstage.o build/cpu/x86/lapic/boot_cpu.romstage.o build/device/device_romstage.romstage.o build/device/pci_early.romstage.o build/drivers/uart/uart8250io.romstage.o build/drivers/uart/util.romstage.o build/lib/bootmode.romstage.o build/lib/cbfs.romstage.o build/lib/cbmem.romstage.o build/lib/clog2.romstage.o build/lib/compute_ip_checksum.romstage.o build/lib/hexdump.romstage.o build/lib/loaders/cbfs_ramstage_loader.romstage.o build/lib/loaders/load_and_run_ramstage.romstage.o build/lib/lzma.romstage.o build/lib/memchr.romstage.o build/lib/memcmp.romstage.o build/lib/ramtest.romstage.o build/mainboard/jetway/nf81-t56n-lf/BiosCallOuts.romstage.o build/mainboard/jetway/nf81-t56n-lf/PlatformGnbPcie.romstage.o build/mainboard/jetway/nf81-t56n-lf/agesawrapper.romstage.o build/mainboard/jetway/nf81-t56n-lf/buildOpts.romstage.o build/northbridge/amd/agesa/family14/dimmSpd.romstage.o build/northbridge/amd/agesa/family14/fam14_callouts.romstage.o build/southbridge/amd/cimx/cimx_util.romstage.o build/southbridge/amd/cimx/sb800/cfg.romstage.o build/southbridge/amd/cimx/sb800/early.romstage.o build/southbridge/amd/cimx/sb800/reset.romstage.o build/southbridge/amd/cimx/sb800/smbus.romstage.o build/superio/fintek/common/early_serial.romstage.o build/vendorcode/amd/cimx/sb800/ACPILIB.romstage.o build/vendorcode/amd/cimx/sb800/AMDLIB.romstage.o build/vendorcode/amd/cimx/sb800/AMDSBLIB.romstage.o build/vendorcode/amd/cimx/sb800/AZALIA.romstage.o build/vendorcode/amd/cimx/sb800/DISPATCHER.romstage.o build/vendorcode/amd/cimx/sb800/EC.romstage.o build/vendorcode/amd/cimx/sb800/ECLIB.romstage.o build/vendorcode/amd/cimx/sb800/ECfanLIB.romstage.o build/vendorcode/amd/cimx/sb800/ECfanc.romstage.o build/vendorcode/amd/cimx/sb800/GEC.romstage.o build/vendorcode/amd/cimx/sb800/Gpp.romstage.o build/vendorcode/amd/cimx/sb800/IOLIB.romstage.o build/vendorcode/amd/cimx/sb800/MEMLIB.romstage.o build/vendorcode/amd/cimx/sb800/PCILIB.romstage.o build/vendorcode/amd/cimx/sb800/PMIO2LIB.romstage.o build/vendorcode/amd/cimx/sb800/PMIOLIB.romstage.o build/vendorcode/amd/cimx/sb800/SATA.romstage.o build/vendorcode/amd/cimx/sb800/SBCMN.romstage.o build/vendorcode/amd/cimx/sb800/SBMAIN.romstage.o build/vendorcode/amd/cimx/sb800/SBPELIB.romstage.o build/vendorcode/amd/cimx/sb800/SBPOR.romstage.o build/vendorcode/amd/cimx/sb800/SMM.romstage.o build/vendorcode/amd/cimx/sb800/USB.romstage.o build/libagesa.fam14.a -Wl,--end-group i386-elf-gcc: error: unrecognized command line option '--rtlib=compiler-rt' Using built-in specs. COLLECT_GCC=/home/edward/Work/MySelf/Company/coreboot/util/crossgcc/xgcc/bin/i386-elf-gcc COLLECT_LTO_WRAPPER=/home/edward/Work/MySelf/Company/coreboot/util/crossgcc/xgcc/lib/gcc/i386-elf/4.7.3/lto-wrapper Target: i386-elf Configured with: ../gcc-4.7.3/configure --prefix=/home/edward/Work/MySelf/Company/coreboot/util/crossgcc/xgcc --libexecdir=/home/edward/Work/MySelf/Company/coreboot/util/crossgcc/xgcc/lib --target=i386-elf --disable-werror --disable-shared --disable-libssp --disable-bootstrap --disable-nls --disable-libquadmath --without-headers --enable-lto --enable-languages=c --with-gmp=/home/edward/Work/MySelf/Company/coreboot/util/crossgcc/xgcc --with-mpfr=/home/edward/Work/MySelf/Company/coreboot/util/crossgcc/xgcc --with-mpc=/home/edward/Work/MySelf/Company/coreboot/util/crossgcc/xgcc --with-libelf=/home/edward/Work/MySelf/Company/coreboot/util/crossgcc/xgcc --with-pkgversion='coreboot toolchain v1.24 February 10th, 2014' Thread model: single gcc version 4.7.3 (coreboot toolchain v1.24 February 10th, 2014) clang-3.5: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)

Cheers, Edward.

rengolin commented 9 years ago

Sorry for being late on this, I completely agree the semantics and implementation are very badly designed (partially my fault). Now that we have both compiler-rt and libc++ buildbots, we can make more substantial changes without the fear to be breaking something.

I'll probably have to fix some of that (at least natively) to make the libc++abi tests pass without libgcc_s (since it only needs hardware emulation like div and ld2).

http://lab.llvm.org:8011/builders/libcxx-libcxxabi-arm-linux/builds/11/steps/test.libcxxabi/logs/stdio

Once that's working we can discuss your problems, because I really didn't understand much of your problem... :)

llvmbot commented 10 years ago

assigned to @rengolin