From owner-freebsd-amd64@FreeBSD.ORG Mon Feb 27 12:41:24 2006 Return-Path: X-Original-To: freebsd-amd64@freebsd.org Delivered-To: freebsd-amd64@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B0B3916A420 for ; Mon, 27 Feb 2006 12:41:24 +0000 (GMT) (envelope-from ru@ip.net.ua) Received: from tigra.ip.net.ua (tigra.ip.net.ua [82.193.96.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2095F43D48 for ; Mon, 27 Feb 2006 12:41:23 +0000 (GMT) (envelope-from ru@ip.net.ua) Received: from localhost (rocky.ip.net.ua [82.193.96.2]) by tigra.ip.net.ua (8.12.11/8.12.11) with ESMTP id k1RCfNn1024884; Mon, 27 Feb 2006 14:41:23 +0200 (EET) (envelope-from ru@ip.net.ua) Received: from tigra.ip.net.ua ([82.193.96.10]) by localhost (rocky.ip.net.ua [82.193.96.2]) (amavisd-new, port 10024) with LMTP id 46237-03; Mon, 27 Feb 2006 14:41:22 +0200 (EET) Received: from heffalump.ip.net.ua (heffalump.ip.net.ua [82.193.96.213]) by tigra.ip.net.ua (8.12.11/8.12.11) with ESMTP id k1RCf4pk024866 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 27 Feb 2006 14:41:05 +0200 (EET) (envelope-from ru@ip.net.ua) Received: (from ru@localhost) by heffalump.ip.net.ua (8.13.4/8.13.4) id k1RCfEJU043572; Mon, 27 Feb 2006 14:41:14 +0200 (EET) (envelope-from ru) Date: Mon, 27 Feb 2006 14:41:14 +0200 From: Ruslan Ermilov To: Paul Koch Message-ID: <20060227124114.GP42677@ip.net.ua> References: <200602271549.26372.paul.koch@statseeker.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="eLe8FOcWSbbyMVJD" Content-Disposition: inline In-Reply-To: <200602271549.26372.paul.koch@statseeker.com> User-Agent: Mutt/1.5.11 X-Virus-Scanned: amavisd-new at ip.net.ua Cc: freebsd-amd64@freebsd.org Subject: Re: Compiling using -m32 on a 64bit platform 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: Mon, 27 Feb 2006 12:41:24 -0000 --eLe8FOcWSbbyMVJD Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Feb 27, 2006 at 03:49:26PM +1000, Paul Koch wrote: > Hi, >=20 > We have a locally written application which is currently deployed on=20 > i386, and we have recently ported it to amd64. Unfortunately, in our=20 > 64bit compile, some of our libraries and executables still need to be=20 > compiled for a 32bit architecture. Our application setup is a server=20 > (i386 or amd64 based) which communicates with remote network appliances= =20 > (i386 based) and the server downloads various binaries to the remote=20 > appliances. >=20 >=20 > The issues we have come across are to do with the size of various types.= =20 > For example: >=20 > int64_t > - compiled on a 32bit machine is 64bits > - compiled on a 64bit machine is 64bits > - compiled on a 64bit machine with -m32 is 32bits !! >=20 > Sample: >=20 > #include > #include >=20 > int > main (int argc, char **argv) > { > printf ("sizeof (int64_t): %d\n", (int) sizeof (int64_t)); >=20 > return 0; > } >=20 > $ cc -Wall -m32 -L/usr/lib32 -B/usr/lib32 -o test_32 test.c > $ cc -Wall -o test_64 test.c >=20 > $ ./test_32 > sizeof (int64_t): 4 >=20 > $ ./test_64 > sizeof (int64_t): 8 >=20 You want to adopt the same approach that's used to compile 32-bit runtime support on amd64. In the above, at the very minimum, you miss the 32-bit (i386) versions of includes. The infrastructure to allow users to build their 32-bit apps is not ready, so you'll have to roll your own. Fortunately, this should be easy to do. You can try it by using the make command from src/Makefile.inc1, as will be shown by "make -f Makefile.inc1 -V LIB32MAKE", after completing buildworld on amd64. For example, : Script started on Mon Feb 27 14:37:44 2006 : $ uname -srm : FreeBSD 7.0-CURRENT amd64 : $ cat Makefile : LIB32MAKE!=3D cd /usr/src && ${MAKE} -f Makefile.inc1 -V LIB32MAKE :=20 : .for target in depend all : ${target}32: : @cd ${.CURDIR} && ${LIB32MAKE} ${target} : .endfor :=20 : PROG=3D test_32 : SRCS=3D test.c : NO_MAN=3D :=20 : .include : $ make all32 : Warning: Object directory not changed from original /tmp : cc -m32 -march=3Dk8 -mfancy-math-387 -DCOMPAT_32BIT -I/usr/obj/usr/src/l= ib32/usr/include -L/usr/obj/usr/src/lib32/usr/lib32 -B/usr/obj/usr/src/li= b32/usr/lib32 -O2 -fno-strict-aliasing -pipe -c test.c : cc -m32 -march=3Dk8 -mfancy-math-387 -DCOMPAT_32BIT -I/usr/obj/usr/src/l= ib32/usr/include -L/usr/obj/usr/src/lib32/usr/lib32 -B/usr/obj/usr/src/li= b32/usr/lib32 -O2 -fno-strict-aliasing -pipe -o test_32 test.o=20 : $ file test_32 : test_32: ELF 32-bit LSB executable, Intel 80386, version 1 (FreeBSD), dyn= amically linked (uses shared libs), not stripped : $ ./test_32 : sizeof (int64_t): 8 : Script done on Mon Feb 27 14:38:03 2006 Cheers, --=20 Ruslan Ermilov ru@FreeBSD.org FreeBSD committer --eLe8FOcWSbbyMVJD Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (FreeBSD) iD8DBQFEAvNqqRfpzJluFF4RAkJhAJ9KLPO8KjtD0YdqgwS+xsNRXXBSOgCfUjwo DXURDhKpxVN1lITZTdmdxvA= =IFgJ -----END PGP SIGNATURE----- --eLe8FOcWSbbyMVJD--