summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2014-02-04 08:15:46 +0000
committerAlexey Samsonov <samsonov@google.com>2014-02-04 08:15:46 +0000
commit482beff8ae17ad896d8221e810b6362cffd0b0c9 (patch)
tree42bb5bb4b9aaa706c722cd611443986a231aebac /llvm
parent34a466f8da8210c69d8b76976aa11b83e516e3a8 (diff)
downloadbcm5719-llvm-482beff8ae17ad896d8221e810b6362cffd0b0c9.tar.gz
bcm5719-llvm-482beff8ae17ad896d8221e810b6362cffd0b0c9.zip
[CMake] Revert r200695 and fix the problem with missing -fno-function-sections in a different way.
llvm-svn: 200745
Diffstat (limited to 'llvm')
-rw-r--r--llvm/cmake/modules/HandleLLVMOptions.cmake22
1 files changed, 12 insertions, 10 deletions
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index 8e4b6bbdafd..b40103ca186 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -335,23 +335,25 @@ if (UNIX AND
append("-fcolor-diagnostics" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
endif()
-# Clang prior to 3.5 ignored -fno-function-sections.
-# It's pretty hard to test directly, so we rely on the version number.
-if( ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5) )
- set(LLVM_COMPILER_HAS_BROKEN_FNO_FUNCTION_SECTIONS ON)
-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")
- # Don't add -ffunction-section if it can be disabled with -fno-function-sections.
- # Doing so will break sanitizers.
- if (NOT LLVM_COMPILER_HAS_BROKEN_FNO_FUNCTION_SECTIONS)
- append("-ffunction-sections -fdata-sections" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+ check_c_compiler_flag("-Werror -fno-function-sections" C_SUPPORTS_FNO_FUNCTION_SECTIONS)
+ if (C_SUPPORTS_FNO_FUNCTION_SECTIONS)
+ # Don't add -ffunction-section if it can be disabled with -fno-function-sections.
+ # Doing so will break sanitizers.
+ check_c_compiler_flag("-Werror -ffunction-sections" C_SUPPORTS_FFUNCTION_SECTIONS)
+ check_cxx_compiler_flag("-Werror -ffunction-sections" CXX_SUPPORTS_FFUNCTION_SECTIONS)
+ append_if(C_SUPPORTS_FFUNCTION_SECTIONS "-ffunction-sections" CMAKE_C_FLAGS)
+ append_if(CXX_SUPPORTS_FFUNCTION_SECTIONS "-ffunction-sections" CMAKE_CXX_FLAGS)
endif()
+ check_c_compiler_flag("-Werror -fdata-sections" C_SUPPORTS_FDATA_SECTIONS)
+ check_cxx_compiler_flag("-Werror -fdata-sections" CXX_SUPPORTS_FDATA_SECTIONS)
+ append_if(C_SUPPORTS_FDATA_SECTIONS "-fdata-sections" CMAKE_C_FLAGS)
+ append_if(CXX_SUPPORTS_FDATA_SECTIONS "-fdata-sections" CMAKE_CXX_FLAGS)
endif()
endif()
OpenPOWER on IntegriCloud