[PATCH] D137398: lib/CodeGen: Compile with -fvisibility=hidden when possible
Tom Stellard via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 4 00:43:29 PDT 2022
tstellar created this revision.
tstellar added reviewers: MaskRay, compnerd.
Herald added subscribers: StephenFan, mstorsjo, hiraditya.
Herald added a project: All.
tstellar requested review of this revision.
Herald added a project: LLVM.
I don't think there is any code there that is meant to be part of the
public LLVM API. This helps reduce the number of exported symbols in
the library:
Before:
$ nm -D libLLVM-16git.so | wc -l
33240
After:
$ nm -D libLLVM-16git.so | wc -l
26987
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D137398
Files:
llvm/CMakeLists.txt
llvm/lib/CodeGen/CMakeLists.txt
llvm/lib/Target/CMakeLists.txt
Index: llvm/lib/Target/CMakeLists.txt
===================================================================
--- llvm/lib/Target/CMakeLists.txt
+++ llvm/lib/Target/CMakeLists.txt
@@ -21,12 +21,7 @@
# When building shared objects for each target there are some internal APIs
# that are used across shared objects which we can't hide.
-if (NOT BUILD_SHARED_LIBS AND NOT APPLE AND
- (NOT (WIN32 OR CYGWIN) OR (MINGW AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")) AND
- NOT (${CMAKE_SYSTEM_NAME} MATCHES "AIX") AND
- NOT DEFINED CMAKE_CXX_VISIBILITY_PRESET)
- # Set default visibility to hidden, so we don't export all the Target classes
- # in libLLVM.so.
+if (LLVM_CAN_USE_HIDDEN_VISIBILITY)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
endif()
Index: llvm/lib/CodeGen/CMakeLists.txt
===================================================================
--- llvm/lib/CodeGen/CMakeLists.txt
+++ llvm/lib/CodeGen/CMakeLists.txt
@@ -1,3 +1,7 @@
+if (LLVM_CAN_USE_HIDDEN_VISIBILITY)
+ set(CMAKE_CXX_VISIBILITY_PRESET hidden)
+endif()
+
if (DEFINED LLVM_HAVE_TF_AOT OR DEFINED LLVM_HAVE_TF_API)
include(TensorFlowCompile)
set(LLVM_RAEVICT_MODEL_PATH_DEFAULT "models/regalloc-eviction")
Index: llvm/CMakeLists.txt
===================================================================
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -1180,6 +1180,13 @@
umbrella_lit_testsuite_begin(check-all)
endif()
+if (NOT BUILD_SHARED_LIBS AND NOT APPLE AND
+ (NOT (WIN32 OR CYGWIN) OR (MINGW AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")) AND
+ NOT (${CMAKE_SYSTEM_NAME} MATCHES "AIX") AND
+ NOT DEFINED CMAKE_CXX_VISIBILITY_PRESET)
+ set(LLVM_CAN_USE_HIDDEN_VISIBILITY ON)
+endif()
+
# Put this before tblgen. Else we have a circular dependence.
add_subdirectory(lib/Demangle)
add_subdirectory(lib/Support)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137398.473147.patch
Type: text/x-patch
Size: 1821 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221104/124c37e3/attachment.bin>
More information about the llvm-commits
mailing list