forked from OSchip/llvm-project
[CMake][compiler-rt] Use COMPILE_OPTIONS and LINK_OPTIONS
This avoids the need for string-ification and lets CMake deduplicate potentially duplicate flags. Differential Revision: https://reviews.llvm.org/D122750
This commit is contained in:
parent
44ee3efb93
commit
30dfe016d4
|
@ -83,8 +83,7 @@ function(add_compiler_rt_object_libraries name)
|
||||||
"${libname}" MATCHES ".*\.osx.*")
|
"${libname}" MATCHES ".*\.osx.*")
|
||||||
foreach(arch ${LIB_ARCHS_${libname}})
|
foreach(arch ${LIB_ARCHS_${libname}})
|
||||||
list(APPEND target_flags
|
list(APPEND target_flags
|
||||||
-target ${arch}-apple-macos${DARWIN_osx_MIN_VER}
|
"SHELL:-target ${arch}-apple-macos${DARWIN_osx_MIN_VER} -darwin-target-variant ${arch}-apple-ios13.1-macabi")
|
||||||
-darwin-target-variant ${arch}-apple-ios13.1-macabi)
|
|
||||||
endforeach()
|
endforeach()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -251,11 +250,9 @@ function(add_compiler_rt_runtime name type)
|
||||||
"${os}" MATCHES "^(osx)$")
|
"${os}" MATCHES "^(osx)$")
|
||||||
foreach(arch ${LIB_ARCHS_${libname}})
|
foreach(arch ${LIB_ARCHS_${libname}})
|
||||||
list(APPEND extra_cflags_${libname}
|
list(APPEND extra_cflags_${libname}
|
||||||
-target ${arch}-apple-macos${DARWIN_osx_MIN_VER}
|
"SHELL:-target ${arch}-apple-macos${DARWIN_osx_MIN_VER} -darwin-target-variant ${arch}-apple-ios13.1-macabi")
|
||||||
-darwin-target-variant ${arch}-apple-ios13.1-macabi)
|
|
||||||
list(APPEND extra_link_flags_${libname}
|
list(APPEND extra_link_flags_${libname}
|
||||||
-target ${arch}-apple-macos${DARWIN_osx_MIN_VER}
|
"SHELL:-target ${arch}-apple-macos${DARWIN_osx_MIN_VER} -darwin-target-variant ${arch}-apple-ios13.1-macabi")
|
||||||
-darwin-target-variant ${arch}-apple-ios13.1-macabi)
|
|
||||||
endforeach()
|
endforeach()
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
|
@ -304,8 +304,7 @@ macro(darwin_add_builtin_library name suffix)
|
||||||
"${LIB_OS}" MATCHES "^osx$")
|
"${LIB_OS}" MATCHES "^osx$")
|
||||||
# Build the macOS builtins with Mac Catalyst support.
|
# Build the macOS builtins with Mac Catalyst support.
|
||||||
list(APPEND builtin_cflags
|
list(APPEND builtin_cflags
|
||||||
-target ${LIB_ARCH}-apple-macos${DARWIN_osx_BUILTIN_MIN_VER}
|
"SHELL:-target ${LIB_ARCH}-apple-macos${DARWIN_osx_BUILTIN_MIN_VER} -darwin-target-variant ${LIB_ARCH}-apple-ios13.1-macabi")
|
||||||
-darwin-target-variant ${LIB_ARCH}-apple-ios13.1-macabi)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set_target_compile_flags(${libname}
|
set_target_compile_flags(${libname}
|
||||||
|
@ -400,12 +399,12 @@ endfunction()
|
||||||
macro(darwin_add_builtin_libraries)
|
macro(darwin_add_builtin_libraries)
|
||||||
set(DARWIN_EXCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Darwin-excludes)
|
set(DARWIN_EXCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Darwin-excludes)
|
||||||
|
|
||||||
set(CFLAGS "-fPIC -O3 -fvisibility=hidden -DVISIBILITY_HIDDEN -Wall -fomit-frame-pointer")
|
set(CFLAGS -fPIC -O3 -fvisibility=hidden -DVISIBILITY_HIDDEN -Wall -fomit-frame-pointer)
|
||||||
set(CMAKE_C_FLAGS "")
|
set(CMAKE_C_FLAGS "")
|
||||||
set(CMAKE_CXX_FLAGS "")
|
set(CMAKE_CXX_FLAGS "")
|
||||||
set(CMAKE_ASM_FLAGS "")
|
set(CMAKE_ASM_FLAGS "")
|
||||||
|
|
||||||
append_string_if(COMPILER_RT_HAS_ASM_LSE " -DHAS_ASM_LSE" CFLAGS)
|
append_list_if(COMPILER_RT_HAS_ASM_LSE -DHAS_ASM_LSE CFLAGS)
|
||||||
|
|
||||||
set(PROFILE_SOURCES ../profile/InstrProfiling.c
|
set(PROFILE_SOURCES ../profile/InstrProfiling.c
|
||||||
../profile/InstrProfilingBuffer.c
|
../profile/InstrProfilingBuffer.c
|
||||||
|
@ -515,7 +514,7 @@ macro(darwin_add_embedded_builtin_libraries)
|
||||||
|
|
||||||
set(MACHO_SYM_DIR ${CMAKE_CURRENT_SOURCE_DIR}/macho_embedded)
|
set(MACHO_SYM_DIR ${CMAKE_CURRENT_SOURCE_DIR}/macho_embedded)
|
||||||
|
|
||||||
set(CFLAGS "-Oz -Wall -fomit-frame-pointer -ffreestanding")
|
set(CFLAGS -Oz -Wall -fomit-frame-pointer -ffreestanding)
|
||||||
set(CMAKE_C_FLAGS "")
|
set(CMAKE_C_FLAGS "")
|
||||||
set(CMAKE_CXX_FLAGS "")
|
set(CMAKE_CXX_FLAGS "")
|
||||||
set(CMAKE_ASM_FLAGS "")
|
set(CMAKE_ASM_FLAGS "")
|
||||||
|
@ -534,8 +533,8 @@ macro(darwin_add_embedded_builtin_libraries)
|
||||||
set(DARWIN_macho_embedded_LIBRARY_INSTALL_DIR
|
set(DARWIN_macho_embedded_LIBRARY_INSTALL_DIR
|
||||||
${COMPILER_RT_INSTALL_LIBRARY_DIR}/macho_embedded)
|
${COMPILER_RT_INSTALL_LIBRARY_DIR}/macho_embedded)
|
||||||
|
|
||||||
set(CFLAGS_armv7 "-target thumbv7-apple-darwin-eabi")
|
set(CFLAGS_armv7 -target thumbv7-apple-darwin-eabi)
|
||||||
set(CFLAGS_i386 "-march=pentium")
|
set(CFLAGS_i386 -march=pentium)
|
||||||
|
|
||||||
darwin_read_list_from_file(common_FUNCTIONS ${MACHO_SYM_DIR}/common.txt)
|
darwin_read_list_from_file(common_FUNCTIONS ${MACHO_SYM_DIR}/common.txt)
|
||||||
darwin_read_list_from_file(thumb2_FUNCTIONS ${MACHO_SYM_DIR}/thumb2.txt)
|
darwin_read_list_from_file(thumb2_FUNCTIONS ${MACHO_SYM_DIR}/thumb2.txt)
|
||||||
|
|
|
@ -5,19 +5,11 @@ include(CheckSymbolExists)
|
||||||
# define a handy helper function for it. The compile flags setting in CMake
|
# define a handy helper function for it. The compile flags setting in CMake
|
||||||
# has serious issues that make its syntax challenging at best.
|
# has serious issues that make its syntax challenging at best.
|
||||||
function(set_target_compile_flags target)
|
function(set_target_compile_flags target)
|
||||||
set(argstring "")
|
set_property(TARGET ${target} PROPERTY COMPILE_OPTIONS ${ARGN})
|
||||||
foreach(arg ${ARGN})
|
|
||||||
set(argstring "${argstring} ${arg}")
|
|
||||||
endforeach()
|
|
||||||
set_property(TARGET ${target} PROPERTY COMPILE_FLAGS "${argstring}")
|
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
function(set_target_link_flags target)
|
function(set_target_link_flags target)
|
||||||
set(argstring "")
|
set_property(TARGET ${target} PROPERTY LINK_OPTIONS ${ARGN})
|
||||||
foreach(arg ${ARGN})
|
|
||||||
set(argstring "${argstring} ${arg}")
|
|
||||||
endforeach()
|
|
||||||
set_property(TARGET ${target} PROPERTY LINK_FLAGS "${argstring}")
|
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
# Set the variable var_PYBOOL to True if var holds a true-ish string,
|
# Set the variable var_PYBOOL to True if var holds a true-ish string,
|
||||||
|
|
Loading…
Reference in New Issue