LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   building GCC for 32-bit i586 (https://www.linuxquestions.org/questions/programming-9/building-gcc-for-32-bit-i586-4175533281/)

barber76 02-06-2015 12:04 PM

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.

NevemTeve 02-06-2015 12:11 PM

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.

barber76 02-06-2015 12:43 PM

Quote:

Originally Posted by NevemTeve (Post 5313142)
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

NevemTeve 02-06-2015 01:00 PM

You might want to add this to your nonexistent script, before the ./configure:
Code:

export CFLAGS="$CFLAGS -m32"
export LDFLAGS="$LDFLAGS -m32"


barber76 02-06-2015 04:06 PM

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...

veerain 02-06-2015 10:12 PM

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


All times are GMT -5. The time now is 08:31 PM.