[CMake] [Darwin] [Builtins] Force setting the flags we care about at the end of the compiler command line
Setting CMAKE_*_FLAGS isn't sufficient here because CMAKE_*_FLAGS_${CMAKE_BUILD_TYPE} can override the flags, and there is no way to safely clear that because it is a cached variable (<sarcasm> YAY! </sarcasm>).
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@252807 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/cmake/Modules/CompilerRTDarwinUtils.cmake b/cmake/Modules/CompilerRTDarwinUtils.cmake
index 0edee65..18ddc0e 100644
--- a/cmake/Modules/CompilerRTDarwinUtils.cmake
+++ b/cmake/Modules/CompilerRTDarwinUtils.cmake
@@ -258,9 +258,10 @@
macro(darwin_add_builtin_libraries)
set(DARWIN_EXCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Darwin-excludes)
- set(CMAKE_C_FLAGS "-O3 -fvisibility=hidden -DVISIBILITY_HIDDEN -Wall -fomit-frame-pointer")
- set(CMAKE_CXX_FLAGS ${CMAKE_C_FLAGS})
- set(CMAKE_ASM_FLAGS ${CMAKE_C_FLAGS})
+ set(CFLAGS "-O3 -fvisibility=hidden -DVISIBILITY_HIDDEN -Wall -fomit-frame-pointer")
+ set(CMAKE_C_FLAGS "")
+ set(CMAKE_CXX_FLAGS "")
+ set(CMAKE_ASM_FLAGS "")
set(PROFILE_SOURCES ../profile/InstrProfiling
../profile/InstrProfilingBuffer
@@ -281,7 +282,7 @@
OS ${os}
ARCH ${arch}
SOURCES ${filtered_sources}
- CFLAGS -arch ${arch}
+ CFLAGS ${CFLAGS} -arch ${arch}
PARENT_TARGET builtins)
endforeach()
@@ -304,7 +305,7 @@
OS ${os}
ARCH ${arch}
SOURCES ${filtered_sources} ${PROFILE_SOURCES}
- CFLAGS -arch ${arch} -mkernel
+ CFLAGS ${CFLAGS} -arch ${arch} -mkernel
DEFS KERNEL_USE
PARENT_TARGET builtins)
endforeach()
@@ -358,9 +359,10 @@
set(MACHO_SYM_DIR ${CMAKE_CURRENT_SOURCE_DIR}/macho_embedded)
- set(CMAKE_C_FLAGS "-Oz -Wall -fomit-frame-pointer -ffreestanding")
- set(CMAKE_CXX_FLAGS ${CMAKE_C_FLAGS})
- set(CMAKE_ASM_FLAGS ${CMAKE_C_FLAGS})
+ set(CFLAGS "-Oz -Wall -fomit-frame-pointer -ffreestanding")
+ set(CMAKE_C_FLAGS "")
+ set(CMAKE_CXX_FLAGS "")
+ set(CMAKE_ASM_FLAGS "")
set(SOFT_FLOAT_FLAG -mfloat-abi=soft)
set(HARD_FLOAT_FLAG -mfloat-abi=hard)
@@ -421,7 +423,7 @@
OS macho_embedded
ARCH ${arch}
SOURCES ${${arch}_filtered_sources}
- CFLAGS -arch ${arch} ${${type}_FLAG} ${float_flag} ${CFLAGS_${arch}}
+ CFLAGS ${CFLAGS} -arch ${arch} ${${type}_FLAG} ${float_flag} ${CFLAGS_${arch}}
PARENT_TARGET builtins)
endforeach()
foreach(lib ${macho_embedded_${lib_suffix}_libs})