universal binaries seems difficult

Ryan Schmidt ryandesign at macports.org
Thu Aug 9 13:54:05 PDT 2007


On Aug 9, 2007, at 07:35, Bengt Nilsson wrote:

> Creating portfiles/Makefiles for universal binary builds seems not  
> so easy.

The problem is you are using a minus sign when you need to use a plus  
sign. The minus sign *deselects* a variant, while the plus sign  
selects it. You want "sudo port install zlib +universal" (to select  
the universal variant) rather than "sudo port install zlib - 
universal" (which deselects the universal variant, which has no  
effect, because the universal variant is deselected by default).


> Example:
>
> port install zlib -universal
> produces a fat ppc/i386 library on a ppc machine, while it produces  
> non-fat i386 library on an intel platform.

zlib builds just fine universal on my MacBook Pro (if you say  
+universal instead of -universal).

$ port installed zlib
The following ports are currently installed:
   zlib @1.2.3_1+universal (active)
$ file /opt/local/lib/libz.1.2.3.dylib
/opt/local/lib/libz.1.2.3.dylib: Mach-O universal binary with 2  
architectures
/opt/local/lib/libz.1.2.3.dylib (for architecture i386):        Mach- 
O dynamically linked shared library i386
/opt/local/lib/libz.1.2.3.dylib (for architecture ppc): Mach-O  
dynamically linked shared library ppc
$ uname -a
Darwin seven.local 8.10.1 Darwin Kernel Version 8.10.1: Wed May 23  
16:33:00 PDT 2007; root:xnu-792.22.5~1/RELEASE_I386 i386 i386
$


> port install freetype -universal
> produces non-fat i386 libraries on an intel mac, while the  
> installation stops with errors on a ppc mac.

I have a report from you and one other individual that universal  
installation of freetype did not work on a PowerPC. I have other  
reports that universal installation of freetype does work on PowerPC.  
It does work for me on Intel:

$ port installed freetype
The following ports are currently installed:
   freetype @2.3.5_0+doc+universal (active)
$ file /opt/local/lib/libfreetype.6.3.16.dylib
/opt/local/lib/libfreetype.6.3.16.dylib: Mach-O universal binary with  
2 architectures
/opt/local/lib/libfreetype.6.3.16.dylib (for architecture  
i386):        Mach-O dynamically linked shared library i386
/opt/local/lib/libfreetype.6.3.16.dylib (for architecture ppc): Mach- 
O dynamically linked shared library ppc
$

Of course, freetype depends on zlib, so if you have not built the  
zlib port universal, then you will not be able to build the freetype  
port universal either.


> port install rxvt -universal
> produces a non-fat i386 executable on an intel mac and a non-fat  
> ppc executable on a ppc mac.

I'm not familiar with rxvt, but it seems to build universal just  
fine. rxvt depends on freetype, so you will need freetype and its  
dependencies (zlib) built universal first.

$ sudo port install rxvt +universal
Password:
--->  Fetching rxvt
--->  Attempting to fetch rxvt-2.7.10.tar.gz from http:// 
downloads.sourceforge.net/rxvt
--->  Verifying checksum(s) for rxvt
--->  Extracting rxvt
--->  Configuring rxvt
--->  Building rxvt with target all
--->  Staging rxvt into destroot
--->  Installing rxvt 2.7.10_1+universal
--->  Activating rxvt 2.7.10_1+universal
--->  Cleaning rxvt
$ port contents rxvt
Port rxvt contains:
   /opt/local/bin/rclock
   /opt/local/bin/rxvt
   /opt/local/bin/rxvt-2.7.10
   /opt/local/share/man/man1/rclock.1.gz
   /opt/local/share/man/man1/rxvt.1.gz
$ file /opt/local/bin/rclock
/opt/local/bin/rclock: Mach-O universal binary with 2 architectures
/opt/local/bin/rclock (for architecture i386):  Mach-O executable i386
/opt/local/bin/rclock (for architecture ppc):   Mach-O executable ppc
$ file /opt/local/bin/rxvt
/opt/local/bin/rxvt: Mach-O universal binary with 2 architectures
/opt/local/bin/rxvt (for architecture i386):    Mach-O executable i386
/opt/local/bin/rxvt (for architecture ppc):     Mach-O executable ppc
$


> Is this the rule, that the MacPort -universal directive is ignored  
> or has unpredictable results for most ports?

The universal variant is made available to all ports. It should work  
with many of them. It will fail for many others. For each port where  
it fails, the port will need to be fixed. This is in the FAQ:

http://trac.macosforge.org/projects/macports/wiki/ 
FAQ#IsMacPortsUniversal





More information about the macports-users mailing list