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

NAKAMURA Takumi geek4civic at gmail.com
Tue Jan 28 01:43:55 PST 2014


Author: chapuni
Date: Tue Jan 28 03:43:55 2014
New Revision: 200299

URL: http://llvm.org/viewvc/llvm-project?rev=200299&view=rev
Log:
[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.

Modified:
    llvm/trunk/cmake/modules/AddLLVM.cmake
    llvm/trunk/cmake/modules/HandleLLVMOptions.cmake

Modified: llvm/trunk/cmake/modules/AddLLVM.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/AddLLVM.cmake?rev=200299&r1=200298&r2=200299&view=diff
==============================================================================
--- llvm/trunk/cmake/modules/AddLLVM.cmake (original)
+++ llvm/trunk/cmake/modules/AddLLVM.cmake Tue Jan 28 03:43:55 2014
@@ -100,21 +100,12 @@ function(add_llvm_symbol_exports target_
 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()

Modified: llvm/trunk/cmake/modules/HandleLLVMOptions.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/HandleLLVMOptions.cmake?rev=200299&r1=200298&r2=200299&view=diff
==============================================================================
--- llvm/trunk/cmake/modules/HandleLLVMOptions.cmake (original)
+++ llvm/trunk/cmake/modules/HandleLLVMOptions.cmake Tue Jan 28 03:43:55 2014
@@ -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()





More information about the llvm-commits mailing list