[all-commits] [llvm/llvm-project] a96f87: [CMake][ELF] Add -fno-semantic-interposition for G...

Fangrui Song via All-commits all-commits at lists.llvm.org
Thu Jun 3 15:26:50 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a96f875fe98de5eb5f44b0148baa442c998364ed
      https://github.com/llvm/llvm-project/commit/a96f875fe98de5eb5f44b0148baa442c998364ed
  Author: Fangrui Song <i at maskray.me>
  Date:   2021-06-03 (Thu, 03 Jun 2021)

  Changed paths:
    M llvm/cmake/modules/HandleLLVMOptions.cmake

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

In a `-DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_LINK_LLVM_DYLIB=on -DCLANG_LINK_CLANG_DYLIB=on`
build, libLLVM-13git.so is 2% smaller and libclang-cpp.so is 1% smaller (on top of -Wl,-Bsymbolic-functions).
There may be some small performance improvement as well because GCC
-fPIC suppresses interprocedural optimizations for non-inline
definitions by default.

Note: we cannot add -fno-semantic-interposition for Clang<13.  Clang<13's
implementation additionally optimizes global variables, which is incompatible
with unfortunate ELF -fno-pic default: direct access relocations for external
data. If the executable has a -fno-pic object file referencing a global variable
declared in a public header, the direct access relocation will cause a copy
relocation. The executable and libLLVM.so/libclang-cpp.so will disagree on the
address.

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D102453




More information about the All-commits mailing list