Building i386 executables on amd64
peterjeremy at optushome.com.au
Sun Apr 29 10:52:33 UTC 2007
I'm currently working on being able to build and run i386 executables
on amd64 (primarily so I can work on a project that's not 64-bit clean
yet). So far, I've run into the following problems:
- "gcc -m32" tries to link against 64-bit libraries (amd64/112215)
I have a work-around for this and simple executables will compile & run.
- Corrupt FP number formatting (amd64/112222)
This has been fixed in a more recent Makefile.inc1
- #include <machine/...> gets amd64 versions of files.
I bumped into this when I found lseek(2) was failing. The problem is
<sys/types.h> has typedef __off_t off_t;
<sys/_types.h> has typedef __int64_t __off_t;
<machine/_types.h> has typedef long __int64_t;
This is OK in native mode, but with compiled with "-m32", long is 32
bits and hence off_t is the wrong size. I'm not sure how this should
be handled. The two approaches I've come up with so far are:
a) /usr/include/machine/foo.h contains
And then install both sys/amd64/include and sys/i386/include.
b) Merge both sys/amd64/include and sys/i386/include (at least the
files that are installed into /usr/include/machine) with conflicting
definitions selected using #ifdef __amd64 or __i386.
- At least with my solution to amd64/112215, i386 executables built on
amd64 won't run on i386.
This is because the executables reference /libexec/ld-elf32.so.1 and
/usr/lib32/*.so - which don't exist on an i386 install. The solutions
here would seem to be:
a) link /libexec/ld-elf.so.1 to /libexec/ld-elf32.so.1 and /usr/lib to
/usr/lib32 on i386 (though this doesn't work for libc.so.N which is
b) Use a different fix to amd64/112215 that links the executables in
"compatibility" mode (in much the same way as i386 executables can
point to /libexec/ld-elf.so.1 and /usr/lib but still run on amd64).
The second approach would seem cleaner (ie an i386 executable looks
identical whether it was built natively on i386 or using -m32 on
amd64) but I'm not sure how easy it is to implement. The first
approach is basically implementing "i386 emulation" mode on i386.
I'd appreciate input and comments from anyone else working in this area.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-amd64/attachments/20070429/ea6921e5/attachment.pgp
More information about the freebsd-amd64