Creating crosscompiler for x86_64 target

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
orentwaig
Posts: 3
Joined: Thu Nov 08, 2007 1:27 am

Creating crosscompiler for x86_64 target

Post by orentwaig »

Hi guys,

For the last week I've tried to create a cross compiler , target = x86_64-pc-linux-gnu , using all the scripts (kegel, crosstool-ng, etc...) and manuals on the web , NOTHING worked :cry: .

Also i've tried all the gcc-binutils-glibc combinations :
* gcc : 3.6.X to 4.2X
* glibc : 2.3 to 2.7
* binutils : 2.15 to 2.18

Each script/versions fails on different script message or compiler errors.

Here is my linux host and the gcc version :

$ uname -a
Linux 2.6.20-1.2319.fc5smp #1 SMP Mon May 21 20:11:15 EDT
2007 i686 i686 i386 GNU/Linux

$ gcc -v
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=i386-redhat-linux
Thread model: posix
gcc version 4.1.1 20070105 (Red Hat 4.1.1-51)


if you know any working crosstool script or manual that is working with these version and on fc5. that will compile toolchain that will support shared glibc with c and c++ languages it will be great help.

Also if you know/have prebuilt toolchain to download it wiil be great also.

Thanks in advance.
Oren.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Post by Solar »

1) GCC Cross-Compiler perhaps?

2) We can't possibly provide you with a complete toolchain including glibc, because glibc would likely need to be adapted to your kernel.
Every good solution is obvious once you've found it.
orentwaig
Posts: 3
Joined: Thu Nov 08, 2007 1:27 am

Post by orentwaig »

tried it. could not even compile gcc bootstrap in the first step...
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post by AJ »

Have you seen this version of the corss compiler tool?

http://www.osdev.org/wiki/GCC_Cross-Compiler_for_x86_64

You may have to edit some files manually to add the 64 bit target.

Cheers,
Adam
orentwaig
Posts: 3
Joined: Thu Nov 08, 2007 1:27 am

Post by orentwaig »

Hi,

Here is the error that kegel crosstool scripts fails.
I believe it has all the needed information...
have you seen such an error ?

(SHLIB_LINK='/cross_compiler/crosstool-0.43/build/x86_64-linux-gnu/gcc-4.1.0-glibc-2.3.6/build-gcc/./gcc/xgcc -B/cross_compiler/crosstool-0.43/build/x86_64-linux-gnu/gcc-4.1.0-glibc-2.3.6/build-gcc/./gcc/ -B/cross_compiler/CC-x86_64-gcc-4.1.0/gcc-4.1.0-glibc-2.3.6/x86_64-linux-gnu/x86_64-linux-gnu/bin/ -B/cross_compiler/CC-x86_64-gcc-4.1.0/gcc-4.1.0-glibc-2.3.6/x86_64-linux-gnu/x86_64-linux-gnu/lib/ -isystem /cross_compiler/CC-x86_64-gcc-4.1.0/gcc-4.1.0-glibc-2.3.6/x86_64-linux-gnu/x86_64-linux-gnu/include -isystem /cross_compiler/CC-x86_64-gcc-4.1.0/gcc-4.1.0-glibc-2.3.6/x86_64-linux-gnu/x86_64-linux-gnu/sys-include -O2 -O2 -g -O2 -DIN_GCC -DCROSS_COMPILE -DNATIVE_CROSS -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 -shared -nodefaultlibs -Wl,--soname=@[email protected] -Wl,--version-script=@shlib_map_file@ -o @multilib_dir@/@[email protected] @multilib_flags@ @shlib_objs@ -lc && rm -f @multilib_dir@/@[email protected] && if [ -f @multilib_dir@/@[email protected] ]; then mv -f @multilib_dir@/@[email protected] @multilib_dir@/@[email protected]; else true; fi && mv @multilib_dir@/@[email protected] @multilib_dir@/@[email protected] && ln -s @[email protected] @multilib_dir@/@[email protected]' \
SHLIB_MULTILIB=''; \
gcc -c -g -O2 -DIN_GCC -DCROSS_COMPILE -DNATIVE_CROSS -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wmissing-format-attribute -DHAVE_CONFIG_H -I. -I. -I/cross_compiler/crosstool-0.43/build/x86_64-linux-gnu/gcc-4.1.0-glibc-2.3.6/gcc-4.1.0/gcc -I/cross_compiler/crosstool-0.43/build/x86_64-linux-gnu/gcc-4.1.0-glibc-2.3.6/gcc-4.1.0/gcc/. -I/cross_compiler/crosstool-0.43/build/x86_64-linux-gnu/gcc-4.1.0-glibc-2.3.6/gcc-4.1.0/gcc/../include -I/cross_compiler/crosstool-0.43/build/x86_64-linux-gnu/gcc-4.1.0-glibc-2.3.6/gcc-4.1.0/gcc/../libcpp/include -DSTANDARD_STARTFILE_PREFIX=\"../../../\" -DSTANDARD_EXEC_PREFIX=\"/cross_compiler/CC-x86_64-gcc-4.1.0/gcc-4.1.0-glibc-2.3.6/x86_64-linux-gnu/lib/gcc/\" -DSTANDARD_LIBEXEC_PREFIX=\"/cross_compiler/CC-x86_64-gcc-4.1.0/gcc-4.1.0-glibc-2.3.6/x86_64-linux-gnu/libexec/gcc/\" -DDEFAULT_TARGET_VERSION=\"4.1.0\" -DDEFAULT_TARGET_MACHINE=\"x86_64-linux-gnu\" -DSTANDARD_BINDIR_PREFIX=\"/cross_compiler/CC-x86_64-gcc-4.1.0/gcc-4.1.0-glibc-2.3.6/x86_64-linux-gnu/bin/\" -DTOOLDIR_BASE_PREFIX=\"../../../../\" -DTARGET_SYSTEM_ROOT=\"/cross_compiler/CC-x86_64-gcc-4.1.0/gcc-4.1.0-glibc-2.3.6/x86_64-linux-gnu/x86_64-linux-gnu/sys-root\" -DTARGET_SYSTEM_ROOT_RELOCATABLE `test "X${SHLIB_LINK}" = "X" || test "yes" != "yes" || echo "-DENABLE_SHARED_LIBGCC"` `test "X${SHLIB_MULTILIB}" = "X" || echo "-DNO_SHARED_LIBGCC_MULTILIB"` \
-I. -I. -I/cross_compiler/crosstool-0.43/build/x86_64-linux-gnu/gcc-4.1.0-glibc-2.3.6/gcc-4.1.0/gcc -I/cross_compiler/crosstool-0.43/build/x86_64-linux-gnu/gcc-4.1.0-glibc-2.3.6/gcc-4.1.0/gcc/. -I/cross_compiler/crosstool-0.43/build/x86_64-linux-gnu/gcc-4.1.0-glibc-2.3.6/gcc-4.1.0/gcc/../include -I/cross_compiler/crosstool-0.43/build/x86_64-linux-gnu/gcc-4.1.0-glibc-2.3.6/gcc-4.1.0/gcc/../libcpp/include /cross_compiler/crosstool-0.43/build/x86_64-linux-gnu/gcc-4.1.0-glibc-2.3.6/gcc-4.1.0/gcc/cp/g++spec.c)
/tmp/cc4PFYeP.s: Assembler messages:
/tmp/cc4PFYeP.s:142: Error: suffix or operands invalid for `push'
/tmp/cc4PFYeP.s:146: Error: suffix or operands invalid for `push'
/tmp/cc4PFYeP.s:148: Error: suffix or operands invalid for `push'
/tmp/cc4PFYeP.s:150: Error: suffix or operands invalid for `push'
/tmp/cc4PFYeP.s:192: Error: suffix or operands invalid for `push'
/tmp/cc4PFYeP.s:193: Error: suffix or operands invalid for `push'
/tmp/cc4PFYeP.s:268: Error: suffix or operands invalid for `push'
/tmp/cc4PFYeP.s:454: Error: suffix or operands invalid for `pop'
/tmp/cc4PFYeP.s:455: Error: suffix or operands invalid for `pop'
/tmp/cc4PFYeP.s:456: Error: suffix or operands invalid for `pop'
/tmp/cc4PFYeP.s:471: Error: suffix or operands invalid for `pop'
/tmp/cc4PFYeP.s:472: Error: suffix or operands invalid for `pop'
/tmp/cc4PFYeP.s:473: Error: suffix or operands invalid for `pop'
/tmp/cc4PFYeP.s:630: Error: suffix or operands invalid for `push'
/tmp/cc4PFYeP.s:631: Error: suffix or operands invalid for `push'
/tmp/cc4PFYeP.s:632: Error: suffix or operands invalid for `push'
/tmp/cc4PFYeP.s:633: Error: suffix or operands invalid for `push'
/tmp/cc4PFYeP.s:654: Error: suffix or operands invalid for `push'
/tmp/cc4PFYeP.s:655: Error: suffix or operands invalid for `push'
/tmp/cc4PFYeP.s:785: Error: suffix or operands invalid for `push'
/tmp/cc4PFYeP.s:786: Error: suffix or operands invalid for `push'
/tmp/cc4PFYeP.s:809: Error: suffix or operands invalid for `push'
/tmp/cc4PFYeP.s:810: Error: suffix or operands invalid for `push'
/tmp/cc4PFYeP.s:989: Error: suffix or operands invalid for `push'
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

/tmp/cc4PFYeP.s:989: Error: suffix or operands invalid for `push'
These errors occur when you try to assemble 64-bit code with a 32-bit assembler. I'm not sure if it's the same the other way around but I doubt it - 64bit assemblers would be able to assemble 32bit code.

It happens when you have statements like:

Code: Select all

pop %rbx
popping a 64 bit register: the 32 bit assembler gets confused and dies. Check your assembler.
Post Reply