Cross-building i386 on amd64

Peter Jeremy peterjeremy at
Wed Sep 9 21:01:48 UTC 2009

Cross-building i386 on amd64 is a fairly regular request and the
only solution at present is installing a full i386 world and running
the build inside a jail or chroot - and even then, some tweaks are
necessary for (eg) the FreeBSD buildworld to work.  Since the amd64
toolchain is inherently capable of building i386 code, this seems

The biggest impediment I can see to cross-building i386 on amd64 is
the presence of /usr/include/machine.  I've been doing some thinking
and come up with a number of possible solutions.  I would appreciate
input on any other approaches and which is the best approach.

1) Install /sys/{amd64,i386}/include as /usr/include/{amd64,i386} and
   use a variant symlink from /usr/include/machine
  + Extensible to other architectures if necessary
  + Easiest to understand for end users
  - Variant symlinks don't exist in FreeBSD
2) Install /sys/{amd64,i386}/include as /usr/include/{amd64,i386}/machine
   and use an option-dependent test in gcc specs to add -I/usr/include/i386
   or -I/usr/include/amd64 before -I/usr/include
  + Extensible to other architectures if necessary
  - end users need to understand toolchain innards to find <machine/foo.h>
  - list of "standard system directories" in gcc may need tweaking so that
    -nostdinc and -I behave as documented[*]
3) Create /usr/include32 containing i386 include files
  + Naming consistent with existence of /usr/lib32
  - list of "standard system directories" in gcc may need tweaking so that
    -nostdinc and -I behave as documented[*]
  - Not extensible
  - Duplicates installation of 99.8% of /usr/include (or needs pile of

Overall, I believe 2 may be the best option but would appreciate comments.

[*] gcc documentation for -I DIR states: "If the directory DIR is a
standard system include directory, the option is ignored to ensure
that the default search order for system directories and the special
treatment of system headers are not defeated."  Do we need to make
sure that someone manually entering -I/usr/include/i386 doesn't cause
problems?  How about someone using -nostdinc to fiddle with the system
include ordering - they are likely to miss the special handling for

Peter Jeremy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url :

More information about the freebsd-amd64 mailing list