static fat libclang library for iOS (device & simulator)

Hallo all,

I’m trying to build libclang as a fat static library for iOS (device & simulator), but I’m still facing several problems. Here’s my build script under development:

  1. iPhone Simulator

I managed to build static libclang for iPhone Simulator (i386-apple-darwin). But even when I use --enable-shared=no it produces libclang.a, which depends on other llvm:: … functions. Temporary solution was to add all produced .a libraries to my project (better solution later). But when I call clang_parseTranslationUnit it stops working, because it shows a warning that some symbols are not available on iPhone Simulator (didn’t tell me which one).

  1. iOS Device

Here I’m not able to compile it for armv7-apple-darwin and it always produces x86_64 builds. It always switches target to i686-apple-darwin11.

Is there anyone who managed to build static fat libclang library for iOS without any other dependencies (= everything needed is inside this library) and this library is suitable for both i386 & armv7.

Why I’m doing this? We’re working on editor for iPad and we do want to use libclang for syntax highlighting only. We just want to test how it behaves on iPad, how fast it is, etc.

I can fix iPhone Simulator issues I’ve got by myself, but this cross compilation is kind of hell with this beast.

Many thanks in advance for any help to get this library ready,

Here’s the configure log output, which says that it’s going to use i686, thus not cross compiling …


Core tests.


configure:1973: checking for armv7-apple-darwin-clang
configure:2000: result: /Applications/
configure:2080: checking for C compiler version
configure:2087: /Applications/ --version >&5
i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO

configure:2090: $? = 0
configure:2097: /Applications/ -v >&5
Using built-in specs.
Target: i686-apple-darwin11
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.11~36/src/configure --disable-checking --enable-werror --prefix=/Applications/ --mandir=/share/man --enable-languages=c,objc
,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2336.11~36/dst-llvmCore/Developer/usr/lo
cal --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
configure:2100: $? = 0
configure:2107: /Applications/ -V >&5
llvm-gcc-4.2: argument to `-V’ is missing
configure:2110: $? = 1
configure:2133: checking for C compiler default output file name
configure:2160: /Applications/ conftest.c >&5
configure:2163: $? = 0
configure:2209: result: a.out
configure:2214: checking whether the C compiler works
configure:2224: ./a.out
configure:2227: $? = 0
configure:2244: result: yes
configure:2251: checking whether we are cross compiling
configure:2253: result: no

I can fix iPhone Simulator issues I’ve got by myself, but this cross compilation is kind of hell with this beast.

Hmm, I managed to build it in this way …

cmake -G Xcode …/llvm
xcodebuild -sdk iphoneos -arch armv7 -project LLVM.xcodeproj -target libclang_static

… but I swear it wasn’t working for the whole day. Maybe my configure & make fixes something for xcodebuild. Will try again with clean checkout.