Date: Mon, 27 Feb 2006 14:41:14 +0200 From: Ruslan Ermilov <ru@freebsd.org> To: Paul Koch <paul.koch@statseeker.com> Cc: freebsd-amd64@freebsd.org Subject: Re: Compiling using -m32 on a 64bit platform Message-ID: <20060227124114.GP42677@ip.net.ua> In-Reply-To: <200602271549.26372.paul.koch@statseeker.com> References: <200602271549.26372.paul.koch@statseeker.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--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 <sys/types.h> > #include <stdio.h> >=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 <bsd.prog.mk> : $ 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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060227124114.GP42677>