1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 12:43:36 +01:00

[CMake] Move -ffunction-data-sections stuff to HandleLLVMOptions.

With this tweaks, also unittests are compiled with -ffunction-sections.

It's hard to control contextual CMAKE_CXX_FLAGS. We should get rid of twiddling it as possible.

llvm-svn: 200299
This commit is contained in:
NAKAMURA Takumi 2014-01-28 09:43:55 +00:00
parent 6e967d4af7
commit 96ebbdc8e5
2 changed files with 11 additions and 10 deletions

View File

@ -100,21 +100,12 @@ function(add_llvm_symbol_exports target_name export_file)
endfunction(add_llvm_symbol_exports)
function(add_dead_strip target_name)
# FIXME: With MSVS, consider compiling with /Gy and linking with /OPT:REF?
# But MinSizeRel seems to add that automatically, so maybe disable these
# flags instead if LLVM_NO_DEAD_STRIP is set.
if(NOT CYGWIN AND NOT MINGW AND NOT MSVC)
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)
# Object files are compiled with -ffunction-data-sections.
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,--gc-sections")
endif()

View File

@ -349,3 +349,13 @@ if (UNIX AND
CMAKE_GENERATOR STREQUAL "Ninja")
append("-fcolor-diagnostics" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
endif()
# Add flags for add_dead_strip().
# FIXME: With MSVS, consider compiling with /Gy and linking with /OPT:REF?
# But MinSizeRel seems to add that automatically, so maybe disable these
# flags instead if LLVM_NO_DEAD_STRIP is set.
if(NOT CYGWIN AND NOT WIN32)
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
append("-ffunction-sections -fdata-sections" CMAKE_CXX_FLAGS)
endif()
endif()