Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 30 Aug 2010 17:31:09 +0200
From:      Tijl Coosemans <tijl@coosemans.org>
To:        freebsd-arch@freebsd.org
Subject:   Re: Support for cc -m32
Message-ID:  <201008301731.19074.tijl@coosemans.org>
In-Reply-To: <201007291718.12687.tijl@coosemans.org>
References:  <201007291718.12687.tijl@coosemans.org>

next in thread | previous in thread | raw e-mail | index | archive | help
--nextPart2583464.2XPOiPN8T5
Content-Type: Text/Plain;
  charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

On Thursday 29 July 2010 17:18:03 Tijl Coosemans wrote:
> I've put the initial version of some patches online to support cross
> compilation of 32 bit binaries on amd64. It's modelled after how NetBSD
> does this.
>=20
> With these patches something like "cc -m32 -o test test.c -pthread -lm"
> generates a program that runs on FreeBSD/i386.
>=20
> http://people.freebsd.org/~tijl/cc-m32-1.diff
> http://people.freebsd.org/~tijl/cc-m32-2.diff
> http://people.freebsd.org/~tijl/cc-m32-3.diff
>=20
> *cc-m32-1.diff* : Let ld and cc find 32 bit libraries.
>=20
> *cc-m32-2.diff* : Install i386 headers on amd64.
>=20
> With this patch headers for a particular $arch are always installed
> under /usr/include/$arch and /usr/include/machine becomes a symlink.
>=20
> A question I have here is how best to clean up the old machine
> directory. The patch currently uses 'rm -rf'.
>=20
> Another problem I encountered was that during the build of
> usr.bin/kdump all headers are searched for definitions of ioctl
> requests and a C source code file is generated that includes all those
> headers. This fails when both i386 and amd64 headers are installed
> because they can't both be included at the same time. For now the patch
> simply blacklists /usr/include/i386, but actually all $arch should be
> excluded. The ioctl requests can still be found through the machine
> symlink. If someone has a better idea...
>=20
> *cc-m32-3.diff* : Modify amd64 headers to include i386 headers when
>                   __i386__ is defined.
>=20
> This patch modifies the amd64 headers to follow this format:
>=20
>   #ifndef _AMD64_HEADER_H
>   #define _AMD64_HEADER_H
>=20
>   #ifdef __i386__
>   #include <i386/header.h>
>   #else
>=20
>   ...
>=20
>   #endif /* __i386__ */
>   #endif /* !_AMD64_HEADER_H */
>=20
> This way including <machine/header.h> works for -m32. There are a few
> i386 headers which don't exist for amd64:
>=20
> apm_segments.h
> bootinfo.h
> cserial.h
> elan_mmcr.h
> if_wl_wavelan.h
> ioctl_bt848.h
> ioctl_meteor.h
> npx.h
> pcaudioio.h
> pcb_ext.h
> perfmon.h
> privatespace.h
> smapi.h
> speaker.h
> vm86.h
> xbox.h
>=20
> Theoretically a dummy amd64 header should be created for each of them
> that just includes the i386 header. The patch does this for npx.h. The
> other headers seem to be really i386 specific or even outdated. If it
> were ever necessary to cross-compile code that uses them, it would be
> easy to modify that code to directly include <i386/header.h>.
>=20
>=20
> Feel free to test the patches and to comment on any part of them.

I'd like to move forward with this now. I've rebased the patches above
against today's CURRENT. If there are no further objections I'd like to
commit them a few days from now, let's say Saturday.

--nextPart2583464.2XPOiPN8T5
Content-Type: application/pgp-signature; name=signature.asc 
Content-Description: This is a digitally signed message part.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.16 (FreeBSD)

iF4EABEIAAYFAkx7zsYACgkQfoCS2CCgtiuYTgD+McJINo+QmlJzQc8r3pA5fjNm
D1UO8me5ljg9xCTevtQA/jU0rSxdQjVF3VRsxdoCpECjVwZ12ECnr1ltF4y7r/xz
=eUE5
-----END PGP SIGNATURE-----

--nextPart2583464.2XPOiPN8T5--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201008301731.19074.tijl>