LLVM 3.2 on Xcode

Following a blend of instructions on 3 web pages, I have succeeded in getting LLVM 3.2 (with clang, extras, and compiler-rt) building - but not testing - on Xcode. I used CMake 2.8.10 GUI to create the Xcode project file. Below are my notes.

First, I believe CMake ends up setting things up so that Xcode has 1 warning after scanning the project having to do with hires images or some such… it takes a long time to fix that up in a project as large as this, but I’m not sure there’s anything we can do about it.
Second, a build of the ALL_BUILD target in Xcode produces 16 warnings about 8 functions declared noreturn, but without a expected __builtin_unreachable() before the end of the function. (The first attempt to build produced 2 errors, the first an unable to create directory error for runtime/libprofile/LLVM.build/Debug/profile_rt-static.build/Objects-normal/x86_64; the second a libtool failure… both went away upon a rebuild.)
Third, a build of the check-all target produced 8 warnings about the 8 functions declared noreturn as for ALL_BUILD, and 6 or 7 “errors”, mostly from asan_mac_test.mm. After fixing up these “errors” (int vs. size_t comparisons and malloc being assigned to volatile pointers), I got 372 duplicate symbol errors from this:

Ld /Volumes/Shared/NewShared/llvm/3.2/xcode/projects/compiler-rt/lib/asan/tests/Debug/AsanTest normal x86_64
cd /Volumes/Shared/NewShared/llvm/3.2/source
setenv MACOSX_DEPLOYMENT_TARGET 10.8
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -L/Volumes/Shared/NewShared/llvm/3.2/xcode/projects/compiler-rt/lib/asan/tests/Debug -F/Volumes/Shared/NewShared/llvm/3.2/xcode/projects/compiler-rt/lib/asan/tests/Debug -filelist /Volumes/Shared/NewShared/llvm/3.2/xcode/projects/compiler-rt/lib/asan/tests/LLVM.build/Debug/AsanTest.build/Objects-normal/x86_64/AsanTest.LinkFileList -mmacosx-version-min=10.8 -framework Foundation -Wl,-search_paths_first -Wl,-headerpad_max_install_names -lpthread /Volumes/Shared/NewShared/llvm/3.2/xcode/lib/Debug/libgtest.a /Volumes/Shared/NewShared/llvm/3.2/xcode/lib/Debug/libgtest_main.a /Volumes/Shared/NewShared/llvm/3.2/xcode/lib/Debug/libLLVMSupport.a /Volumes/Shared/NewShared/llvm/3.2/xcode/lib/clang/3.2/lib/darwin/Debug/libclang_rt.asan_osx.a /Volumes/Shared/NewShared/llvm/3.2/xcode/lib/Debug/libgtest.a /Volumes/Shared/NewShared/llvm/3.2/xcode/lib/Debug/libLLVMSupport.a -lpthread -fobjc-link-runtime /Volumes/Shared/NewShared/llvm/3.2/source/…/xcode/projects/compiler-rt/lib/asan/tests/asan_globals_test.cc.asan.o /Volumes/Shared/NewShared/llvm/3.2/source/…/xcode/projects/compiler-rt/lib/asan/tests/asan_test.cc.asan.o /Volumes/Shared/NewShared/llvm/3.2/source/…/xcode/projects/compiler-rt/lib/asan/tests/asan_mac_test.mm.asan.o -o /Volumes/Shared/NewShared/llvm/3.2/xcode/projects/compiler-rt/lib/asan/tests/Debug/AsanTest

duplicate symbol __Z11GlobalsTesti in:
/Volumes/Shared/NewShared/llvm/3.2/xcode/projects/compiler-rt/lib/asan/tests/LLVM.build/Debug/AsanTest.build/Objects-normal/x86_64/asan_globals_test.o
/Volumes/Shared/NewShared/llvm/3.2/source/…/xcode/projects/compiler-rt/lib/asan/tests/asan_globals_test.cc.asan.o
duplicate symbol _kStartupStr in:
/Volumes/Shared/NewShared/llvm/3.2/xcode/projects/compiler-rt/lib/asan/tests/LLVM.build/Debug/AsanTest.build/Objects-normal/x86_64/asan_mac_test.o
/Volumes/Shared/NewShared/llvm/3.2/source/…/xcode/projects/compiler-rt/lib/asan/tests/asan_mac_test.mm.asan.o
and 370 more…

Those look like the linker is being passed the same .o file built twice, ex:
…/Objects-normal/x86_64/asan_globals_test.o
…/lib/asan/tests/asan_globals_test.cc.asan.o

So, the symbols are colliding. Something is set up wrong in the xcode project.

-Nick

Hi Richard!

Those look like the linker is being passed the same .o file built twice, ex:
…/Objects-normal/x86_64/asan_globals_test.o
…/lib/asan/tests/asan_globals_test.cc.asan.o

So, the symbols are colliding. Something is set up wrong in the xcode project.

-Nick

Following a blend of instructions on 3 web pages, I have succeeded in getting LLVM 3.2 (with clang, extras, and compiler-rt) building - but not testing - on Xcode. I used CMake 2.8.10 GUI to create the Xcode project file. Below are my notes.

First, I believe CMake ends up setting things up so that Xcode has 1 warning after scanning the project having to do with hires images or some such… it takes a long time to fix that up in a project as large as this, but I’m not sure there’s anything we can do about it.
Second, a build of the ALL_BUILD target in Xcode produces 16 warnings about 8 functions declared noreturn, but without a expected __builtin_unreachable() before the end of the function. (The first attempt to build produced 2 errors, the first an unable to create directory error for runtime/libprofile/LLVM.build/Debug/profile_rt-static.build/Objects-normal/x86_64; the second a libtool failure… both went away upon a rebuild.)
Third, a build of the check-all target produced 8 warnings about the 8 functions declared noreturn as for ALL_BUILD, and 6 or 7 “errors”, mostly from asan_mac_test.mm. After fixing up these “errors” (int vs. size_t comparisons and malloc being assigned to volatile pointers), I got 372 duplicate symbol errors from this:

Ld /Volumes/Shared/NewShared/llvm/3.2/xcode/projects/compiler-rt/lib/asan/tests/Debug/AsanTest normal x86_64
cd /Volumes/Shared/NewShared/llvm/3.2/source
setenv MACOSX_DEPLOYMENT_TARGET 10.8
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -L/Volumes/Shared/NewShared/llvm/3.2/xcode/projects/compiler-rt/lib/asan/tests/Debug -F/Volumes/Shared/NewShared/llvm/3.2/xcode/projects/compiler-rt/lib/asan/tests/Debug -filelist /Volumes/Shared/NewShared/llvm/3.2/xcode/projects/compiler-rt/lib/asan/tests/LLVM.build/Debug/AsanTest.build/Objects-normal/x86_64/AsanTest.LinkFileList -mmacosx-version-min=10.8 -framework Foundation -Wl,-search_paths_first -Wl,-headerpad_max_install_names -lpthread /Volumes/Shared/NewShared/llvm/3.2/xcode/lib/Debug/libgtest.a /Volumes/Shared/NewShared/llvm/3.2/xcode/lib/Debug/libgtest_main.a /Volumes/Shared/NewShared/llvm/3.2/xcode/lib/Debug/libLLVMSupport.a /Volumes/Shared/NewShared/llvm/3.2/xcode/lib/clang/3.2/lib/darwin/Debug/libclang_rt.asan_osx.a /Volumes/Shared/NewShared/llvm/3.2/xcode/lib/Debug/libgtest.a /Volumes/Shared/NewShared/llvm/3.2/xcode/lib/Debug/libLLVMSupport.a -lpthread -fobjc-link-runtime /Volumes/Shared/NewShared/llvm/3.2/source/…/xcode/projects/compiler-rt/lib/asan/tests/asan_globals_test.cc.asan.o /Volumes/Shared/NewShared/llvm/3.2/source/…/xcode/projects/compiler-rt/lib/asan/tests/asan_test.cc.asan.o /Volumes/Shared/NewShared/llvm/3.2/source/…/xcode/projects/compiler-rt/lib/asan/tests/asan_mac_test.mm.asan.o -o /Volumes/Shared/NewShared/llvm/3.2/xcode/projects/compiler-rt/lib/asan/tests/Debug/AsanTest

duplicate symbol __Z11GlobalsTesti in:
/Volumes/Shared/NewShared/llvm/3.2/xcode/projects/compiler-rt/lib/asan/tests/LLVM.build/Debug/AsanTest.build/Objects-normal/x86_64/asan_globals_test.o
/Volumes/Shared/NewShared/llvm/3.2/source/…/xcode/projects/compiler-rt/lib/asan/tests/asan_globals_test.cc.asan.o
duplicate symbol _kStartupStr in:
/Volumes/Shared/NewShared/llvm/3.2/xcode/projects/compiler-rt/lib/asan/tests/LLVM.build/Debug/AsanTest.build/Objects-normal/x86_64/asan_mac_test.o
/Volumes/Shared/NewShared/llvm/3.2/source/…/xcode/projects/compiler-rt/lib/asan/tests/asan_mac_test.mm.asan.o
and 370 more…

Recently the way we build ASan unit tests has changed. Could you please check if your XCode build works for the trunk?

Different, but still failing (this time with Xcode 4.4…)

/Users/rrelph/llvm/tot/xcode/bin/Debug/clang sanitizer_allocator_test.cc.i386.o sanitizer_common_test.cc.i386.o sanitizer_flags_test.cc.i386.o sanitizer_libc_test.cc.i386.o sanitizer_list_test.cc.i386.o sanitizer_printf_test.cc.i386.o sanitizer_stackdepot_test.cc.i386.o sanitizer_test_main.cc.i386.o gtest-all.cc.i386.o libRTSanitizerCommon.test.osx.a -o /Users/rrelph/llvm/tot/xcode/projects/compiler-rt/lib/sanitizer_common/tests/Sanitizer-i386-Test -lstdc++ -lpthread -m32
clang: error: no such file or directory: ‘libRTSanitizerCommon.test.osx.a’
make: *** [/Users/rrelph/llvm/tot/xcode/projects/compiler-rt/lib/sanitizer_common/tests/Sanitizer-i386-Test] Error 1
Command /bin/sh failed with exit code 2

Additionally, there are still the 8 functions declared noreturn in asan_report.cc that clang expects to “not return”. These generate 16 warnings during the ALL_BUILD build and 8 more warnings during the check-all build.

Richard

Hi, Richard!