summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2013-12-30 03:36:05 +0000
committerNico Weber <nicolasweber@gmx.de>2013-12-30 03:36:05 +0000
commit94d1e67cb555f544252a88235a33a2caa378ae63 (patch)
tree4be0932b346f0fae5544dcd3074f47bb1bd26cf3
parent0661cbefb3c3544b50dd3b7ee6e81113a92e389d (diff)
downloadllvm-94d1e67cb555f544252a88235a33a2caa378ae63.tar.gz
llvm-94d1e67cb555f544252a88235a33a2caa378ae63.tar.bz2
llvm-94d1e67cb555f544252a88235a33a2caa378ae63.tar.xz
Port r198087 and r198089 (strip dead code by default) from make to cmake.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198198 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--cmake/modules/AddLLVM.cmake22
-rw-r--r--tools/bugpoint/CMakeLists.txt3
-rw-r--r--tools/llc/CMakeLists.txt3
-rw-r--r--tools/opt/CMakeLists.txt3
-rw-r--r--unittests/ExecutionEngine/JIT/CMakeLists.txt3
5 files changed, 34 insertions, 0 deletions
diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake
index 3d0c53d1eb..6840cfca81 100644
--- a/cmake/modules/AddLLVM.cmake
+++ b/cmake/modules/AddLLVM.cmake
@@ -76,10 +76,30 @@ function(add_llvm_symbol_exports target_name export_file)
add_dependencies(${target_name} ${target_name}_exports)
endfunction(add_llvm_symbol_exports)
+function(add_dead_strip target_name)
+ if(NOT CYGWIN AND NOT MINGW)
+ if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+ SET(CMAKE_CXX_FLAGS
+ "${CMAKE_CXX_FLAGS} -ffunction-sections -fdata-sections"
+ PARENT_SCOPE)
+ endif()
+ endif()
+ if(NOT LLVM_NO_DEAD_STRIP)
+ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+ set_property(TARGET ${target_name} APPEND_STRING PROPERTY
+ LINK_FLAGS " -Wl,-dead_strip")
+ elseif(NOT WIN32)
+ set_property(TARGET ${target_name} APPEND_STRING PROPERTY
+ LINK_FLAGS " -Wl,--gc-sections")
+ endif()
+ endif()
+endfunction(add_dead_strip)
+
macro(add_llvm_library name)
llvm_process_sources( ALL_FILES ${ARGN} )
add_library( ${name} ${ALL_FILES} )
set_property( GLOBAL APPEND PROPERTY LLVM_LIBS ${name} )
+ add_dead_strip( ${name} )
if( LLVM_COMMON_DEPENDS )
add_dependencies( ${name} ${LLVM_COMMON_DEPENDS} )
endif( LLVM_COMMON_DEPENDS )
@@ -137,6 +157,7 @@ ${name} ignored.")
add_library( ${name} ${libkind} ${ALL_FILES} )
set_target_properties( ${name} PROPERTIES PREFIX "" )
+ add_dead_strip( ${name} )
if (LLVM_EXPORTED_SYMBOL_FILE)
add_llvm_symbol_exports( ${name} ${LLVM_EXPORTED_SYMBOL_FILE} )
@@ -173,6 +194,7 @@ macro(add_llvm_executable name)
else()
add_executable(${name} ${ALL_FILES})
endif()
+ add_dead_strip( ${name} )
if (LLVM_EXPORTED_SYMBOL_FILE)
add_llvm_symbol_exports( ${name} ${LLVM_EXPORTED_SYMBOL_FILE} )
diff --git a/tools/bugpoint/CMakeLists.txt b/tools/bugpoint/CMakeLists.txt
index 7e7ad0e94c..14f5a3b004 100644
--- a/tools/bugpoint/CMakeLists.txt
+++ b/tools/bugpoint/CMakeLists.txt
@@ -16,6 +16,9 @@ set(LLVM_LINK_COMPONENTS
Vectorize
)
+# Support plugins.
+set(LLVM_NO_DEAD_STRIP 1)
+
add_llvm_tool(bugpoint
BugDriver.cpp
CrashDebugger.cpp
diff --git a/tools/llc/CMakeLists.txt b/tools/llc/CMakeLists.txt
index 9a3d411a28..393d64c0ef 100644
--- a/tools/llc/CMakeLists.txt
+++ b/tools/llc/CMakeLists.txt
@@ -11,6 +11,9 @@ set(LLVM_LINK_COMPONENTS
Target
)
+# Support plugins.
+set(LLVM_NO_DEAD_STRIP 1)
+
add_llvm_tool(llc
llc.cpp
)
diff --git a/tools/opt/CMakeLists.txt b/tools/opt/CMakeLists.txt
index 816edeae2d..f96f9b35ef 100644
--- a/tools/opt/CMakeLists.txt
+++ b/tools/opt/CMakeLists.txt
@@ -17,6 +17,9 @@ set(LLVM_LINK_COMPONENTS
Vectorize
)
+# Support plugins.
+set(LLVM_NO_DEAD_STRIP 1)
+
add_llvm_tool(opt
AnalysisWrappers.cpp
GraphPrinters.cpp
diff --git a/unittests/ExecutionEngine/JIT/CMakeLists.txt b/unittests/ExecutionEngine/JIT/CMakeLists.txt
index d5e0b2eea8..72c1df7463 100644
--- a/unittests/ExecutionEngine/JIT/CMakeLists.txt
+++ b/unittests/ExecutionEngine/JIT/CMakeLists.txt
@@ -51,6 +51,9 @@ if(MSVC)
list(APPEND JITTestsSources JITTests.def)
endif()
+# The JIT tests need to dlopen things.
+set(LLVM_NO_DEAD_STRIP 1)
+
add_llvm_unittest(JITTests
${JITTestsSources}
)