Skip to content

Commit 896335b

Browse files
committed
Don't export symbols from clang/opt/llc if plugins are disabled.
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 for the discussion that led to this patch. Differential Revision: https://reviews.llvm.org/D76527
1 parent 75add0b commit 896335b

File tree

7 files changed

+12
-6
lines changed

7 files changed

+12
-6
lines changed

clang/tools/driver/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ endif()
5757

5858
# Support plugins.
5959
if(CLANG_PLUGIN_SUPPORT)
60-
export_executable_symbols(clang)
60+
export_executable_symbols_for_plugins(clang)
6161
endif()
6262

6363
add_dependencies(clang clang-resource-headers)

llvm/cmake/modules/AddLLVM.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,6 +1029,13 @@ function(export_executable_symbols target)
10291029
endif()
10301030
endfunction()
10311031

1032+
# Export symbols if LLVM plugins are enabled.
1033+
function(export_executable_symbols_for_plugins target)
1034+
if(LLVM_ENABLE_PLUGINS)
1035+
export_executable_symbols(${target})
1036+
endif()
1037+
endfunction()
1038+
10321039
if(NOT LLVM_TOOLCHAIN_TOOLS)
10331040
set (LLVM_TOOLCHAIN_TOOLS
10341041
llvm-ar

llvm/tools/bugpoint/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ add_llvm_tool(bugpoint
3838
intrinsics_gen
3939
SUPPORT_PLUGINS
4040
)
41-
export_executable_symbols(bugpoint)
41+
export_executable_symbols_for_plugins(bugpoint)

llvm/tools/llc/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ add_llvm_tool(llc
2727
SUPPORT_PLUGINS
2828
)
2929

30-
export_executable_symbols(llc)
30+
export_executable_symbols_for_plugins(llc)

llvm/tools/llvm-stress/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,3 @@ add_llvm_tool(llvm-stress
1010
DEPENDS
1111
intrinsics_gen
1212
)
13-
export_executable_symbols(llvm-stress)

llvm/tools/opt/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ add_llvm_tool(opt
3939
intrinsics_gen
4040
SUPPORT_PLUGINS
4141
)
42-
export_executable_symbols(opt)
42+
export_executable_symbols_for_plugins(opt)
4343

4444
if(LLVM_BUILD_EXAMPLES)
4545
target_link_libraries(opt PRIVATE ExampleIRTransforms)

llvm/unittests/Passes/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ if (NOT WIN32)
1616
add_llvm_unittest(PluginsTests
1717
PluginsTest.cpp
1818
)
19-
export_executable_symbols(PluginsTests)
19+
export_executable_symbols_for_plugins(PluginsTests)
2020
target_link_libraries(PluginsTests PRIVATE LLVMTestingSupport)
2121

2222
set(LLVM_LINK_COMPONENTS)

0 commit comments

Comments
 (0)