llvm / llvm-project

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

Cross-compile llvm-gcc Linux x86 to arm-linux #3874

Closed llvmbot closed 15 years ago

llvmbot commented 15 years ago
Bugzilla Link 3502
Resolution FIXED
Resolved on Apr 17, 2009 11:20
Version trunk
OS Linux
Attachments Revert some of 54175 to help ARM cross-compiler build, Preprocessed source that the "xgcc" executable chokes on.
Reporter LLVM Bugzilla Contributor
CC @asl

Extended Description

Hi all,

I'm quite new to this, so hopefully this is a real bug and not my fault :)

I'm trying to compile cross-compile llvm-gcc trunk for arm-linux from my Kubuntu 8.04 x86 Linux install, and have run into many build errors, including what appears to be an internal compiler error.

Firstly, the commit:

http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/arm/arm.h?r1=54175&r2=54174&pathrev=54175

seems to have removed some stuff necessary for arm.c and arm.md to compile on a non-Darwin host - in particular, the definitions of MACHO_DYNAMIC_NO_PIC_P, ENCODED_SHORT_CALL_ATTR_P and ENCODED_LONG_CALL_ATTR_P. Reverting some of these changes allows us to proceed (see attached patch).

After that, I ./configure llvm-gcc trunk from an obj/ subdir as follows (the full path to this obj/ dir is /home/kde4daily/tmp/funkytown-sdl/llvm-arm/src/llvm-gcc/obj/./gcc/xgcc) :

./configure --prefix=/home/kde4daily/tmp/funkytown-sdl/llvm-arm/install --enable-languages=c,c++ --enable-checking --disable-bootstrap --disable-multilib --target=arm-linux --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu --with-build-sysroot=/home/kde4daily/tmp/funkytown-sdl/llvm-arm/install/ --with-llvm=$LLVMOBJDIR

(the same configuration, passed to stock gcc 4.2, leads to a successful cross compilation, so I think this is llvm-gcc-specific).

Running make eventually descends into /home/kde4daily/tmp/funkytown-sdl/llvm-arm/src/llvm-gcc/obj/gcc/ and tries to run the "xgcc" executable that has been created on crtstuff.c and an internal compiler error is generated. After getting the preprocessed stuff and ditching all the -I and -D flags, I've reduced the call to the relatively self-contained:

/home/kde4daily/tmp/funkytown-sdl/llvm-arm/src/llvm-gcc/obj/./gcc/xgcc -B/home/kde4daily/tmp/funkytown-sdl/llvm-arm/src/llvm-gcc/obj/./gcc/ -g -O2 -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -g0 -finhibit-size-directive -fno-inline-functions -fno-exceptions -fno-zero-initialized-in-bss -fno-toplevel-reorder -fPIC -c crtstuff-preprocessed.c -o crtbeginS.o

(crtstuff-preprocessed.c is attached) and the following error is produced:

../../gcc/crtstuff.c: In function ‘__do_global_dtors_aux’: ../../gcc/crtstuff.c:334: internal compiler error: in mark_jump_label, at jump.c:1144 Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://developer.apple.com/bugreporter> for instructions.

The corresponding call, adapted for cross-compilation of the stock gcc 4.2, works without incident.

If you need any more info, please let me know :)

llvmbot commented 15 years ago

Yes. Thanks.

llvmbot commented 15 years ago

So it's fixed, right?

llvmbot commented 15 years ago

Looks like fix for pr3954 has fixed this problem as well.

llvmbot commented 15 years ago

crtbegin.bc

llvmbot commented 15 years ago

This bug comes to life again during compilation of llvm-gcc-4.2! Sorry.

svn version : 67763

/build/x86_64-arm/llvm-gcc-4.2/./gcc/xgcc -B/build/x86_64-arm/llvm-gcc-4.2/./gcc/ -B/install/x86_64-arm/llvm-gcc-4.2/arm-none-linux-gnueabi/bin/ -B/install/x86_64-arm/llvm-gcc-4.2/arm-none-linux-gnueabi/lib/ -isystem /install/x86_64-arm/llvm-gcc-4.2/arm-none-linux-gnueabi/include -isystem /install/x86_64-arm/llvm-gcc-4.2/arm-none-linux-gnueabi/sys-include -O2 -O2 -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem ./include -I. -I. -I../../../../src/llvm-gcc-4.2/gcc -I../../../../src/llvm-gcc-4.2/gcc/. -I../../../../src/llvm-gcc-4.2/gcc/../include -I../../../../src/llvm-gcc-4.2/gcc/../libcpp/include -I../../../../src/llvm-gcc-4.2/gcc/../libdecnumber -I../libdecnumber -I/install/x86_64-arm/llvm/include -I/src/llvm/include -g0 -finhibit-size-directive -fno-inline-functions -fno-exceptions -fno-zero-initialized-in-bss -fno-toplevel-reorder -c ../../../../src/llvm-gcc-4.2/gcc/crtstuff.c -DCRT_BEGIN -o crtbegin.o cc1: /src/llvm/lib/CodeGen/RegisterScavenging.cpp:273: void llvm::RegScavenger::forward(): Assertion `(isReserved(Reg) || isUnused(Reg) || IsImpDef || isImplicitlyDefined(Reg) || isLiveInButUnusedBefore(Reg, MI, MBB, TRI, MRI)) && "Re-defining a live register!"' failed. ../../../../src/llvm-gcc-4.2/gcc/crtstuff.c:382: internal compiler error: Aborted I'm attaching the bitcode - called crtbegin.bc.
llvmbot commented 15 years ago

Fixed. http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20090216/074104.html

llvmbot commented 15 years ago

I encountered the assertion failure while compiling my project using llvm based x86_64->ARM cross compiler. I attached is a simplified versions of .bc and .ll.

Thanks.

llvmbot commented 15 years ago

bugpoint-simple.bc

llvmbot commented 15 years ago

bugpoint-simplified.ll code

llvmbot commented 15 years ago

Both test cases should have been fixed by r64745. Please check.

llvmbot commented 15 years ago

bit code of libgcc2.c I also get the following assertion failure during my attempt to build an x86_64->ARM cross compiler.

/./gcc/xgcc -B/./gcc/ -B/arm-none-linux-gnueabi/bin/ -B/arm-none-linux-gnueabi/lib/ -isystem /arm-none-linux-gnueabi/include -isystem /arm-none-linux-gnueabi/sys-include -O2 -O2 -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem ./include -fPIC -g -DHAVE_GTHR_DEFAULT -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED -I. -I. -I/gcc -I/gcc/. -I/gcc/../include -I/gcc/../libcpp/include -I/gcc/../libdecnumber -I../libdecnumber -I/llvm/include -I/llvm/lib/CodeGen/RegisterScavenging.cpp:273: void llvm::RegScavenger::forward(): Assertion `(isReserved(Reg) || isUnused(Reg) || IsImpDef || isImplicitlyDefined(Reg) || isLiveInButUnusedBefore(Reg, MI, MBB, TRI, MRI)) && "Re-defining a live register!"' failed. ../../../../src/llvm-gcc-4.2/gcc/libgcc2.c:1914: internal compiler error: Aborted Please submit a full bug report, with preprocessed source if appropriate. See for instructions. Here is some relevant info: LLVM and llvm-gcc-4.2 source rev 64487 $ svn info Path: . URL: http://llvm.org/svn/llvm-project/llvm/trunk Repository Root: http://llvm.org/svn/llvm-project Repository UUID: 91177308-0d34-0410-b5e6-96231b3b80d8 Revision: 64487 Node Kind: directory Schedule: normal Last Changed Author: djg Last Changed Rev: 64468 Last Changed Date: 2009-02-13 12:45:12 -0500 (Fri, 13 Feb 2009) $ svn info Path: . URL: http://llvm.org/svn/llvm-project/llvm-gcc-4.2/trunk Repository Root: http://llvm.org/svn/llvm-project Repository UUID: 91177308-0d34-0410-b5e6-96231b3b80d8 Revision: 64487 Node Kind: directory Schedule: normal Last Changed Author: baldrick Last Changed Rev: 64234 Last Changed Date: 2009-02-10 15:43:26 -0500 (Tue, 10 Feb 2009) LLVM configured and successfully built as : /configure --with-llvmgccdir=/llvm-gcc-4.2 --enable-optimized --enable-jit --prefix=/configure --prefix=/llvm --disable-multilib --target=arm-none-linux-gnueabi --with-sysroot= --enable-languages=c,c++ Attached the result of passing -emit-llvm to the above failing command.
llvmbot commented 15 years ago

bitcode of regex.c Hi Evan,

Hopefully this is right :)

llvmbot commented 15 years ago

Can you attach a bitcode file? Just re-run xgcc ... -c with -emit-llvm. Thanks.

llvmbot commented 15 years ago

Pre-processed file that causes the internal error.

llvmbot commented 15 years ago

Reduced testcase; regex.i will be attached.

/home/kde4daily/tmp/funkytown-sdl/llvm-arm/src/llvm-gcc/obj/./gcc/xgcc -B/home/kde4daily/tmp/funkytown-sdl/llvm-arm/src/llvm-gcc/obj/./gcc/ -B/home/kde4daily/tmp/funkytown-sdl/llvm-arm/install/arm-linux/bin/ -B/home/kde4daily/tmp/funkytown-sdl/llvm-arm/install/arm-linux/lib/ -c -O2 -g -O2 -W -Wall -pedantic -Wwrite-strings -Wstrict-prototypes -Wc++-compat regex.i -o regex.o

llvmbot commented 15 years ago

Thanks Chris - I feel silly now (s/--with-llvm/--enable-llvm/) :)

That got me much further, and I ran into http://llvm.org/bugs/show_bug.cgi?id=896, so I had to add --disable-shared to the flags.

With the new flags:

../configure --prefix=/home/kde4daily/tmp/funkytown-sdl/llvm-arm/install --enable-languages=c,c++ --enable-checking --disable-bootstrap --disable-multilib --disable-shared --target=arm-linux --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu --with-build-sysroot=/home/kde4daily/tmp/funkytown-sdl/llvm-arm/install/ --enable-llvm=$LLVMOBJDIR

I eventually run into:

Checking multilib configuration for libstdc++-v3... Checking multilib configuration for libiberty... make[2]: Entering directory /home/kde4daily/tmp/funkytown-sdl/llvm-arm/src/llvm-gcc/obj/arm-linux/libiberty' if [ x"" != x ]; then \ /home/kde4daily/tmp/funkytown-sdl/llvm-arm/src/llvm-gcc/obj/./gcc/xgcc -B/home/kde4daily/tmp/funkytown-sdl/llvm-arm/src/llvm-gcc/obj/./gcc/ -B/home/kde4daily/tmp/funkytown-sdl/llvm-arm/install/arm-linux/bin/ -B/home/kde4daily/tmp/funkytown-sdl/llvm-arm/install/arm-linux/lib/ -isystem /home/kde4daily/tmp/funkytown-sdl/llvm-arm/install/arm-linux/include -isystem /home/kde4daily/tmp/funkytown-sdl/llvm-arm/install/arm-linux/sys-include -c -DHAVE_CONFIG_H -O2 -g -O2 --sysroot=/home/kde4daily/tmp/funkytown-sdl/llvm-arm/install/ -I. -I../../../libiberty/../include -W -Wall -pedantic -Wwrite-strings -Wstrict-prototypes -Wc++-compat ../../../libiberty/regex.c -o pic/regex.o; \ else true; fi /home/kde4daily/tmp/funkytown-sdl/llvm-arm/src/llvm-gcc/obj/./gcc/xgcc -B/home/kde4daily/tmp/funkytown-sdl/llvm-arm/src/llvm-gcc/obj/./gcc/ -B/home/kde4daily/tmp/funkytown-sdl/llvm-arm/install/arm-linux/bin/ -B/home/kde4daily/tmp/funkytown-sdl/llvm-arm/install/arm-linux/lib/ -isystem /home/kde4daily/tmp/funkytown-sdl/llvm-arm/install/arm-linux/include -isystem /home/kde4daily/tmp/funkytown-sdl/llvm-arm/install/arm-linux/sys-include -c -DHAVE_CONFIG_H -O2 -g -O2 --sysroot=/home/kde4daily/tmp/funkytown-sdl/llvm-arm/install/ -I. -I../../../libiberty/../include -W -Wall -pedantic -Wwrite-strings -Wstrict-prototypes -Wc++-compat ../../../libiberty/regex.c -o regex.o cc1: /home/kde4daily/tmp/funkytown-sdl/llvm-arm/src/llvm/lib/CodeGen/RegisterScavenging.cpp:273: void llvm::RegScavenger::forward(): Assertion(isReserved(Reg) || isUnused(Reg) || IsImpDef || isImplicitlyDefined(Reg) || isLiveInButUnusedBefore(Reg, MI, MBB, TRI, MRI)) && "Re-defining a live register!"' failed. ../../../libiberty/regex.c:8126: internal compiler error: Aborted Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://developer.apple.com/bugreporter> for instructions. make[2]: *** [regex.o] Error 1

Should I file a separate report for this, and what information would be most useful to you guys?

lattner commented 15 years ago

If you are crashing in jump.c, then you have a non-llvm gcc. Make sure to pass --enable-llvm properly.

-Chris

llvmbot commented 15 years ago

This might be a piece of the puzzle: it seems to be the only significant difference between stock gcc 4.2's jump.c and llvm-gcc's:

http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/jump.c?r1=43927&r2=43926&pathrev=43927