Re: gcc -m32 option on amd64.



On Fri, 2007-07-27 at 20:20 +1000, Peter Jeremy wrote:
On 2007-Jul-27 15:13:48 +0530, Sharad Chandra <sharadc@xxxxxxxxxx> wrote:
I am trying gcc -m32 on freebsd 6.1 amd64 env, but it does not seems to be
working. i also installed /usr/port/lang/linux-libgcc/ but did not help
what i did is=>
echo "main () {}" > t.c; gcc -m32 t.c
/usr/bin/ld: skipping
incompatible /usr/local/lib/gcc/x86_64-portbld-freebsd6.1/4.2.0/gcc/x86_64-portbld-freebsd6.1/4.2.0/libgcc.a
when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
collect2: ld returned 1 exit status

how can we make this working?

You are using gcc 4.2 from ports. I suspect this only includes the
64-bit libraries. gcc in the base system includes both 32-bit and
64-bit libraries by default but it still suffers the same problem.

I had a go at fixing the problem in amd64/112215 but this has other
problems and needs more work. Note that non-trivial code will break
because <machine/XXXX.h> points at amd64 headers whilst the -m32
compiler needs i386 headers in many cases. There's a non-trivial
amount of work needed to actually get cross-building working. I
suggest you look throught the FreeBSD-amd64 archives.


gcc on amd64 is capable of generating i386 code, but ld on amd64 is
incapable of linking i386 code together without serious amounts of work.

At work, we use a large number of amd64 boxes as compile farm servers
for i386 development, using distcc and a wrapper to invoke gcc correctly
on the external boxes.

To verify that it works (it compiles to i386 code), do this:
$ uname -a; echo "main() { } " > t.c ; gcc -c -m32 -o t.o t.c; file t.o
FreeBSD chef.mintel.co.uk 6.1-STABLE FreeBSD 6.1-STABLE #1: Fri Jun 23
12:48:28 BST 2006
operator@xxxxxxxxxxxxxxxxx:/usr/obj/usr/src/sys/CHEF amd64
t.o: ELF 32-bit LSB relocatable, Intel 80386, version 1 (FreeBSD), not
stripped

Attachment: signature.asc
Description: This is a digitally signed message part



Relevant Pages

  • Re: Whats the story with the "end of XP"?
    ... Support gives them access to the larger body ... The same compiler suite may be "best" in both ... In the case of ByteCraft compilers, you are truly expert in your field, you work closely and rapidly with customers if there are any issues, and you have top class testing and quality control. ... understanding the inner workings of a relatively simple compiler like GCC ...
    (comp.arch.embedded)
  • [RFC][PATCH-2.6] Clean up and merge compiler-*.h
    ... the kernel headers in include/linux to include/linux-abi. ... * Common definitions for all gcc versions go here. ... -/* Some compiler specific definitions are overwritten here ...
    (Linux-Kernel)
  • Re: LPC900/80C51 Compiler Toolchain
    ... >> supported by GCC, and so they invest. ... > if they already have their in-house compiler. ... one of the main companies in the Symbian consortium ... vendor to provide a good compiler for Atmel AVRs and eventually became ...
    (comp.arch.embedded)
  • Newbie packages question
    ... checking for gcc... ... checking for C compiler default output file name... ... checking if the linker is GNU ld... ... checking how to recognise dependent libraries... ...
    (Debian-User)
  • Lib X11 compile problem /Xlib.h:3573: error: syntax error before "_X_SENTINEL"
    ... checking for gcc... ... checking for C compiler default output file name... ... checking how to recognise dependent libraries... ...
    (comp.os.linux.x)