[PATCH] D102090: [CMake][ELF] Add -fno-semantic-interposition and -Bsymbolic-functions
Fangrui Song via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri May 7 13:53:01 PDT 2021
MaskRay updated this revision to Diff 343755.
MaskRay added a comment.
Set global CMAKE_SHARED_LINKER_FLAGS instead.
This additional makes -DBUILD_SHARED_LIBS=on builds (dev only; not recommended for packagers) faster.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D102090/new/
https://reviews.llvm.org/D102090
Files:
llvm/cmake/modules/HandleLLVMOptions.cmake
Index: llvm/cmake/modules/HandleLLVMOptions.cmake
===================================================================
--- llvm/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -237,6 +237,12 @@
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-z,nodelete")
endif()
+# Optimize function calls and global variable access for default visibility
+# definitions to avoid PLT and reduce dynamic relocations.
+if(${CMAKE_SYSTEM_NAME} MATCHES "DragonFly|FreeBSD|Fuchsia|Linux|NetBSD|OpenBSD")
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-Bsymbolic-functions")
+endif()
+
function(append value)
foreach(variable ${ARGN})
@@ -305,6 +311,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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102090.343755.patch
Type: text/x-patch
Size: 1063 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210507/22d3ea3d/attachment.bin>
More information about the cfe-commits
mailing list