[compiler-rt] 30dfe01 - [CMake][compiler-rt] Use COMPILE_OPTIONS and LINK_OPTIONS
Petr Hosek via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 23 23:56:25 PDT 2022
Author: Petr Hosek
Date: 2022-06-24T06:55:10Z
New Revision: 30dfe016d4259398689dc1be163e0ecc804b5feb
URL: https://github.com/llvm/llvm-project/commit/30dfe016d4259398689dc1be163e0ecc804b5feb
DIFF: https://github.com/llvm/llvm-project/commit/30dfe016d4259398689dc1be163e0ecc804b5feb.diff
LOG: [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
Added:
Modified:
compiler-rt/cmake/Modules/AddCompilerRT.cmake
compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
compiler-rt/cmake/Modules/CompilerRTUtils.cmake
Removed:
################################################################################
diff --git a/compiler-rt/cmake/Modules/AddCompilerRT.cmake b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
index 502200654f042..b7eb04327bb1d 100644
--- a/compiler-rt/cmake/Modules/AddCompilerRT.cmake
+++ b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
@@ -83,8 +83,7 @@ function(add_compiler_rt_object_libraries name)
"${libname}" MATCHES ".*\.osx.*")
foreach(arch ${LIB_ARCHS_${libname}})
list(APPEND target_flags
- -target ${arch}-apple-macos${DARWIN_osx_MIN_VER}
- -darwin-target-variant ${arch}-apple-ios13.1-macabi)
+ "SHELL:-target ${arch}-apple-macos${DARWIN_osx_MIN_VER} -darwin-target-variant ${arch}-apple-ios13.1-macabi")
endforeach()
endif()
@@ -251,11 +250,9 @@ function(add_compiler_rt_runtime name type)
"${os}" MATCHES "^(osx)$")
foreach(arch ${LIB_ARCHS_${libname}})
list(APPEND extra_cflags_${libname}
- -target ${arch}-apple-macos${DARWIN_osx_MIN_VER}
- -darwin-target-variant ${arch}-apple-ios13.1-macabi)
+ "SHELL:-target ${arch}-apple-macos${DARWIN_osx_MIN_VER} -darwin-target-variant ${arch}-apple-ios13.1-macabi")
list(APPEND extra_link_flags_${libname}
- -target ${arch}-apple-macos${DARWIN_osx_MIN_VER}
- -darwin-target-variant ${arch}-apple-ios13.1-macabi)
+ "SHELL:-target ${arch}-apple-macos${DARWIN_osx_MIN_VER} -darwin-target-variant ${arch}-apple-ios13.1-macabi")
endforeach()
endif()
endforeach()
diff --git a/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake b/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
index 4782e727e1c87..2c9983c6a1ae3 100644
--- a/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
+++ b/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
@@ -304,8 +304,7 @@ macro(darwin_add_builtin_library name suffix)
"${LIB_OS}" MATCHES "^osx$")
# Build the macOS builtins with Mac Catalyst support.
list(APPEND builtin_cflags
- -target ${LIB_ARCH}-apple-macos${DARWIN_osx_BUILTIN_MIN_VER}
- -darwin-target-variant ${LIB_ARCH}-apple-ios13.1-macabi)
+ "SHELL:-target ${LIB_ARCH}-apple-macos${DARWIN_osx_BUILTIN_MIN_VER} -darwin-target-variant ${LIB_ARCH}-apple-ios13.1-macabi")
endif()
set_target_compile_flags(${libname}
@@ -400,12 +399,12 @@ endfunction()
macro(darwin_add_builtin_libraries)
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_CXX_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
../profile/InstrProfilingBuffer.c
@@ -515,7 +514,7 @@ macro(darwin_add_embedded_builtin_libraries)
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_CXX_FLAGS "")
set(CMAKE_ASM_FLAGS "")
@@ -534,8 +533,8 @@ macro(darwin_add_embedded_builtin_libraries)
set(DARWIN_macho_embedded_LIBRARY_INSTALL_DIR
${COMPILER_RT_INSTALL_LIBRARY_DIR}/macho_embedded)
- set(CFLAGS_armv7 "-target thumbv7-apple-darwin-eabi")
- set(CFLAGS_i386 "-march=pentium")
+ set(CFLAGS_armv7 -target thumbv7-apple-darwin-eabi)
+ set(CFLAGS_i386 -march=pentium)
darwin_read_list_from_file(common_FUNCTIONS ${MACHO_SYM_DIR}/common.txt)
darwin_read_list_from_file(thumb2_FUNCTIONS ${MACHO_SYM_DIR}/thumb2.txt)
diff --git a/compiler-rt/cmake/Modules/CompilerRTUtils.cmake b/compiler-rt/cmake/Modules/CompilerRTUtils.cmake
index 8b7d71635eb19..9b5e03a6607ba 100644
--- a/compiler-rt/cmake/Modules/CompilerRTUtils.cmake
+++ b/compiler-rt/cmake/Modules/CompilerRTUtils.cmake
@@ -5,19 +5,11 @@ include(CheckSymbolExists)
# define a handy helper function for it. The compile flags setting in CMake
# has serious issues that make its syntax challenging at best.
function(set_target_compile_flags target)
- set(argstring "")
- foreach(arg ${ARGN})
- set(argstring "${argstring} ${arg}")
- endforeach()
- set_property(TARGET ${target} PROPERTY COMPILE_FLAGS "${argstring}")
+ set_property(TARGET ${target} PROPERTY COMPILE_OPTIONS ${ARGN})
endfunction()
function(set_target_link_flags target)
- set(argstring "")
- foreach(arg ${ARGN})
- set(argstring "${argstring} ${arg}")
- endforeach()
- set_property(TARGET ${target} PROPERTY LINK_FLAGS "${argstring}")
+ set_property(TARGET ${target} PROPERTY LINK_OPTIONS ${ARGN})
endfunction()
# Set the variable var_PYBOOL to True if var holds a true-ish string,
More information about the llvm-commits
mailing list