Support for cc -m32
tijl at coosemans.org
Thu Jul 29 15:47:44 UTC 2010
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
With these patches something like "cc -m32 -o test test.c -pthread -lm"
generates a program that runs on FreeBSD/i386.
*cc-m32-1.diff* : Let ld and cc find 32 bit libraries.
*cc-m32-2.diff* : Install i386 headers on amd64.
With this patch headers for a particular $arch are always installed
under /usr/include/$arch and /usr/include/machine becomes a symlink.
A question I have here is how best to clean up the old machine
directory. The patch currently uses 'rm -rf'.
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...
*cc-m32-3.diff* : Modify amd64 headers to include i386 headers when
__i386__ is defined.
This patch modifies the amd64 headers to follow this format:
#endif /* __i386__ */
#endif /* !_AMD64_HEADER_H */
This way including <machine/header.h> works for -m32. There are a few
i386 headers which don't exist for amd64:
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>.
Feel free to test the patches and to comment on any part of them.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 228 bytes
Desc: This is a digitally signed message part.
Url : http://lists.freebsd.org/pipermail/freebsd-arch/attachments/20100729/861a3f00/attachment.pgp
More information about the freebsd-arch