building old gcc3 for i386-linux on recent x86-linux?
Steffen Dettmer
steffen.dettmer@gmail.com
Thu Feb 18 17:21:00 GMT 2016
Hi,
in short:
How to build a gcc3 host=x86-linux target=i386-old-linux today?
Are there alternatives?
--long:
I'd have to build old 32 bit applications for old i386 Linux
systems and would like to use a recent 64 bit Linux system to do
so. I think I should be able to install an old gcc3 as
cross-compiler.
As first step I unpacked binutils-2.16.1a.tar.bz2 and
gcc-3.4.3.tar.gz, symlinked " bfd binutils gas gprof ld opcodes"
to gcc src dir in order to perform a "combined build", created an
objdir and ran configure --target=i386-myold-linux, which worked
(see below for the complete commands).
I wondered why I don't need any headers of the old glibc to be
used and so far no kernel headers... Did I miss something here?
(Note: in later attempts, I tried various combinations with
--sys-root, but had no success either). I expected that I'd build
bintuils+gcc+glibc (some older egclib) against the headers from
the old target kernel. Am I on the right way at all?
After configure, I tried "make", but it fails:
gcc -W -Wall -Wstrict-prototypes -Wmissing-prototypes -g -O2
-o .libs/size size.o bucomm.o version.o filemode.o
../bfd/.libs/libbfd.so
-L/net/dehecnas1/Homes/sdettmer/tmp/gcc3/3/objdir/libiberty/pic
-liberty ../libiberty/libiberty.a ./../intl/libintl.a -Wl,--rpath
-Wl,/net/dehecnas1/Homes/sdettmer/tmp/gcc3/3/inst/x86_64-unknown-linux-gnu/i386-vcu-linux/lib
gcc: error: ./../intl/libintl.a: No such file or directory
Makefile:615: recipe for target 'size' failed
just guessing I tried:
make -C intl libintl.a
which worked, so I repeated make. Now it fails a bit later with:
gcc -W -Wall -Wstrict-prototypes -Wmissing-prototypes -g -O2
-o .libs/size size.o bucomm.o version.o filemode.o
../bfd/.libs/libbfd.so
-L/net/dehecnas1/Homes/sdettmer/tmp/gcc3/3/objdir/libiberty/pic
-liberty ../libiberty/libiberty.a ./../intl/libintl.a -Wl,--rpath
-Wl,/net/dehecnas1/Homes/sdettmer/tmp/gcc3/3/inst/x86_64-unknown-linux-gnu/i386-vcu-linux/libbucomm.o:
In function `make_tempname':
/net/dehecnas1/Homes/sdettmer/tmp/gcc3/3/objdir/binutils/../../gcc-3.4.3/binutils/bucomm.c:425:
warning: the use of `mktemp' is dangerous, better use `mkstemp' or
`mkdtemp'
../bfd/.libs/libbfd.so: undefined reference to `unlink_if_ordinary'
collect2: error: ld returned 1 exit status
Makefile:615: recipe for target 'size' failed
and indeed
nm libiberty/libiberty.a |grep unlink_if_ordinary
finds nothing. Interestingly, when I build binutils in a
different object dir alone, I get a libiberty.a with:
nm libiberty/libiberty.a |grep unlink_if_ordinary
0000000000000000 T unlink_if_ordinary
so as I already was hacking I just used the whole folder in my
gcc build tree and re-run make. This time it runs some more
seconds until it fails with:
../../gcc-3.4.3/gcc/config/i386/linux.h:217:20: signal.h: No
such file or directory
../../gcc-3.4.3/gcc/config/i386/linux.h:218:26:
sys/ucontext.h: No such file or directory
in my kernel headers ("2.6.16.60-0.37_f594963d-bigsmp") I have
asm/ucontext.h, but no sys/ucontext.h. For a test, I copied
headers from target system to my inst/i386-vcu-linux/sys-include/
and some libs (crt*.o, libc.so and libm.so) to inst/i386-vcu-linux/lib.
Make progresses but then fails with:
checking for main in -lm... configure: error: Link tests are
not allowed after GCC_NO_EXECUTABLES.
Makefile:21960: recipe for target 'configure-target-libstdc++-v3' failed
make: *** [configure-target-libstdc++-v3] Error 1
This time I had no idea what I could hack to progress.
I also tried to build with newer binutils versions
(binutils-2.19.1, binutils-2.22.tar.bz2), but they try to compile
with -Werror which fails because of gcc49 warnings.
I tried older (2.14), but had issues resulting in an attemp to
run flex. I also tried gcc-3.3.6 (which I actually would prefere)
without success.
I even tried to build a native gcc3 first (with make bootstrap),
but it also failed. First, with libiberty, as above, when copying
it from binutils build, I get:
gcc -DHAVE_CONFIG_H -I. -I../../gcc-3.3.6/gprof -I.
-D_GNU_SOURCE -DDEBUG -I../bfd -I../../gcc-3.3.6/gprof/../include
-I../../gcc-3.3.6/gprof/../bfd -I../../gcc-3.3.6/gprof/../intl
-I../intl -I. -DLOCALEDIR="\"/net/dehecnas1/Homes/sdettmer/tmp/gcc3/2/native/share/locale\""
-W -Wall -Wstrict-prototypes -Wmissing-prototypes -g -O2 -c
../../gcc-3.3.6/gprof/sparc.c
gcc -DHAVE_CONFIG_H -I. -I../../gcc-3.3.6/gprof -I.
-D_GNU_SOURCE -DDEBUG -I../bfd -I../../gcc-3.3.6/gprof/../include
-I../../gcc-3.3.6/gprof/../bfd -I../../gcc-3.3.6/gprof/../intl
-I../intl -I. -DLOCALEDIR="\"/net/dehecnas1/Homes/sdettmer/tmp/gcc3/2/native/share/locale\""
-W -Wall -Wstrict-prototypes -Wmissing-prototypes -g -O2 -c
../../gcc-3.3.6/gprof/mips.c
cc -c -o flat_bl.o ../../gcc-3.3.6/gprof/flat_bl.m
cc: error trying to exec 'cc1obj': execvp: No such file or directory
<builtin>: recipe for target 'flat_bl.o' failed
make[3]: *** [flat_bl.o] Error 1
(after several calls to gcc it calls cc?)
and when removing gprof from Makefile it progresses, but finally
I cannot link because it misses ctri.o (it is in
/usr/lib/x86_64-linux-gnu/crti.o).
How to build a gcc3 version today?
Any hint, help or FAQ pointers appreciated! Google is not so
helpful when looking for older information...
Steffen
------------------------------------------------------------------->8=======
#!/bin/bash
set -e
function warn() { echo "$@" >&2 ; }
function die() { warn "FATAL: $@" ; exit 2 ; }
#tar xjf binutils-2.16.1a.tar.bz2
#tar xzf gcc-3.4.3.tar.gz
#tar xzf glibc-2.3.4.tar.gz
( cd gcc-3.4.3/ && for d in bfd binutils gas gprof ld opcodes ; do ln
-sf ../binutils-2.16.1/$d . || die "failed to symlink binutils"; done
) || die "error"
test -d objdir || mkdir objdir
test -d binobjdir || mkdir binobjdir
test -d inst || mkdir inst
#TODO
# mkdir inst/i386-vcu-linux/sys-include
# cd ... && ln -s ../../../dehetucks-includes/* .
# mkdir inst/i386-vcu-linux/lib/
# ctr*o, lib[cm].so
inst="`pwd`/inst"
# seems unused (but check inst/i386-vcu-linux/sys-include/)
test -d inst/sys-include || mkdir inst/sys-include
( cd inst/sys-include && ln -sf
../../linux-2.6.16.60-0.37_f594963d-bigsmp/linux linux )
( cd inst/sys-include && ln -sf
../../asm-2.6.16.60-0.37_f594963d-bigsmp/asm asm )
#test -d sysroot || mkdir sysroot
PATH=/bin:/usr/bin
# TODO CHECK: should need old host triplet names?
# --with-system-zlib \
# --prefix=/usr/local/ \
# --with-local-prefix: Do not specify /usr
# --with-sysroot
# --with-clocale=generic https://gcc.gnu.org/ml/gcc-help/2014-09/msg00010.html
# --with-cpu=generic # original gcc-3.3.6 tells this, but not supported here?
cd objdir
../gcc-3.4.3/configure \
--target=i386-vcu-linux \
--prefix=$inst \
--with-local-prefix=$inst \
--enable-threads=posix \
--enable-languages=c,c++ \
--enable-ssp --disable-libssp \
--enable-shared --enable-__cxa_atexit \
--enable-libstdcxx-allocator=new \
--enable-version-specific-runtime-libs \
--without-system-libunwind
make -j8
More information about the Gcc-help
mailing list