Job makes me drown in work, so I'll write down info there for the time
being.
Compilation wise, there are two ways to create universal binaries:
1. create .o for -arch A, then for -arch B, then fatten with lipo(1)
or
2. use -arch A -arch B on gcc, both at once
While 2. sounds great because it potentially allows for packages to be
built for arch A and B at once, it is only valid for "dumb" binary
object compilation. As soon as you use things like configure, things
start to fall apart. You see, configure compiles and run little
programs to evaluate host capacities. This grandiosly fails in our
case, because for i386/x86_64 it will compile two-arches at once, but
run only one. And you see, configure evaluates things like int/long
sizes, pointer lengths and so on. Imagine for a second what a program
will do if it's compiled with constants assuming 64bit and run on
32bit.
Core dump, at best. Silent corruption at worst.
It gets worse as sometimes this manifests only in packages depending
on other packages broken by this.
What's more some packages have custom build systems, a few being
particularly convoluted, and have a hard time managing to pass
multiple -arch flags at all. configure itself generally needs to be
run with --disable-dependency-tracking, requiring quite some patches
to each and every PKGBUILDs.
Besides, packages like openssl or perl run test suites, which would of
course be executed only for one arch if built with multiple arches.
So, 2. is really too much trouble. The only way out is 1.
To implement this we have multiple solutions:
1. have separate packages, thus separate repos and git trees for i386
and x86_64. Not good IMHO, community will be fragmented, and packages
won't match.
2. change build() of each PKGBUILD to configure/build/install each
arch, then merge binaries with lipo. This is what I've done for
openssl (see below), but is really cumbersome.
3. have a tool that takes two (or more, think ppc) built packages and
output a single one where binaries are merged. Then have a tool that
runs makepkg once for each arch then and run the previous tool to
merge.
4. enhance/extend makepkg to call build for each arch, then merge
binaries. Ideal, we could use PKGBUILD as is.
my PoV:
1. sounds really bad
2. too much work, especially with recent discussions WRT keeping in
sync with archlinux
3. sounds like a simple approach
4. really sounds the best, but I don't know if/how makepkg is
extendable. ask upstream?
For the record, binaries are easy to find:
find . | grep Mach-O
I also have a script that tells if an installed package has non-
universal binaries, and if no argument given, lists all installed
packages that have one that is not universal.
example universal build() for openssl:
build() {
cd $srcdir/$pkgname-$pkgver
patch -p1 -i $srcdir/openssl-0.9.8j-fix_manpages-1.patch || return 1
# manual universal build
arches="i386 x86_64"
binaries="bin/openssl lib/engines/lib4758cca.so lib/engines/
libaep.so lib/engines/libatalla.so lib/engines/libcapi.so lib/engines/
libchil.so lib/engines/libcswift.so lib/engines/libgmp.so lib/engines/
libnuron.so lib/engines/libsureware.so lib/engines/libubsec.so lib/
libcrypto.0.9.8.dylib lib/libcrypto.a lib/libcrypto.dylib lib/libssl.
0.9.8.dylib lib/libssl.a lib/libssl.dylib"
original_cflags="$CFLAGS"
original_ldflags="$LDFLAGS"
for arch in $arches; do
echo "building $arch"
make clean
CFLAGS="-arch $arch $(echo $original_cflags | sed 's^-arch [a-
z0-9_][a-z0-9_]*^^g')"
LDFLAGS="-arch $arch $(echo $original_ldflags | sed 's^-arch
[a-z0-9_][a-z0-9_]*^^g')"
CC="gcc -arch $arch"
configuration="--prefix=/opt/arch --openssldir=/opt/arch/etc/ssl
shared zlib"
case "$arch" in
"i386")
./Configure $configuration darwin-i386-cc
;;
"x86_64")
./Configure $configuration darwin64-x86_64-cc
;;
esac
make || return 1
make test || return 1
mkdir -p $startdir/src/build/$arch
make INSTALL_PREFIX=$startdir/src/build/$arch MANDIR=/opt/arch/
share/man install
done
make INSTALL_PREFIX=$pkgdir MANDIR=/opt/arch/share/man install
echo "making universal binaries"
for binary in $binaries; do
rm $startdir/pkg/opt/arch/$binary
lipo -create $startdir/src/build/*/opt/arch/$binary -output
$startdir/pkg/opt/arch/$binary
done
sed -i~ -e 's^EX_LIBS= *-lz^EX_LIBS= -L/opt/arch/lib -lz^g'
Makefile
install -D -m644 LICENSE $pkgdir/opt/arch/share/licenses/$pkgname/
LICENSE
}
On Jul 20, 12:49 am, Loic Nageleisen <
loic.nagelei...@gmail.com>
wrote: