1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-18 18:42:46 +02:00

Port r198087 and r198089 (strip dead code by default) from make to cmake.

llvm-svn: 198198
This commit is contained in:
Nico Weber 2013-12-30 03:36:05 +00:00
parent 747bcf57ed
commit e7bb9e41e0
5 changed files with 34 additions and 0 deletions

View File

@ -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} )

View File

@ -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

View File

@ -11,6 +11,9 @@ set(LLVM_LINK_COMPONENTS
Target
)
# Support plugins.
set(LLVM_NO_DEAD_STRIP 1)
add_llvm_tool(llc
llc.cpp
)

View File

@ -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

View File

@ -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}
)