springmeyer / build-llvm

DEPRECATED - Script to build latest llvm, clang, lldb, and include-what-you-use
4 stars 2 forks source link

Linking failing on OS X #2

Open springmeyer opened 8 years ago

springmeyer commented 8 years ago

Hitting:

FAILED: : && /Users/dane/.homebrew/Cellar/cmake/3.5.0/bin/cmake -E remove lib/clang/3.9.0/lib/darwin/libclang_rt.profile_osx.a && /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar qc lib/clang/3.9.0/lib/darwin/libclang_rt.profile_osx.a  projects/compiler-rt/lib/profile/CMakeFiles/clang_rt.profile_osx.dir/GCDAProfiling.c.o projects/compiler-rt/lib/profile/CMakeFiles/clang_rt.profile_osx.dir/InstrProfiling.c.o projects/compiler-rt/lib/profile/CMakeFiles/clang_rt.profile_osx.dir/InstrProfilingValue.c.o projects/compiler-rt/lib/profile/CMakeFiles/clang_rt.profile_osx.dir/InstrProfilingBuffer.c.o projects/compiler-rt/lib/profile/CMakeFiles/clang_rt.profile_osx.dir/InstrProfilingFile.c.o projects/compiler-rt/lib/profile/CMakeFiles/clang_rt.profile_osx.dir/InstrProfilingMerge.c.o projects/compiler-rt/lib/profile/CMakeFiles/clang_rt.profile_osx.dir/InstrProfilingMergeFile.c.o projects/compiler-rt/lib/profile/CMakeFiles/clang_rt.profile_osx.dir/InstrProfilingWriter.c.o projects/compiler-rt/lib/profile/CMakeFiles/clang_rt.profile_osx.dir/InstrProfilingPlatformDarwin.c.o projects/compiler-rt/lib/profile/CMakeFiles/clang_rt.profile_osx.dir/InstrProfilingPlatformLinux.c.o projects/compiler-rt/lib/profile/CMakeFiles/clang_rt.profile_osx.dir/InstrProfilingPlatformOther.c.o projects/compiler-rt/lib/profile/CMakeFiles/clang_rt.profile_osx.dir/InstrProfilingRuntime.cc.o projects/compiler-rt/lib/profile/CMakeFiles/clang_rt.profile_osx.dir/InstrProfilingUtil.c.o && /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib lib/clang/3.9.0/lib/darwin/libclang_rt.profile_osx.a && :
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: library member: lib/clang/3.9.0/lib/darwin/libclang_rt.profile_osx.a(InstrProfilingRuntime.cc.o) is not an object file (not allowed in a library with multiple architectures)
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: library member: lib/clang/3.9.0/lib/darwin/libclang_rt.profile_osx.a(InstrProfilingRuntime.cc.o) is not an object file (not allowed in a library with multiple architectures)
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: library member: lib/clang/3.9.0/lib/darwin/libclang_rt.profile_osx.a(InstrProfilingRuntime.cc.o) is not an object file (not allowed in a library with multiple architectures)
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar: internal ranlib command failed
[56/3732] Building CXX object projects/compiler-rt/lib/asan/CMakeFiles/RTAsan_dynamic.osx.dir/asan_interceptors.cc.o
ninja: build stopped: subcommand failed.

From a clean rebuild:

[1270/3737] Linking CXX static library lib/clang/3.9.0/lib/darwin/libclang_rt.profile_osx.a
FAILED: : && /Users/dane/.homebrew/Cellar/cmake/3.5.0/bin/cmake -E remove lib/clang/3.9.0/lib/darwin/libclang_rt.profile_osx.a && /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar qc lib/clang/3.9.0/lib/darwin/libclang_rt.profile_osx.a  projects/compiler-rt/lib/profile/CMakeFiles/clang_rt.profile_osx.dir/GCDAProfiling.c.o projects/compiler-rt/lib/profile/CMakeFiles/clang_rt.profile_osx.dir/InstrProfiling.c.o projects/compiler-rt/lib/profile/CMakeFiles/clang_rt.profile_osx.dir/InstrProfilingValue.c.o projects/compiler-rt/lib/profile/CMakeFiles/clang_rt.profile_osx.dir/InstrProfilingBuffer.c.o projects/compiler-rt/lib/profile/CMakeFiles/clang_rt.profile_osx.dir/InstrProfilingFile.c.o projects/compiler-rt/lib/profile/CMakeFiles/clang_rt.profile_osx.dir/InstrProfilingMerge.c.o projects/compiler-rt/lib/profile/CMakeFiles/clang_rt.profile_osx.dir/InstrProfilingMergeFile.c.o projects/compiler-rt/lib/profile/CMakeFiles/clang_rt.profile_osx.dir/InstrProfilingWriter.c.o projects/compiler-rt/lib/profile/CMakeFiles/clang_rt.profile_osx.dir/InstrProfilingPlatformDarwin.c.o projects/compiler-rt/lib/profile/CMakeFiles/clang_rt.profile_osx.dir/InstrProfilingPlatformLinux.c.o projects/compiler-rt/lib/profile/CMakeFiles/clang_rt.profile_osx.dir/InstrProfilingPlatformOther.c.o projects/compiler-rt/lib/profile/CMakeFiles/clang_rt.profile_osx.dir/InstrProfilingRuntime.cc.o projects/compiler-rt/lib/profile/CMakeFiles/clang_rt.profile_osx.dir/InstrProfilingUtil.c.o && /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib lib/clang/3.9.0/lib/darwin/libclang_rt.profile_osx.a && :
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: library member: lib/clang/3.9.0/lib/darwin/libclang_rt.profile_osx.a(InstrProfilingRuntime.cc.o) is not an object file (not allowed in a library with multiple architectures)
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: library member: lib/clang/3.9.0/lib/darwin/libclang_rt.profile_osx.a(InstrProfilingRuntime.cc.o) is not an object file (not allowed in a library with multiple architectures)
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: library member: lib/clang/3.9.0/lib/darwin/libclang_rt.profile_osx.a(InstrProfilingRuntime.cc.o) is not an object file (not allowed in a library with multiple architectures)
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar: internal ranlib command failed
[1270/3737] Linking CXX executable bin/llvm-tblgen
ninja: build stopped: subcommand failed.
springmeyer commented 8 years ago

Narrowed this down. It happens when -flto is added to the compile flags for compiling InstrProfilingRuntime.cc. I had been doing:

       export CXXFLAGS="-O3 -flto"
       export LDFLAGS="-flto"

before building with cmake.

refs https://llvm.org/bugs/show_bug.cgi?id=26963