Date: Sun, 29 Apr 2007 20:52:31 +1000 From: Peter Jeremy <peterjeremy@optushome.com.au> To: freebsd-amd64@freebsd.org Subject: Building i386 executables on amd64 Message-ID: <20070429105231.GB848@turion.vk2pj.dyndns.org>
next in thread | raw e-mail | index | archive | help
--BwCQnh7xodEAoBMC Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 #ifdef __amd64 #include <amd64/foo.h> #else #include <i386/foo.h> #endif 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 in /lib) 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. --=20 Peter Jeremy --BwCQnh7xodEAoBMC Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (FreeBSD) iD8DBQFGNHjv/opHv/APuIcRAn51AKC8HWw+VeBFqfX3FKXh9+02r1BNKwCffIhG ZsRaSYzuIZQGTfzipPOQ9s4= =lrpC -----END PGP SIGNATURE----- --BwCQnh7xodEAoBMC--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070429105231.GB848>