[LLVMdev] [PATCH] Cross-compiling LLVM on Mac OS X?

Graham Wakefield wakefield at mat.ucsb.edu
Tue Feb 16 14:54:10 PST 2010


Sorry to resurrect an ancient thread, but...

For our application we need to build llvm libraries on OSX as  
universal ppc/i386 binaries, against the 10.4 SDK, using the 2.6  
stable release of LLVM.

I've followed the comments that people have made previously, including  
Rob Rix's makefile patch and the following command line incantations,  
but the build is failing:

#configure:
sudo make clean
export MACOSX_DEPLOYMENT_TARGET=10.4
export UNIVERSAL=true
export UNIVERSAL_ARCH="i386 ppc"
export UNIVERSAL_SDK_PATH=/Developer/SDKs/MacOSX10.4u.sdk/
export CFLAGS="-mmacosx-version-min=10.4"
export CXXFLAGS="-mmacosx-version-min=10.4"
./configure --enable-optimized --enable-jit --enable-targets=x86,powerpc

# modifications to config.h for 10.4:
edit include/llvm/Config/config.h
# comment out HAVE_BACKTRACE 1
# comment out HAVE_EXECINFO_H 1

#make:
export MACOSX_DEPLOYMENT_TARGET=10.4
export UNIVERSAL=true
export UNIVERSAL_ARCH="i386 ppc"
export UNIVERSAL_SDK_PATH=/Developer/SDKs/MacOSX10.4u.sdk/
export CFLAGS="-mmacosx-version-min=10.4"
export CXXFLAGS="-mmacosx-version-min=10.4"
make libs-only

The error is as follows:

llvm[2]: Compiling TableGenBackend.cpp for Release build
g++ -I/Users/grahamwakefield/Source/llvm-2.6_ub/include -I/Users/ 
grahamwakefield/Source/llvm-2.6_ub/utils/TableGen  -D_DEBUG - 
D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -O3  -fno- 
common -Woverloaded-virtual -mmacosx-version-min=10.4  -mmacosx- 
version-min=10.4 -pedantic -Wno-long-long -Wall -W -Wno-unused- 
parameter -Wwrite-strings  -arch i386 -arch ppc -isysroot /Developer/ 
SDKs/MacOSX10.4u.sdk/ -c TableGenBackend.cpp -o /Users/grahamwakefield/ 
Source/llvm-2.6_ub/utils/TableGen/Release/TableGenBackend.o
llvm[2]: Linking Release executable tblgen (without symbols)
ld: library not found for -lffi
collect2: ld returned 1 exit status
ld: library not found for -lffi
collect2: ld returned 1 exit status
lipo: can't open input file: /var/folders/O+/O+BZljw+HB8GMWwKGSQWs+++ 
+TI/-Tmp-//cczAl73O.out (No such file or directory)
make[2]: *** [/Users/grahamwakefield/Source/llvm-2.6_ub/Release/bin/ 
tblgen] Error 1
make[1]: *** [TableGen/.makeall] Error 2
make: *** [all] Error 1

I thought that it meant that I need a universal libffi, but the  
libffi.dylib I have in /usr/lib is a fat binary (according to file).

Any suggestions for what to try next would be very much appreciated!

On Dec 22, 2009, at 2:19 PM, Rob Rix wrote:

>>> Daniel's comments are also good.
>>
>> …success!
>
>
> Looks like I spoke a bit too soon. Everything works as far as the  
> fat binaries are concerned, except that -mmacosx-version-min is set  
> to the host’s OS version, not that of the SDK, causing errors when  
> it tries to link against 10.6’s versions of libraries instead of  
> 10.5’s.
>
> This patch appears to solve that; it uses the OS version from the  
> SDK path for -mmacosx-version-min if UNIVERSAL_SDK_PATH is specified.
>
> <Makefile.rules.patch>
>
> --
> Rob Rix, Unknown Quantity
> Monochrome Industries
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev





More information about the llvm-dev mailing list