<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - ubsan fails to link on x86_64-darwin11 due to symbol linkage in /usr/lib/libc++abi.dylib"
   href="https://llvm.org/bugs/show_bug.cgi?id=25950">25950</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>ubsan fails to link on x86_64-darwin11 due to symbol linkage in /usr/lib/libc++abi.dylib
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>compiler-rt
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.7
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Macintosh
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>MacOS X
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>compiler-rt
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>fang@csl.cornell.edu
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>in a cmake stage1 bootstrap of clang-3.7.0 using Xcode 4.6.2 on darwin11,
linking ubsan fails with:

make[2]: Entering directory '/sw/src/fink.build/llvm37-3.7.0-3/build/stage1'
Linking CXX shared library
../../../../lib/clang/3.7.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib
cd /sw/src/fink.build/llvm37-3.7.0-3/build/stage1/projects/compiler-rt/lib/asan
&& /sw/bin/cmake -E cmake_link_script
CMakeFiles/clang_rt.asan_osx_dynamic.dir/link.txt --verbose=1
/sw/src/fink.build/llvm37-3.7.0-3/opt-bin/ccclang++  -fno-common     -std=c++11
-stdlib=libc++ -fPIC -fvisibility-inlines-hidden -Wall -std=c++11 -arch x86_64
-arch i386 -dynamiclib -Wl,-headerpad_max_install_names 
-mmacosx-version-min=10.9 -stdlib=libc++ -lc++ -lc++abi -isysroot
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk
 -L/sw/lib -o
../../../../lib/clang/3.7.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib
-install_name @rpath/libclang_rt.asan_osx_dynamic.dylib
CMakeFiles/RTAsan.osx.dir/asan_allocator.cc.o
CMakeFiles/RTAsan.osx.dir/asan_activation.cc.o
CMakeFiles/RTAsan.osx.dir/asan_debugging.cc.o
CMakeFiles/RTAsan.osx.dir/asan_fake_stack.cc.o
CMakeFiles/RTAsan.osx.dir/asan_flags.cc.o
CMakeFiles/RTAsan.osx.dir/asan_globals.cc.o
CMakeFiles/RTAsan.osx.dir/asan_interceptors.cc.o
CMakeFiles/RTAsan.osx.dir/asan_linux.cc.o
CMakeFiles/RTAsan.osx.dir/asan_mac.cc.o
CMakeFiles/RTAsan.osx.dir/asan_malloc_linux.cc.o
CMakeFiles/RTAsan.osx.dir/asan_malloc_mac.cc.o
CMakeFiles/RTAsan.osx.dir/asan_malloc_win.cc.o
CMakeFiles/RTAsan.osx.dir/asan_poisoning.cc.o
CMakeFiles/RTAsan.osx.dir/asan_posix.cc.o
CMakeFiles/RTAsan.osx.dir/asan_report.cc.o
CMakeFiles/RTAsan.osx.dir/asan_rtl.cc.o
CMakeFiles/RTAsan.osx.dir/asan_stack.cc.o
CMakeFiles/RTAsan.osx.dir/asan_stats.cc.o
CMakeFiles/RTAsan.osx.dir/asan_suppressions.cc.o
CMakeFiles/RTAsan.osx.dir/asan_thread.cc.o
CMakeFiles/RTAsan.osx.dir/asan_win.cc.o
CMakeFiles/RTAsan.osx.dir/asan_new_delete.cc.o
../interception/CMakeFiles/RTInterception.osx.dir/interception_linux.cc.o
../interception/CMakeFiles/RTInterception.osx.dir/interception_mac.cc.o
../interception/CMakeFiles/RTInterception.osx.dir/interception_win.cc.o
../interception/CMakeFiles/RTInterception.osx.dir/interception_type_test.cc.o
../sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_allocator.cc.o
../sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_common.cc.o
../sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_deadlock_detector1.cc.o
../sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_deadlock_detector2.cc.o
../sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_flags.cc.o
../sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_flag_parser.cc.o
../sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_libc.cc.o
../sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_libignore.cc.o
../sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_linux.cc.o
../sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_mac.cc.o
../sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_persistent_allocator.cc.o
../sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_platform_limits_linux.cc.o
../sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_platform_limits_posix.cc.o
../sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_posix.cc.o
../sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_printf.cc.o
../sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_procmaps_common.cc.o
../sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_procmaps_freebsd.cc.o
../sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_procmaps_linux.cc.o
../sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_procmaps_mac.cc.o
../sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_stackdepot.cc.o
../sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_stacktrace.cc.o
../sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_stacktrace_printer.cc.o
../sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_suppressions.cc.o
../sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_symbolizer.cc.o
../sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_symbolizer_libbacktrace.cc.o
../sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_symbolizer_mac.cc.o
../sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_symbolizer_win.cc.o
../sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_tls_get_addr.cc.o
../sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_thread_registry.cc.o
../sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_win.cc.o
../sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_common_libcdep.cc.o
../sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_coverage_libcdep.cc.o
../sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_coverage_mapping_libcdep.cc.o
../sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_linux_libcdep.cc.o
../sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_posix_libcdep.cc.o
../sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_stacktrace_libcdep.cc.o
../sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_stoptheworld_linux_libcdep.cc.o
../sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_symbolizer_libcdep.cc.o
../sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_symbolizer_posix_libcdep.cc.o
../sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_symbolizer_process_libcdep.cc.o
../sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_unwind_linux_libcdep.cc.o
../lsan/CMakeFiles/RTLSanCommon.osx.dir/lsan_common.cc.o
../lsan/CMakeFiles/RTLSanCommon.osx.dir/lsan_common_linux.cc.o
../ubsan/CMakeFiles/RTUbsan.osx.dir/ubsan_diag.cc.o
../ubsan/CMakeFiles/RTUbsan.osx.dir/ubsan_init.cc.o
../ubsan/CMakeFiles/RTUbsan.osx.dir/ubsan_flags.cc.o
../ubsan/CMakeFiles/RTUbsan.osx.dir/ubsan_handlers.cc.o
../ubsan/CMakeFiles/RTUbsan.osx.dir/ubsan_value.cc.o
../ubsan/CMakeFiles/RTUbsan.osx.dir/ubsan_handlers_cxx.cc.o
../ubsan/CMakeFiles/RTUbsan.osx.dir/ubsan_type_hash.cc.o
../ubsan/CMakeFiles/RTUbsan.osx.dir/ubsan_type_hash_itanium.cc.o
../ubsan/CMakeFiles/RTUbsan.osx.dir/ubsan_type_hash_win.cc.o
-Wl,-rpath,@executable_path/../lib 
Undefined symbols for architecture x86_64:
  "typeinfo for __cxxabiv1::__class_type_info", referenced from:
      __ubsan::checkDynamicType(void*, void*, unsigned long) in
ubsan_type_hash_itanium.cc.o
      __ZL21isDerivedFromAtOffsetPKN10__cxxabiv117__class_type_infoES2_l in
ubsan_type_hash_itanium.cc.o
      __ZL16findBaseAtOffsetPKN10__cxxabiv117__class_type_infoEl in
ubsan_type_hash_itanium.cc.o
  "typeinfo for __cxxabiv1::__si_class_type_info", referenced from:
      __ZL21isDerivedFromAtOffsetPKN10__cxxabiv117__class_type_infoES2_l in
ubsan_type_hash_itanium.cc.o
      __ZL16findBaseAtOffsetPKN10__cxxabiv117__class_type_infoEl in
ubsan_type_hash_itanium.cc.o
  "typeinfo for __cxxabiv1::__vmi_class_type_info", referenced from:
      __ZL21isDerivedFromAtOffsetPKN10__cxxabiv117__class_type_infoES2_l in
ubsan_type_hash_itanium.cc.o
      __ZL16findBaseAtOffsetPKN10__cxxabiv117__class_type_infoEl in
ubsan_type_hash_itanium.cc.o
  "typeinfo for std::type_info", referenced from:
      __ubsan::checkDynamicType(void*, void*, unsigned long) in
ubsan_type_hash_itanium.cc.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
projects/compiler-rt/lib/asan/CMakeFiles/clang_rt.asan_osx_dynamic.dir/build.make:216:
recipe for target
'lib/clang/3.7.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib' failed
make[2]: *** [lib/clang/3.7.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib]
Error 1
make[2]: Leaving directory '/sw/src/fink.build/llvm37-3.7.0-3/build/stage1'
CMakeFiles/Makefile2:7308: recipe for target
'projects/compiler-rt/lib/asan/CMakeFiles/clang_rt.asan_osx_dynamic.dir/all'
failed
make[1]: ***
[projects/compiler-rt/lib/asan/CMakeFiles/clang_rt.asan_osx_dynamic.dir/all]
Error 2
make[1]: Leaving directory '/sw/src/fink.build/llvm37-3.7.0-3/build/stage1'
Makefile:136: recipe for target 'all' failed
make: *** [all] Error 2



This fails because the referenced symbols in /usr/lib/libc++abi.dylib all have
static linkage:

% nm /usr/lib/libc++abi.dylib | c++filt | grep "typeinfo for
__cxxabiv1::__class_type_info" 
000000000000cd10 s typeinfo for __cxxabiv1::__class_type_info
                 ^--- lowercase s: static

On newer darwins, these symbols in libc++abi.dylib have extern linkage 'S'.

Is there a workaround for this?
If not, what is the cmake-way of disabling ubsan?</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>