[PATCH] D76527: Don't export symbols from clang/opt/llc if plugins are disabled.

Eli Friedman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 20 14:08:45 PDT 2020


efriedma created this revision.
efriedma added reviewers: MaskRay, serge-sans-paille, Meinersbur.
Herald added subscribers: cfe-commits, dexonsmith, mgorny.
Herald added a project: clang.

The only reason we export symbols from these tools is to support plugins; if we don't have plugins, exporting symbols just bloats the executable and makes LTO less effective.

See review of D75879 <https://reviews.llvm.org/D75879> for the discussion that led to this patch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76527

Files:
  clang/tools/driver/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake
  llvm/tools/bugpoint/CMakeLists.txt
  llvm/tools/llc/CMakeLists.txt
  llvm/tools/llvm-stress/CMakeLists.txt
  llvm/tools/opt/CMakeLists.txt
  llvm/unittests/Passes/CMakeLists.txt


Index: llvm/unittests/Passes/CMakeLists.txt
===================================================================
--- llvm/unittests/Passes/CMakeLists.txt
+++ llvm/unittests/Passes/CMakeLists.txt
@@ -16,7 +16,7 @@
   add_llvm_unittest(PluginsTests
     PluginsTest.cpp
     )
-  export_executable_symbols(PluginsTests)
+  export_executable_symbols_for_plugins(PluginsTests)
   target_link_libraries(PluginsTests PRIVATE LLVMTestingSupport)
 
   set(LLVM_LINK_COMPONENTS)
Index: llvm/tools/opt/CMakeLists.txt
===================================================================
--- llvm/tools/opt/CMakeLists.txt
+++ llvm/tools/opt/CMakeLists.txt
@@ -39,7 +39,7 @@
   intrinsics_gen
   SUPPORT_PLUGINS
   )
-export_executable_symbols(opt)
+export_executable_symbols_for_plugins(opt)
 
 if(LLVM_BUILD_EXAMPLES)
     target_link_libraries(opt PRIVATE ExampleIRTransforms)
Index: llvm/tools/llvm-stress/CMakeLists.txt
===================================================================
--- llvm/tools/llvm-stress/CMakeLists.txt
+++ llvm/tools/llvm-stress/CMakeLists.txt
@@ -10,4 +10,3 @@
   DEPENDS
   intrinsics_gen
   )
-export_executable_symbols(llvm-stress)
Index: llvm/tools/llc/CMakeLists.txt
===================================================================
--- llvm/tools/llc/CMakeLists.txt
+++ llvm/tools/llc/CMakeLists.txt
@@ -27,4 +27,4 @@
   SUPPORT_PLUGINS
   )
 
-export_executable_symbols(llc)
+export_executable_symbols_for_plugins(llc)
Index: llvm/tools/bugpoint/CMakeLists.txt
===================================================================
--- llvm/tools/bugpoint/CMakeLists.txt
+++ llvm/tools/bugpoint/CMakeLists.txt
@@ -38,4 +38,4 @@
   intrinsics_gen
   SUPPORT_PLUGINS
   )
-export_executable_symbols(bugpoint)
+export_executable_symbols_for_plugins(bugpoint)
Index: llvm/cmake/modules/AddLLVM.cmake
===================================================================
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -1029,6 +1029,13 @@
   endif()
 endfunction()
 
+# Export symbols if LLVM plugins are enabled.
+function(export_executable_symbols_for_plugins target)
+  if(LLVM_ENABLE_PLUGINS)
+    export_executable_symbols(${target})
+  endif()
+endfunction()
+
 if(NOT LLVM_TOOLCHAIN_TOOLS)
   set (LLVM_TOOLCHAIN_TOOLS
     llvm-ar
Index: clang/tools/driver/CMakeLists.txt
===================================================================
--- clang/tools/driver/CMakeLists.txt
+++ clang/tools/driver/CMakeLists.txt
@@ -57,7 +57,7 @@
 
 # Support plugins.
 if(CLANG_PLUGIN_SUPPORT)
-  export_executable_symbols(clang)
+  export_executable_symbols_for_plugins(clang)
 endif()
 
 add_dependencies(clang clang-resource-headers)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76527.251757.patch
Type: text/x-patch
Size: 2680 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200320/16fb811a/attachment-0001.bin>


More information about the cfe-commits mailing list