[cfe-dev] UBSAN: undefined symbols when compiling on macOS Sierra (local config issue?)

Kevin Ushey via cfe-dev cfe-dev at lists.llvm.org
Thu Sep 29 10:23:16 PDT 2016


Hi everyone,

I'm running into some issues when attempting to link while using the
'undefined' sanitizer -- when linking my program, I'm getting errors of the
form:

Undefined symbols for architecture x86_64:
  "___ubsan_handle_dynamic_type_cache_miss", referenced from: <...>
  "___ubsan_vptr_type_cache", referenced from: <...>
ld: symbol(s) not found for architecture x86_64


Looking at the generated ubsan dynamic library, those symbols are not
present:

kevin at cdrv:/usr/local/llvm/db79113/lib/clang/4.0.0/lib/darwin
$ nm libclang_rt.ubsan_osx_dynamic.dylib | grep "ubsan_vptr_type_cache"


However, with clang-3.8 provided by Homebrew, these symbols are indeed
present:

kevin at cdrv
:/usr/local/Cellar/llvm38/3.8.0/lib/llvm-3.8/lib/clang/3.8.0/lib/darwin
$ nm libclang_rt.ubsan_osx_dynamic.dylib | grep "ubsan_vptr_type_cache"
0000000000b20c00 S ___ubsan_vptr_type_cache


which I think implies I'm probably missing some bit of configuration when
building clang with sanitizers. For reference, I'm building the LLVM tree
with:

cmake -G "Ninja" ..                                  \
    -DCMAKE_C_COMPILER=/usr/bin/clang                \
    -DCMAKE_C_FLAGS="${INCLUDE_FLAGS}"               \
    -DCMAKE_CXX_COMPILER=/usr/bin/clang++            \
    -DCMAKE_CXX_FLAGS="${INCLUDE_FLAGS}"             \
    -DCMAKE_SHARED_LINKER_FLAGS="-L/usr/local/lib"   \
    -DCMAKE_BUILD_TYPE=Release                       \
    -DCMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}" \
    -DLLVM_ENABLE_EH=Yes                             \
    -DLLVM_ENABLE_RTTI=Yes

cmake --build .

cmake --build . --target install


This is built with 'clang' and 'lldb' checked out in the 'llvm/tools'
folder, and 'compiler-rt', 'openmp', 'libcxx' and 'libcxxabi' checked out
in the 'llvm/projects' folder, and the master branch from the various git
mirrors for each project.

A bit of googling brought me to
http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20150622/283017.html,
but I'm not sure if it's relevant to this particular issue.

Any idea what I could be missing?

Thanks,
Kevin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160929/b6f72a78/attachment.html>


More information about the cfe-dev mailing list