I'm building compiler-rt for AddressSanitizer according to http://code.google.com/p/address-sanitizer/wiki/HowToBuild The following command fails when running make: ARCHIVE: clang_darwin/ios/armv6: /Users/buildbot/src/llvm-buildbot/slave/mac10.6/build/llvm-build/tools/clang/runtime/compiler-rt/clang_darwin/ios/armv6/libcompiler_rt.a make[5]: *** [/Users/buildbot/src/llvm-buildbot/slave/mac10.6/build/llvm-build/tools/clang/runtime/compiler-rt/clang_darwin/ios/armv6/libcompiler_rt.a] Error 1 Setting VERBOSE=1 prints the failing command: ar cru /Users/glider/src/asan/llvm/build/tools/clang/runtime/compiler-rt/clang_darwin/ios/armv6/libcompiler_rt.a /Users/glider/src/asan/llvm/build/tools/clang/runtime/compiler-rt/clang_darwin/ios/armv6/SubDir.lib__arm/divmodsi4.o /Users/glider/src/asan/llvm/build/tools/clang/runtime/compiler-rt/clang_darwin/ios/armv6/SubDir.lib/int_util.o /Users/glider/src/asan/llvm/build/tools/clang/runtime/compiler-rt/clang_darwin/ios/armv6/SubDir.lib/mulodi4.o /Users/glider/src/asan/llvm/build/tools/clang/runtime/compiler-rt/clang_darwin/ios/armv6/SubDir.lib/mulosi4.o /Users/glider/src/asan/llvm/build/tools/clang/runtime/compiler-rt/clang_darwin/ios/armv6/SubDir.lib/muloti4.o /Users/glider/src/asan/llvm/build/tools/clang/runtime/compiler-rt/clang_darwin/ios/armv6/SubDir.lib__arm/restore_vfp_d8_d15_regs.o /Users/glider/src/asan/llvm/build/tools/clang/runtime/compiler-rt/clang_darwin/ios/armv6/SubDir.lib__arm/save_vfp_d8_d15_regs.o /Users/glider/src/asan/llvm/build/tools/clang/runtime/compiler-rt/clang_darwin/ios/armv6/SubDir.lib__arm/switch16.o /Users/glider/src/asan/llvm/build/tools/clang/runtime/compiler-rt/clang_darwin/ios/armv6/SubDir.lib__arm/switch32.o /Users/glider/src/asan/llvm/build/tools/clang/runtime/compiler-rt/clang_darwin/ios/armv6/SubDir.lib__arm/switch8.o /Users/glider/src/asan/llvm/build/tools/clang/runtime/compiler-rt/clang_darwin/ios/armv6/SubDir.lib__arm/switchu8.o /Users/glider/src/asan/llvm/build/tools/clang/runtime/compiler-rt/clang_darwin/ios/armv6/SubDir.lib__arm/sync_synchronize.o /Users/glider/src/asan/llvm/build/tools/clang/runtime/compiler-rt/clang_darwin/ios/armv6/SubDir.lib__arm/udivmodsi4.o , which results in: /usr/bin/ranlib: object: /Users/glider/src/asan/llvm/build/tools/clang/runtime/compiler-rt/clang_darwin/ios/armv6/libcompiler_rt.a(int_util.o) malformed object (unknown load command 1)
$ /Users/glider/src/asan/llvm/build/Release+Asserts/bin/clang -arch armv6 -fvisibility=hidden -DVISIBILITY_HIDDEN -Wall -Werror -O3 -fomit-frame-pointer -miphoneos-version-min=1.0 -isysroot /Users/glider/src/asan/llvm/projects/compiler-rt/SDKs/darwin -c -fPIC -o /Users/glider/src/asan/llvm/build/tools/clang/runtime/compiler-rt/clang_darwin/ios/armv6/SubDir.lib/int_util.o /Users/glider/src/asan/llvm/projects/compiler-rt/lib/int_util.c && otool -l /Users/glider/src/asan/llvm/build/tools/clang/runtime/compiler-rt/clang_darwin/ios/armv6/SubDir.lib/int_util.o 2>&1 | grep Unknown cmd ?(0x00000029) Unknown load command
Looks like r157062 has introduced the new LCT_DataInCode load command (=0x29) which is not supported by older toolchains.
*** Bug 12950 has been marked as a duplicate of this bug. ***
You can get around this fairly easily--for certain definitions of "easy" :). Go to opensource.apple.com and get the source to the cctools project from any Xcode version >= 4.3. We're going to build our own ar and ranlib. After unpacking the tarball, chdir into <cctools>/libstuff and build the libstuff library with make. Then, chdir to ../misc and make libtool.NEW. Execute these commands when the build finishes: $ sudo install -c -m 0755 libtool.NEW /usr/local/bin/libtool $ sudo ln -s libtool /usr/local/bin/ranlib # ranlib is a symlink to libtool Finally, chdir to ../ar and make ar.NEW. When that's done, install ar.NEW to /usr/local/bin like so: $ sudo install -c -m 0755 ar.NEW /usr/local/bin/ar This should fix the issue you're seeing. It did for me.
grosbach: Can you comment if you intend to fix this, or is a prerelease ar now required to build clang on os x?
Yes, the data in code load command requires very recent cctools+ld64. However, why is clang trying to build anything for iOS outside of an Apple internal build environment? That shouldn't be happening (this is a good example of why).
compiler-rt is built for OS X and iOS by default. I don't know if that's intentional (ddunbar?), but I guess it makes sense since one might want to use the mac clang to build iOS apps. (I could do without that, but I don't want to use a non-default compiler-rt build config.)
For the record, I had to pass additional options in order to build ar and libtool with Xcode 4.2: $ make LTO= TRIE= -j8 -k (there was also a linktime error in lipo.NEW, so I had to pass -k)
FTR, the easy workaround is: ../configure --enable-optimized --enable-targets=host-only
Yes, but that breaks cross-compilation completely and doesn't just remove iOS. (I use that for the stage 1 build.)
r158466