[PATCH] D102090: [CMake][ELF] Add -fno-semantic-interposition and -Bsymbolic-functions

Fangrui Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 12 10:34:40 PDT 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rG3bf1acab5b45: [CMake][ELF] Add -fno-semantic-interposition and -Bsymbolic-functions (authored by MaskRay).

Changed prior to commit:
  https://reviews.llvm.org/D102090?vs=343758&id=344866#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102090

Files:
  clang/tools/clang-shlib/CMakeLists.txt
  llvm/cmake/modules/HandleLLVMOptions.cmake
  llvm/tools/llvm-shlib/CMakeLists.txt


Index: llvm/tools/llvm-shlib/CMakeLists.txt
===================================================================
--- llvm/tools/llvm-shlib/CMakeLists.txt
+++ llvm/tools/llvm-shlib/CMakeLists.txt
@@ -50,6 +50,9 @@
       # Solaris ld does not accept global: *; so there is no way to version *all* global symbols
       set(LIB_NAMES -Wl,--version-script,${LLVM_LIBRARY_DIR}/tools/llvm-shlib/simple_version_script.map ${LIB_NAMES})
     endif()
+    # Optimize function calls and global variable access for default visibility
+    # definitions to avoid PLT and reduce dynamic relocations.
+    target_link_options(LLVM PRIVATE LINKER:-Bsymbolic-functions)
   elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
     set(LIB_NAMES -Wl,-all_load ${LIB_NAMES})
   endif()
Index: llvm/cmake/modules/HandleLLVMOptions.cmake
===================================================================
--- llvm/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -305,6 +305,7 @@
     # On Windows all code is PIC. MinGW warns if -fPIC is used.
   else()
     add_flag_or_print_warning("-fPIC" FPIC)
+    add_flag_if_supported("-fno-semantic-interposition" FNO_SEMANTIC_INTERPOSITION)
   endif()
   # GCC for MIPS can miscompile LLVM due to PR37701.
   if(CMAKE_COMPILER_IS_GNUCXX AND LLVM_NATIVE_ARCH STREQUAL "Mips" AND
Index: clang/tools/clang-shlib/CMakeLists.txt
===================================================================
--- clang/tools/clang-shlib/CMakeLists.txt
+++ clang/tools/clang-shlib/CMakeLists.txt
@@ -48,3 +48,8 @@
                   ${_OBJECTS}
                   LINK_LIBS
                   ${_DEPS})
+# Optimize function calls and global variable access for default visibility
+# definitions to avoid PLT and reduce dynamic relocations.
+if (NOT APPLE)
+  target_link_options(clang-cpp PRIVATE LINKER:-Bsymbolic-functions)
+endif()


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102090.344866.patch
Type: text/x-patch
Size: 1877 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210512/fc25c211/attachment.bin>


More information about the cfe-commits mailing list