32 bit ports on an AMD64 system

b. f. bf1783 at googlemail.com
Mon Aug 31 15:18:01 UTC 2009


>I want to compile some 32 bit ports on an AMD64 system. I know the GCC
>has to receive the -m32 flag to compile the ports as 32 bit, but I
>also want to change the install directory with 32 bit ports, I was
>wondering which would be the most appropriate root given unix themes
>and standard FreeBSD directory structure.
>
>/usr/local/[same-as-before]-32 (i.e. [...]/bin32, [...]/lib32,[...]/libexec32, etc)
>/usr/32/
>/usr/32bit/
>/usr/FreeBSD32/
>/usr/compat/32bit/
>/usr/compat/FreeBSD32/
>
>
>Also, would I be able to pass the appropriate flags through port
>upgrade (or use environmental variables), or would I have to make
>duplicates of the port directories and modify the makefiles?
>
>Thanks,
>-Jim Stapleton

First, I hope that you have a good reason for doing this, because it
is going to be a PITA, and prone to all sorts of problems. The Ports
collection is full of sloppy linking statements, and not all ports
respect custom CFLAGS, PREFIX, and LOCALBASE settings, although they
are supposed to do so. Other ports use a compiler that may not be able
to produce 32-bit binaries on amd64.  If you mean to build a large
number of ports this way, you are better off either installing i386,
or at least building and installing these ports in a jail, where you
can more effectively isolate them from your 64-bit ports.  Mixing and
matching a large number of 32-bit and 64-bit ports will be a headache,
especially if you have both 32- and 64-bit versions of some ports
installed in parallel.

If you are just talking about unshadowed ports, you could try adding
something like the following to /etc/make.conf:

.ifdef(32BIT)
PREFIX=/usr/local/32
LOCALBASE=/usr/local/32
LDCONFIG=/sbin/ldconfig -32
CFLAGS+=-m32
.endif

and then wrapping your portupgrade, portmaster, or make commands with:

env 32BIT=yes [insert rest of command here]

If there is shadowing, you have to consider how to manage the
environment PATH so that you can actually run the 32-bit binary
executables without typing in fully-qualified pathnames every time,
and maybe also using LD_RUN_PATH or LD_LIBRARY_PATH so that the right
libraries are used --- you can see how problems crop up at every turn?

b.


More information about the freebsd-questions mailing list