[PATCH] D78325: [ubsan] Link shared runtime library with a version script.

Petr Hosek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 17 17:34:19 PDT 2020


phosek added a comment.

In D78325#1989273 <https://reviews.llvm.org/D78325#1989273>, @eugenis wrote:

> Sorry about that! Any idea why this is happening? I don't see any "-lc++" on the linker command line, but the driver should add it anyway when you link with "clang++" AFAIK.


I compared the two builds from before and after, and it seems like `-nodefaultlibs` got dropped which explains why `-lc++` is not being linked in:

Before:

  LINK_FLAGS = -L/usr/local/google/home/phosek/clang-llvm/sdk/arch/x64/lib    -nodefaultlibs -Wl,-z,text -Wl,-z,defs,-z,now,-z,relro

After:

  LINK_FLAGS = -L/usr/local/google/home/phosek/clang-llvm/sdk/arch/x64/lib    -Wl,--version-script,/src/clang-llvm/llvm-build/fuchsia2/runtimes/runtimes-x86_64-unknown-fuchsia-bins/compiler-rt/lib/ubsan/clang_rt.ubsan_standalone-dynamic-x86_64.vers

I believe this is because `${SANITIZER_COMMON_LINK_FLAGS}` got replaced with `${UBSAN_LINK_FLAGS} ${VERSION_SCRIPT_FLAG}`, and `${UBSAN_LINK_FLAGS}` doesn't contain `-nodefaultlibs`. In fact, I don't even see `${UBSAN_LINK_FLAGS}` being set in `ubsan\CMakeLists.txt`, it's only set in `ubsan_minimal\CMakeLists.txt`, so we probably need to add `set(UBSAN_LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS})` to this file as well.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78325/new/

https://reviews.llvm.org/D78325





More information about the llvm-commits mailing list