LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-06-2015, 12:04 PM   #1
barber76
LQ Newbie
 
Registered: Feb 2015
Location: Austin, TX
Posts: 6

Rep: Reputation: Disabled
building GCC for 32-bit i586


Hi everyone.
I've installed (to non-default location) side version of glibc configured with --host=pentium-linux , as my primary goal is to build statically linked executables for 32bit Pentium ISA.
To avoid problems of pairing my default gcc/g++ with my side glibc, I decided to install side version of GCC as well, using my side glibc as a sysroot. I configured GCC with
--with-sysroot=/path/to/my/glibc --target=i586-linux --disable-multilib --with-multilib-list=m32

GCC build goes for some time, then fails with
Code:
g++ -m32   -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE  -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings   -DHAVE_CONFIG_H -DGENERATOR_FILE -static-libstdc++ -static-libgcc  -o build/genconstants \
            build/genconstants.o build/read-md.o build/errors.o ../build-x86_64-unknown-linux-gnu/libiberty/libiberty.a
/nfs/an/itools/em64t_SLES10/pkgs/gcc/4.8.0/.bin/../lib64/gcc/x86_64-suse-linux/4.8.0/../../../../x86_64-suse-linux/bin/ld: i386:x86-64 architecture of input file `../build-x86_64-unknown-linux-gnu/libiberty/libiberty.a(concat.o)' is incompatible with i386 output
I checked how those libiberty.a made, looks like it is a pack of *.o libraries, and each library is built with simple
gcc -O2 -g ...and different defines and source file...
No -march=pentium, no -m32, nothing.

Looks like my configure settings --target=i586-linux --disable-multilib --with-multilib-list=m32 didn't affect all that is needed.
What do I do? Do I have to set CFLAGS/CXXFLAGS in addition?

Thanks a lot.
 
Old 02-06-2015, 12:11 PM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Hopefully you created a script for compilation, sg like this:
Code:
#!/bin/sh
./configure ... 2>&1 | tee log.configure
make all 2>&1 | tee log.make.all
If it is so, please quote your script.
 
Old 02-06-2015, 12:43 PM   #3
barber76
LQ Newbie
 
Registered: Feb 2015
Location: Austin, TX
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by NevemTeve View Post
Hopefully you created a script for compilation, sg like this:
Code:
#!/bin/sh
./configure ... 2>&1 | tee log.configure
make all 2>&1 | tee log.make.all
If it is so, please quote your script.
Hi NevemTeve. I just did
../gcc-4.8.4/configure --prefix=/future/path/to/my/gcc/install --with-sysroot=/path/to/my/glibc/install --target=i586-linux --disable-multilib --with-multilib-list=m32
And then typed make.
Configure script itself in in gcc source folder. Makefile is created by configure script. Make log is too long to quote. What should I quote?

P.S. my compilation script would be those two lines:
../gcc-4.8.4/configure --prefix=/future/path/to/my/gcc/install --with-sysroot=/path/to/my/glibc/install --target=i586-linux --disable-multilib --with-multilib-list=m32
make

Last edited by barber76; 02-06-2015 at 12:55 PM.
 
Old 02-06-2015, 01:00 PM   #4
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
You might want to add this to your nonexistent script, before the ./configure:
Code:
export CFLAGS="$CFLAGS -m32"
export LDFLAGS="$LDFLAGS -m32"
 
Old 02-06-2015, 04:06 PM   #5
barber76
LQ Newbie
 
Registered: Feb 2015
Location: Austin, TX
Posts: 6

Original Poster
Rep: Reputation: Disabled
I just noticed, that I accidentally had CC env.var set to 'gcc -march=pentium -m32 -O2' - this was left after I was building glibc in same shell session.
I started gcc configure/build from scratch, this time opening new login terminal without any CC-related enviroment variables. Just totally relying on configuring script doing what needed. And now I have different failure:
../gcc-4.8.4/configure --prefix=/future/path/to/my/gcc/install --with-sysroot=/path/to/my/glibc/install --target=i586-linux --disable-multilib --with-multilib-list=m32
make

Code:
checking for i586-linux-ranlib... i586-linux-ranlib
checking for i586-linux-strip... i586-linux-strip
checking whether ln -s works... yes
checking for i586-linux-gcc... /my/path/to/gcc/build/./gcc/xgcc -B/my/path/to/gcc/build/./gcc/ -B/my/path/to/gcc/install/i586-linux/bin/ -B/my/path/to/gcc/install/i586-linux/lib/ -isystem /my/path/to/gcc/install/i586-linux/include -isystem /my/path/to/gcc/install/i586-linux/sys-include   
checking for suffix of object files... configure: error: in `/my/path/to/gcc/build/i586-linux/libgcc':
configure: error: cannot compute suffix of object files: cannot compile
See `config.log' for more details.
gmake[1]: *** [configure-target-libgcc] Error 1
I look to the log and I see:
Code:
configure:3347: /my/path/to/gcc/build/./gcc/xgcc -B/my/path/to/gcc/build/./gcc/ -B/my/path/to/gcc/install/i586-linux/bin/ -B/my/path/to/gcc/install/i586-linux/lib/ -isystem /my/path/to/gcc/install/i586-linux/include -isystem /my/path/to/gcc/install/i586-linux/sys-include    -V >&5
xgcc: error: unrecognized command line option '-V'
xgcc: fatal error: no input files
Ok, what's the hell xgcc is, anyway? I check my build output and see that this... thing was build this way:
Code:
g++   -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE  -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings   -DHAVE_CONFIG_H -static-libstdc++ -static-libgcc  -o xgcc gcc.o ggc-none.o \
c/gccspec.o driver-i386.o  libcommon-target.a \
libcommon.a ../libcpp/libcpp.a   ../libbacktrace/.libs/libbacktrace.a ../libiberty/libiberty.a ../libdecnumber/libdecnumber.a
That's where I'm now...
 
Old 02-06-2015, 10:12 PM   #6
veerain
Senior Member
 
Registered: Mar 2005
Location: Earth bound to Helios
Distribution: Custom
Posts: 2,524

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
Please read glibc howto from http://www.tldp.org.
 
  


Reply

Tags
gcc, glibc, isa, pentium



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
i586-mingw32msvc-gcc and -lpcap vip2442 Linux - Software 2 10-27-2011 01:58 AM
Compilation problem when downgrading from 64-bit gcc to 32-bit gcc huyhoang3673 Linux - Software 7 08-26-2009 11:31 AM
upgrading from i586 to 64 bit via internet TuxLives Mandriva 1 01-05-2009 02:19 PM
errors building xerces xml parser on SLES 9 (i586) nkshirsagar SUSE / openSUSE 0 05-02-2005 08:12 AM
gcc-3.1-1mdk.i586.rpm aizkorri Linux - Software 7 08-20-2002 02:06 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:38 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration