Author |
Message |
snayak
Joined: 14 Sep 2011 Posts: 422
|
Posted: Mon 04 Nov 2013, 12:06 Post subject:
How to make gcc cross compiler (for i386) on 64 bit puppy? Subject description: How to compile gcc source to make a cross compiler which can produce i386 executable, on Fatdog 611. |
|
Dear All,
When I got my 64bit laptop, running Fatdog 611, I am missing my 32bit application development.
What is the procedure to compile gcc source to create a cross compiler which can produce i386 executable, on Fatdog 611?
Please suggest.
Sincerely,
Srinivas Nayak
_________________ [Precise 571 on AMD Athlon XP 2000+ with 512MB RAM]
[Fatdog 720 on Intel Pentium B960 with 4GB RAM]
http://srinivas-nayak.blogspot.com/
|
Back to top
|
|
 |
snayak
Joined: 14 Sep 2011 Posts: 422
|
Posted: Tue 05 Nov 2013, 05:44 Post subject:
|
|
I did this.
Code: | wget ftp://ftp.gnu.org/gnu/binutils/binutils-2.23.tar.gz
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-4.3.2.tar.bz2
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-2.4.2.tar.bz2
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-0.8.1.tar.gz
wget ftp://ftp.gnu.org/gnu/gcc/gcc-4.6.2/gcc-core-4.6.2.tar.bz2
tar xvzf binutils-2.23.tar.gz
bunzip2 gmp-4.3.2.tar.bz2
tar xvf gmp-4.3.2.tar
bunzip2 mpfr-2.4.2.tar.bz2
tar xvf mpfr-2.4.2.tar
tar zxvf mpc-0.8.1.tar.gz
bunzip2 gcc-core-4.6.2.tar.bz2
tar xvf gcc-core-4.6.2.tar
mkdir src
mv gmp-4.3.2 mpc-0.8.1 mpfr-2.4.2 binutils-2.23 gcc-4.6.2 src
mkdir -p opt/cross
export PREFIX="$HOME/opt/cross"
export TARGET=i586-elf
export PATH="$PREFIX/bin:$PATH"
cd $HOME/src
mkdir build-binutils
cd build-binutils
../binutils-2.23/configure --target=$TARGET --prefix="$PREFIX" --disable-nls
make
make install
mv gmp-4.3.2 gcc-4.6.2/gmp
mv mpc-0.8.1 gcc-4.6.2/mpc
mv mpfr-2.4.2 gcc-4.6.2/mpfr
mkdir build-gcc
cd build-gcc
../gcc-4.6.2/configure --target=$TARGET --prefix="$PREFIX" --disable-nls --enable-languages=c --without-headers
make all-gcc
make all-target-libgcc
make install-gcc
make install-target-libgcc
$HOME/opt/cross/bin/$TARGET-gcc --version
#to add cross compiler location to system path
#export PATH="$HOME/opt/cross/bin:$PATH"
|
Got a working compiler...
Sincerely,
Srinivas Nayak
_________________ [Precise 571 on AMD Athlon XP 2000+ with 512MB RAM]
[Fatdog 720 on Intel Pentium B960 with 4GB RAM]
http://srinivas-nayak.blogspot.com/
Last edited by snayak on Wed 06 Nov 2013, 03:47; edited 1 time in total
|
Back to top
|
|
 |
Ibidem
Joined: 25 May 2010 Posts: 553 Location: State of Jefferson
|
Posted: Wed 06 Nov 2013, 03:25 Post subject:
|
|
You also need a libc. Not sure how to go about that if you aren't going to use musl (musl-libc.org).
|
Back to top
|
|
 |
snayak
Joined: 14 Sep 2011 Posts: 422
|
Posted: Wed 06 Nov 2013, 03:48 Post subject:
|
|
Yes Ibidem, I need a library.
For the time being compiler is only ready.
_________________ [Precise 571 on AMD Athlon XP 2000+ with 512MB RAM]
[Fatdog 720 on Intel Pentium B960 with 4GB RAM]
http://srinivas-nayak.blogspot.com/
|
Back to top
|
|
 |
amigo
Joined: 02 Apr 2007 Posts: 2647
|
Posted: Wed 06 Nov 2013, 05:42 Post subject:
|
|
So, now use your new linker and compiler to compile glibc -it should be the same version as that used on the target system, and it should use the same patches (if any) and configuration options as the target systems' glibc. Be sure to use your separate prefix as for binutils and gcc.
Then when compiling apps for the target, you need to export LD_LIBRARY_PATH to the toolchain so that linking is done against the 32-bit libs above. If the app you want to compile rewuires other lobs besides glibc, then you'll need to compile and (subdir) install them before building.
Lot's of luck -cross-compiling can be a nightmare -even when things go well...
|
Back to top
|
|
 |
snayak
Joined: 14 Sep 2011 Posts: 422
|
Posted: Thu 07 Nov 2013, 01:10 Post subject:
|
|
By the way, with my default 64bit gcc, is it possible to use -m32 option to create a i386 executable?
I got
Code: | ~# gcc -march=i386 a.c
a.c:1:0: error: CPU you selected does not support x86-64 instruction set
a.c:1:0: error: CPU you selected does not support x86-64 instruction set
~#
|
Code: | ~# gcc -m32 a.c
/usr/lib64/gcc/x86_64-t2-linux-gnu/4.6.2/../../../../lib/crt1.o: could not read symbols: File in wrong format
collect2: ld returned 1 exit status
~# |
Any hope?
Sincerely,
Srinivas Nayak
_________________ [Precise 571 on AMD Athlon XP 2000+ with 512MB RAM]
[Fatdog 720 on Intel Pentium B960 with 4GB RAM]
http://srinivas-nayak.blogspot.com/
|
Back to top
|
|
 |
amigo
Joined: 02 Apr 2007 Posts: 2647
|
Posted: Thu 07 Nov 2013, 02:30 Post subject:
|
|
For -m32 to work, you need to build a multi-target, multi-lib compiler.
|
Back to top
|
|
 |
jamesbond
Joined: 26 Feb 2007 Posts: 3475 Location: The Blue Marble
|
Posted: Thu 07 Nov 2013, 09:31 Post subject:
Re: How to make gcc cross compiler (for i386) on 64 bit puppy? Subject description: How to compile gcc source to make a cross compiler which can produce i386 executable, on Fatdog 611. |
|
snayak wrote: | What is the procedure to compile gcc source to create a cross compiler which can produce i386 executable, on Fatdog 611? |
http://crosstool-ng.org/
Or if you are too lazy http://www.landley.net/aboriginal/downloads/binaries/cross-compiler-i686.tar.bz2.
And beware of what amigo said, this is so true:
[quote=amigo]Lot's of luck -cross-compiling can be a nightmare -even when things go well...[/quote]
_________________ Fatdog64 forum links: Latest version | Contributed packages | ISO builder
|
Back to top
|
|
 |
|