[PATCH] D102453: [CMake][ELF] Add -fno-semantic-interposition for GCC and Clang>=13

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 12 18:42:34 PST 2022


MaskRay added a comment.

In D102453#3239251 <https://reviews.llvm.org/D102453#3239251>, @ljmf00 wrote:

> In D102453#3238656 <https://reviews.llvm.org/D102453#3238656>, @MaskRay wrote:
>
>> What's your Clang version? Clang -DLLVM_USE_SANITIZER=Address works well for me (and sanitizer* build bots) with both Debug and Release.
>> If it's problems in older Clang versions, we can just disable the older versions.
>
> I'm running builds on an Arch Linux based docker container with Clang and LLVM tools with version 13.0.0 (rel version 2, for clang, on Arch Linux) on this target CPU https://termbin.com/82n2 . I'm also using ccache 4.4.2 to speed up builds.
> I've done a full clean build and logged it here https://ipfs.io/ipfs/bafybeia4kdu4a55fcp5nfntwcqe33aucuwv3uacelmo6zcsmasnsuafvim/ . I'm sorry for including that many flags, but I have an automated CMake bootstrap script to do it but some of them are the default values.
>
> I tried to debug this a bit and figure out if there is a combination of flags that can succeed. I consulted the infrastructure repository and confirmed that sanitisers are being built with gold linker. So perhaps is this something linker related? I can try gold if it is worth trying.

I cannot reproduce your breakage with clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04 on https://github.com/llvm/llvm-project/releases , or nearly trunk Clang from (`curl -s https://raw.githubusercontent.com/chromium/chromium/main/tools/clang/scripts/update.py | python3 - --output-dir=~/Stable`)

I dropped ccache related options and used something like `-DCMAKE_C_COMPILER=~/llvm-prebuilt/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04/bin/clang -DCMAKE_CXX_COMPILER=~/llvm-prebuilt/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04/bin/clang++ '-DLLVM_ENABLE_PROJECTS=clang-tools-extra;clang;llvm;lldb;lld' -DCMAKE_BUILD_TYPE=Debug -DLLDB_EXPORT_ALL_SYMBOLS=OFF '-DLLVM_LIT_ARGS=-v -vv' -DLLVM_OPTIMIZED_TABLEGEN=ON -DLLVM_ENABLE_ASSERTIONS=ON -DLLDB_ENABLE_LUA=OFF -DLLDB_ENABLE_LZMA=ON -DLLDB_ENABLE_LIBXML2=ON -DLLDB_ENABLE_PYTHON=ON -DLLVM_TARGETS_TO_BUILD=all -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly -DLLDB_TEST_USER_ARGS=-t -DLLVM_ENABLE_WERROR=ON -DLLVM_LINK_LLVM_DYLIB=ON -DCLANG_LINK_CLANG_DYLIB=ON -DBUILD_SHARED_LIBS=OFF -DLLVM_ENABLE_LLD=ON -DCLANG_DEFAULT_LINKER=lld -DLLVM_USE_SPLIT_DWARF=ON -DLLVM_ENABLE_LTO=OFF -DLLVM_ENABLE_EXPENSIVE_CHECKS=OFF -DLLVM_BUILD_INSTRUMENTED_COVERAGE=OFF -DLLVM_USE_SANITIZE_COVERAGE=ON '-DLLVM_USE_SANITIZER=Address;Undefined'`

Take this as an example:

  ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol lto_module_is_object_file_for_target; recompile with -fPIC                              
  >>> defined in tools/lto/CMakeFiles/LTO.dir/lto.cpp.o                                                                                                         
  >>> referenced by lto.cpp:175 (/mnt/Workspace/Repos/collab/github/llvm/llvm-project/llvm/tools/lto/lto.cpp:175)                                               
  >>>               tools/lto/CMakeFiles/LTO.dir/lto.cpp.o:(lto_module_is_object_file_for_target)                     

You can delete `lto.cpp.o`, rerun `ninja` with -v to get the compiler command line. You can then remove unneeded options and then add -S to get the assembly.
Check which instruction generates something like `R_X86_64_PC32` (you may need to compile with -c and compare .o output with .s)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102453



More information about the llvm-commits mailing list