Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sat 01 Nov 2014, 10:07
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
How to make gcc cross compiler (for i386) on 64 bit puppy?
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [8 Posts]  
Author Message
snayak

Joined: 14 Sep 2011
Posts: 231

PostPosted: 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

_________________
Machine: Wary 530, AMD Athlon 2000+, ASUS A7N266-VM board, 512MB DDR RAM, 40GB HDD, 52xCDRW, PS/2 Mouse/Keyboard, USB 2.0.
Home: http://www.mathmeth.com/sn/
Blog: http://srinivas-nayak.blogspot.com/
Back to top
View user's profile Send private message 
snayak

Joined: 14 Sep 2011
Posts: 231

PostPosted: 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

_________________
Machine: Wary 530, AMD Athlon 2000+, ASUS A7N266-VM board, 512MB DDR RAM, 40GB HDD, 52xCDRW, PS/2 Mouse/Keyboard, USB 2.0.
Home: http://www.mathmeth.com/sn/
Blog: http://srinivas-nayak.blogspot.com/

Last edited by snayak on Wed 06 Nov 2013, 03:47; edited 1 time in total
Back to top
View user's profile Send private message 
Ibidem

Joined: 25 May 2010
Posts: 502
Location: State of Jefferson

PostPosted: 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
View user's profile Send private message 
snayak

Joined: 14 Sep 2011
Posts: 231

PostPosted: Wed 06 Nov 2013, 03:48    Post subject:  

Yes Ibidem, I need a library.
For the time being compiler is only ready.

_________________
Machine: Wary 530, AMD Athlon 2000+, ASUS A7N266-VM board, 512MB DDR RAM, 40GB HDD, 52xCDRW, PS/2 Mouse/Keyboard, USB 2.0.
Home: http://www.mathmeth.com/sn/
Blog: http://srinivas-nayak.blogspot.com/
Back to top
View user's profile Send private message 
amigo

Joined: 02 Apr 2007
Posts: 2263

PostPosted: 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
View user's profile Send private message 
snayak

Joined: 14 Sep 2011
Posts: 231

PostPosted: 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

_________________
Machine: Wary 530, AMD Athlon 2000+, ASUS A7N266-VM board, 512MB DDR RAM, 40GB HDD, 52xCDRW, PS/2 Mouse/Keyboard, USB 2.0.
Home: http://www.mathmeth.com/sn/
Blog: http://srinivas-nayak.blogspot.com/
Back to top
View user's profile Send private message 
amigo

Joined: 02 Apr 2007
Posts: 2263

PostPosted: 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
View user's profile Send private message 
jamesbond

Joined: 26 Feb 2007
Posts: 2230
Location: The Blue Marble

PostPosted: 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, Slacko and Puppeee user. Puppy user since 2.13.
Contributed Fatdog64 packages thread
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [8 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0586s ][ Queries: 12 (0.0036s) ][ GZIP on ]