LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 12918 - Regression(r157062 ): compiler-rt build on mac is broken due to armv6 changes
Summary: Regression(r157062 ): compiler-rt build on mac is broken due to armv6 changes
Status: RESOLVED FIXED
Alias: None
Product: compiler-rt
Classification: Unclassified
Component: compiler-rt (show other bugs)
Version: unspecified
Hardware: PC MacOS X
: P normal
Assignee: Jim Grosbach
URL:
Keywords:
: 12950 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-05-23 06:40 PDT by Alexander Potapenko
Modified: 2012-06-15 00:16 PDT (History)
7 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Potapenko 2012-05-23 06:40:27 PDT
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)
Comment 1 Alexander Potapenko 2012-05-23 06:46:11 PDT
$ /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
Comment 2 Alexander Potapenko 2012-05-23 07:40:51 PDT
Looks like r157062 has introduced the new LCT_DataInCode load command (=0x29) which is not supported by older toolchains.
Comment 3 Nico Weber 2012-05-25 17:16:33 PDT
*** Bug 12950 has been marked as a duplicate of this bug. ***
Comment 4 Charles Davis 2012-05-25 21:58:20 PDT
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.
Comment 5 Nico Weber 2012-05-28 10:48:18 PDT
grosbach: Can you comment if you intend to fix this, or is a prerelease ar now required to build clang on os x?
Comment 6 Jim Grosbach 2012-05-30 11:55:37 PDT
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).
Comment 7 Nico Weber 2012-05-30 12:20:53 PDT
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.)
Comment 8 Alexander Potapenko 2012-05-31 07:25:01 PDT
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)
Comment 9 Timur Iskhodzhanov 2012-06-07 07:00:41 PDT
FTR, the easy workaround is:
../configure --enable-optimized --enable-targets=host-only
Comment 10 Nico Weber 2012-06-10 11:12:14 PDT
Yes, but that breaks cross-compilation completely and doesn't just remove iOS. (I use that for the stage 1 build.)
Comment 11 Nico Weber 2012-06-15 00:16:36 PDT
r158466