[Flac-dev] flac/metaflac 32/64 Universal OS X builds

Stephen F. Booth me at sbooth.org
Mon May 5 21:25:28 PDT 2008


> From your steps, it seems that it is possible to cross-compile, but
> only if you build one architecture at a time and then manually lipo
> them together.  If I someday find an easy fix for this, I'll let you
> know.  Then again, Stephen may have figured out the magic incantation
> for Xcode to make this work as simply as it should.

I always have difficulty getting cross-compiling to work from the  
command line as well.  It seems that setting --host, --build, and -- 
target don't cause the correct compiler to get picked up automatically  
as I feel they should (and the configure/autoconf docs state).  For  
example, the following should let me cross-compile for PowerPC on my  
i686 Mac:

% ./configure --disable-shared --disable-asm-optimizations --disable- 
ogg --host=ppc-apple-darwin9 --target=powerpc-apple-darwin9 -- 
build=i686-apple-darwin9

But the reality is that configure can't find the powerpc compiler, as  
on my system I have two gcc versions:  powerpc-apple-darwin9-gcc-4.0.1  
and powerpc-apple-darwin9-gcc-4.2.1.  configure only looks for powerpc- 
apple-darwin9-gcc and variants, and it ends up using plain gcc which  
obviously isn't a cross compiler.

Setting the CC environment variable manually does get things working:

% CC=powerpc-apple-darwin9-gcc-4.0.1  ./configure --disable-shared -- 
disable-asm-optimizations --disable-ogg --host=ppc-apple-darwin9 -- 
target=powerpc-apple-darwin9 --build=i686-apple-darwin9

Of course, that doesn't take care of PPC64.  So rather than repeat  
this process for all four architectures, I just created one Xcode  
project with targets for everything I needed, and architectures set  
appropriately for Release and Debug builds.  I suppose one could take  
the alternate tack and just write a bash script to automate the  
generation of each architecture and then lipo that output together.

> So, tell me, Erik: Can you build for Intel on PPC?  Can you build for
> PPC on Intel?  If you're willing to do the manual lipo steps, is that
> all you need to do to make a UB? ... or do you actually need both an
> Intel Mac and a PowerPC Mac?

I have also run into similar issues as the one Erik reports.   
Invariably it seems to come down to the WORDS_BIGENDIAN macro.  I  
typically settle this problem by hand editing an automatically- 
generated config.h with the following:

#if __BIG_ENDIAN__
#define WORDS_BIGENDIAN 1
#endif

thus the same config.h (on OS X) will work for any architecture.

Anyhow, this is getting extremely off-topic for the list so I apologize.

Stephen

PS The amusing thing to me about all of this is that the gcc Apple  
ships is itself cross-compiled:

% gcc -v -help
Using built-in specs.
Target: i686-apple-darwin9
Configured with: /var/tmp/gcc/gcc-5480~3/src/configure --disable- 
checking -enable-werror --prefix=/usr --mandir=/share/man --enable- 
languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/ 
$/-4.0/ --with-gxx-include-dir=/include/c++/4.0.0 --with-slibdir=/usr/ 
lib --build=powerpc-apple-darwin9 --with-arch=apple --with- 
tune=generic --program-prefix= --host=i686-apple-darwin9 --target=i686- 
apple-darwin9
Thread model: posix
gcc version 4.0.1 (Apple Inc. build 5480)



More information about the Flac-dev mailing list