32 bit libraries - build hack

Peter Wemm peter at wemm.org
Sun Mar 21 20:13:16 PST 2004


http://people.freebsd.org/~peter/build32.sh

This builds a working set of libraries and rtld to match.  Some caveats..

- It must be run AFTER a FULL world build and install.
- You MUST be running -current after of yesterday afternoon.  Sorry, no
  5.2-R/5.2.1-R support here.
- c++ doesn't seem to like the -m32 switch, so you'll still need to supply
  your own libstdc++.so.4.
- ldconfig has an undocumented -32 switch for setting the search path
  for ld-elf32.so.1.  You'll need to do this for local and X11R6 libraries.
- Yes, you could conceivably use a pure 32 bit /usr/X11R6 and /usr/local.
  But I haven't tried it and I'm not planning to.  You'll need to hack your
  rc scripts to not add /usr/local/lib to your 64 bit library search paths etc.
- no, there is no /compat subtree for this stuff.  I'm not aware of anything that
  needs it.  All the files in /etc and /var are shareable because we have
  explicitly sized  types in our definitions for them.

This isn't well tested, its a hack.  I tried it on a previously unmolested
machine (sledge.freebsd.org) before posting this.  Ideally this should be
better integrated with world at some point, but I'll personally shoot anybody
who makes this something that happens unconditionally with every buildworld.

#! /bin/sh
# $P4: //depot/projects/hammer/build32.sh#5 $
#
# This script is for running on a self-hosted amd64 machine, with an up-to-date
# world and toolchain etc.  ie: the installed world is assumed to match the sources.
# It is rude, crude and brutal.  But its the only option for now.
#
# Its purpose is to build a 32 bit library set and a ld-elf32.so.1.

# XXX beware.. some of the library targets have no way to disable
# XXX installation of includes.  ie: it will re-install some files in
# XXX /usr/include for you.

mkdir /lib32
mkdir /usr/lib32
mkdir /usr/local/lib32
mkdir /usr/X11R6/lib32

# Set up an obj tree
chflags -R noschg /tmp/i386
rm -rf /tmp/i386

# and a place to put the alternate include tree into.
mkdir -p /tmp/i386/root
make MAKEOBJDIRPREFIX=/tmp/i386 DESTDIR=/tmp/i386/root MACHINE_ARCH=i386 hierarchy

# Now build includes
make MAKEOBJDIRPREFIX=/tmp/i386 DESTDIR=/tmp/i386/root MACHINE_ARCH=i386 obj
make MAKEOBJDIRPREFIX=/tmp/i386 DESTDIR=/tmp/i386/root MACHINE_ARCH=i386 includes

# libncurses needs a build-tools pass first.  I wish build-tools was a recursive target.
(cd lib/libncurses; make MAKEOBJDIRPREFIX=/tmp/i386 build-tools)

# Now the libraries.  This doesn't work for bind, gnuregex and stdc++ yet. hence -k
make -DNOMAN -DNODOC -DNOINFO MAKEOBJDIRPREFIX=/tmp/i386 LIBDIR=/usr/lib32 SHLIBDIR=/usr/lib32 MACHINE_ARCH=i386 CC="cc -m32 -I/tmp/i386/root/usr/include -L/usr/lib32 -B/usr/lib32" CXX="c++ -m32 -I/tmp/i386/root/usr/include/c++/3.3 -L/usr/lib32 -B/usr/lib32" LD="ld -m elf_i386_fbsd -Y P,/usr/lib32" -k libraries

# bind isn't a problem, its an internal no-install lib, so let it fail.
# libstdc++ is a curious one. it looks like "c++ -m32" doesn't work.
# Hack to fix gnuregex which does evil hacks to the -I paths.
(cd gnu/lib/libregex; make -DNOMAN -DNODOC -DNOINFO MAKEOBJDIRPREFIX=/tmp/i386 LIBDIR=/usr/lib32 SHLIBDIR=/usr/lib32 MACHINE_ARCH=i386 CC="cc -m32 -I/tmp/i386/root/usr/include/gnu -I/tmp/i386/root/usr/include -L/usr/lib32 -B/usr/lib32" CXX="c++ -m32 -I/tmp/i386/root/usr/include/c++/3.3 -L/usr/lib32 -B/usr/lib32" LD="ld -m elf_i386_fbsd -Y P,/usr/lib32" all install)

# and now that we have enough libraries, build ld-elf32.so.1
cd libexec/rtld-elf
make -DNOMAN -DNODOC -DNOINFO PROG=ld-elf32.so.1 MAKEOBJDIRPREFIX=/tmp/i386 LIBDIR=/usr/lib32 SHLIBDIR=/usr/lib32 MACHINE_ARCH=i386 CC="cc -m32 -I/tmp/i386/root/usr/include -L/usr/lib32 -B/usr/lib32 -DCOMPAT_32BIT" LD="ld -m elf_i386_fbsd -Y P,/usr/lib32" obj
make -DNOMAN -DNODOC -DNOINFO PROG=ld-elf32.so.1 MAKEOBJDIRPREFIX=/tmp/i386 LIBDIR=/usr/lib32 SHLIBDIR=/usr/lib32 MACHINE_ARCH=i386 CC="cc -m32 -I/tmp/i386/root/usr/include -L/usr/lib32 -B/usr/lib32 -DCOMPAT_32BIT" LD="ld -m elf_i386_fbsd -Y P,/usr/lib32" depend
make -DNOMAN -DNODOC -DNOINFO PROG=ld-elf32.so.1 MAKEOBJDIRPREFIX=/tmp/i386 LIBDIR=/usr/lib32 SHLIBDIR=/usr/lib32 MACHINE_ARCH=i386 CC="cc -m32 -I/tmp/i386/root/usr/include -L/usr/lib32 -B/usr/lib32 -DCOMPAT_32BIT" LD="ld -m elf_i386_fbsd -Y P,/usr/lib32"
make -DNOMAN -DNODOC -DNOINFO PROG=ld-elf32.so.1 MAKEOBJDIRPREFIX=/tmp/i386 LIBDIR=/usr/lib32 SHLIBDIR=/usr/lib32 MACHINE_ARCH=i386 CC="cc -m32 -I/tmp/i386/root/usr/include -L/usr/lib32 -B/usr/lib32 -DCOMPAT_32BIT" LD="ld -m elf_i386_fbsd -Y P,/usr/lib32" install

-- 
Peter Wemm - peter at wemm.org; peter at FreeBSD.org; peter at yahoo-inc.com
"All of this is for nothing if we don't go to the stars" - JMS/B5


More information about the freebsd-amd64 mailing list