From owner-freebsd-amd64@FreeBSD.ORG Sun Apr 29 10:52:33 2007 Return-Path: X-Original-To: freebsd-amd64@freebsd.org Delivered-To: freebsd-amd64@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id AB46A16A404 for ; Sun, 29 Apr 2007 10:52:33 +0000 (UTC) (envelope-from peterjeremy@optushome.com.au) Received: from turion.vk2pj.dyndns.org (c220-239-3-125.belrs4.nsw.optusnet.com.au [220.239.3.125]) by mx1.freebsd.org (Postfix) with ESMTP id 0B7BE13C44B for ; Sun, 29 Apr 2007 10:52:32 +0000 (UTC) (envelope-from peterjeremy@optushome.com.au) Received: from turion.vk2pj.dyndns.org (localhost.vk2pj.dyndns.org [127.0.0.1]) by turion.vk2pj.dyndns.org (8.13.8/8.13.8) with ESMTP id l3TAqVwF062033 for ; Sun, 29 Apr 2007 20:52:31 +1000 (EST) (envelope-from peter@turion.vk2pj.dyndns.org) Received: (from peter@localhost) by turion.vk2pj.dyndns.org (8.13.8/8.13.8/Submit) id l3TAqV98062032 for freebsd-amd64@freebsd.org; Sun, 29 Apr 2007 20:52:31 +1000 (EST) (envelope-from peter) Date: Sun, 29 Apr 2007 20:52:31 +1000 From: Peter Jeremy To: freebsd-amd64@freebsd.org Message-ID: <20070429105231.GB848@turion.vk2pj.dyndns.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="BwCQnh7xodEAoBMC" Content-Disposition: inline X-PGP-Key: http://members.optusnet.com.au/peterjeremy/pubkey.asc User-Agent: Mutt/1.5.14 (2007-02-12) Subject: Building i386 executables on amd64 X-BeenThere: freebsd-amd64@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the AMD64 platform List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2007 10:52:33 -0000 --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 gets amd64 versions of files. I bumped into this when I found lseek(2) was failing. The problem is has typedef __off_t off_t; has typedef __int64_t __off_t; 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 #else #include #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--