forked from OSchip/llvm-project
[runtimes] [CMake] Unify variable names
Avoid repeating CMake checks across runtimes by unifying names of variables used for results to leverage CMake caching. Differential Revision: https://reviews.llvm.org/D110005
This commit is contained in:
parent
2fc67af487
commit
b3df14b6c9
|
@ -457,7 +457,7 @@ append_list_if(COMPILER_RT_HAS_WD4800_FLAG /wd4800 SANITIZER_COMMON_CFLAGS)
|
|||
append_list_if(MINGW -fms-extensions SANITIZER_COMMON_CFLAGS)
|
||||
|
||||
# Set common link flags.
|
||||
append_list_if(COMPILER_RT_HAS_NODEFAULTLIBS_FLAG -nodefaultlibs SANITIZER_COMMON_LINK_FLAGS)
|
||||
append_list_if(C_SUPPORTS_NODEFAULTLIBS_FLAG -nodefaultlibs SANITIZER_COMMON_LINK_FLAGS)
|
||||
append_list_if(COMPILER_RT_HAS_Z_TEXT -Wl,-z,text SANITIZER_COMMON_LINK_FLAGS)
|
||||
|
||||
if (COMPILER_RT_USE_BUILTINS_LIBRARY)
|
||||
|
|
|
@ -23,8 +23,8 @@ else()
|
|||
endif()
|
||||
endif()
|
||||
|
||||
check_c_compiler_flag(-nodefaultlibs COMPILER_RT_HAS_NODEFAULTLIBS_FLAG)
|
||||
if (COMPILER_RT_HAS_NODEFAULTLIBS_FLAG)
|
||||
check_c_compiler_flag(-nodefaultlibs C_SUPPORTS_NODEFAULTLIBS_FLAG)
|
||||
if (C_SUPPORTS_NODEFAULTLIBS_FLAG)
|
||||
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nodefaultlibs")
|
||||
if (COMPILER_RT_HAS_LIBC)
|
||||
list(APPEND CMAKE_REQUIRED_LIBRARIES c)
|
||||
|
|
|
@ -593,7 +593,7 @@ function(cxx_add_basic_build_flags target)
|
|||
target_compile_definitions(${target} PRIVATE -D_LIBCPP_DISABLE_NEW_DELETE_DEFINITIONS)
|
||||
endif()
|
||||
|
||||
if (LIBCXX_HAS_COMMENT_LIB_PRAGMA)
|
||||
if (C_SUPPORTS_COMMENT_LIB_PRAGMA)
|
||||
if (LIBCXX_HAS_PTHREAD_LIB)
|
||||
target_compile_definitions(${target} PRIVATE -D_LIBCPP_LINK_PTHREAD_LIB)
|
||||
endif()
|
||||
|
@ -774,7 +774,7 @@ function(cxx_link_system_libraries target)
|
|||
# Unfortunately this cannot be used universally because for example g++ supports
|
||||
# only -nodefaultlibs in which case all libraries will be removed and
|
||||
# all libraries but c++ have to be added in manually.
|
||||
if (LIBCXX_SUPPORTS_NOSTDLIBXX_FLAG)
|
||||
if (CXX_SUPPORTS_NOSTDLIBXX_FLAG)
|
||||
target_add_link_flags_if_supported(${target} PRIVATE "-nostdlib++")
|
||||
else()
|
||||
target_add_link_flags_if_supported(${target} PRIVATE "-nodefaultlibs")
|
||||
|
@ -782,7 +782,7 @@ function(cxx_link_system_libraries target)
|
|||
target_add_link_flags_if_supported(${target} PRIVATE "/nodefaultlib")
|
||||
endif()
|
||||
|
||||
if (LIBCXX_SUPPORTS_UNWINDLIB_NONE_FLAG AND LIBCXXABI_USE_LLVM_UNWINDER)
|
||||
if (CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG AND LIBCXXABI_USE_LLVM_UNWINDER)
|
||||
# If we're linking directly against the libunwind that we're building
|
||||
# in the same invocation, don't try to link in the toolchain's
|
||||
# default libunwind (which may be missing still).
|
||||
|
|
|
@ -42,7 +42,7 @@ endmacro(remove_flags)
|
|||
|
||||
macro(check_flag_supported flag)
|
||||
mangle_name("${flag}" flagname)
|
||||
check_cxx_compiler_flag("${flag}" "LIBCXX_SUPPORTS_${flagname}_FLAG")
|
||||
check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG")
|
||||
endmacro()
|
||||
|
||||
macro(append_flags DEST)
|
||||
|
@ -63,8 +63,8 @@ endmacro()
|
|||
macro(append_flags_if_supported DEST)
|
||||
foreach(flag ${ARGN})
|
||||
mangle_name("${flag}" flagname)
|
||||
check_cxx_compiler_flag("${flag}" "LIBCXX_SUPPORTS_${flagname}_FLAG")
|
||||
append_flags_if(LIBCXX_SUPPORTS_${flagname}_FLAG ${DEST} ${flag})
|
||||
check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG")
|
||||
append_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${DEST} ${flag})
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
|
@ -127,8 +127,8 @@ endmacro()
|
|||
macro(add_target_flags_if_supported)
|
||||
foreach(flag ${ARGN})
|
||||
mangle_name("${flag}" flagname)
|
||||
check_cxx_compiler_flag("${flag}" "LIBCXX_SUPPORTS_${flagname}_FLAG")
|
||||
add_target_flags_if(LIBCXX_SUPPORTS_${flagname}_FLAG ${flag})
|
||||
check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG")
|
||||
add_target_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag})
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
|
@ -154,8 +154,8 @@ endmacro()
|
|||
macro(add_flags_if_supported)
|
||||
foreach(flag ${ARGN})
|
||||
mangle_name("${flag}" flagname)
|
||||
check_cxx_compiler_flag("${flag}" "LIBCXX_SUPPORTS_${flagname}_FLAG")
|
||||
add_flags_if(LIBCXX_SUPPORTS_${flagname}_FLAG ${flag})
|
||||
check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG")
|
||||
add_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag})
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
|
@ -179,8 +179,8 @@ endmacro()
|
|||
macro(add_compile_flags_if_supported)
|
||||
foreach(flag ${ARGN})
|
||||
mangle_name("${flag}" flagname)
|
||||
check_cxx_compiler_flag("${flag}" "LIBCXX_SUPPORTS_${flagname}_FLAG")
|
||||
add_compile_flags_if(LIBCXX_SUPPORTS_${flagname}_FLAG ${flag})
|
||||
check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG")
|
||||
add_compile_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag})
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
|
@ -204,8 +204,8 @@ endmacro()
|
|||
macro(add_link_flags_if_supported)
|
||||
foreach(flag ${ARGN})
|
||||
mangle_name("${flag}" flagname)
|
||||
check_cxx_compiler_flag("${flag}" "LIBCXX_SUPPORTS_${flagname}_FLAG")
|
||||
add_link_flags_if(LIBCXX_SUPPORTS_${flagname}_FLAG ${flag})
|
||||
check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG")
|
||||
add_link_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag})
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
|
@ -234,8 +234,8 @@ endmacro()
|
|||
function(target_add_link_flags_if_supported target visibility)
|
||||
foreach(flag ${ARGN})
|
||||
mangle_name("${flag}" flagname)
|
||||
check_cxx_compiler_flag("${flag}" "LIBCXX_SUPPORTS_${flagname}_FLAG")
|
||||
if (LIBCXX_SUPPORTS_${flagname}_FLAG)
|
||||
check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG")
|
||||
if (CXX_SUPPORTS_${flagname}_FLAG)
|
||||
target_link_libraries(${target} ${visibility} ${flag})
|
||||
endif()
|
||||
endforeach()
|
||||
|
@ -246,8 +246,8 @@ endfunction()
|
|||
function(target_add_compile_flags_if_supported target visibility)
|
||||
foreach(flag ${ARGN})
|
||||
mangle_name("${flag}" flagname)
|
||||
check_cxx_compiler_flag("${flag}" "LIBCXX_SUPPORTS_${flagname}_FLAG")
|
||||
if (LIBCXX_SUPPORTS_${flagname}_FLAG)
|
||||
check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG")
|
||||
if (CXX_SUPPORTS_${flagname}_FLAG)
|
||||
target_compile_options(${target} ${visibility} ${flag})
|
||||
endif()
|
||||
endforeach()
|
||||
|
|
|
@ -12,8 +12,8 @@ include(CheckCSourceCompiles)
|
|||
# libunwind (and the compiler implicit -lunwind wouldn't succeed as the newly
|
||||
# built libunwind isn't installed yet). For those cases, it'd be good to
|
||||
# link with --uwnindlib=none. Check if that option works.
|
||||
llvm_check_compiler_linker_flag(C "--unwindlib=none" LIBCXX_SUPPORTS_UNWINDLIB_NONE_FLAG)
|
||||
if (LIBCXX_SUPPORTS_UNWINDLIB_NONE_FLAG)
|
||||
llvm_check_compiler_linker_flag(C "--unwindlib=none" CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG)
|
||||
if (CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG)
|
||||
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} --unwindlib=none")
|
||||
endif()
|
||||
|
||||
|
@ -46,17 +46,17 @@ endif()
|
|||
# required for the link to go through. We remove sanitizers from the
|
||||
# configuration checks to avoid spurious link errors.
|
||||
|
||||
check_c_compiler_flag(-nostdlib++ LIBCXX_SUPPORTS_NOSTDLIBXX_FLAG)
|
||||
if (LIBCXX_SUPPORTS_NOSTDLIBXX_FLAG)
|
||||
check_cxx_compiler_flag(-nostdlib++ CXX_SUPPORTS_NOSTDLIBXX_FLAG)
|
||||
if (CXX_SUPPORTS_NOSTDLIBXX_FLAG)
|
||||
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++")
|
||||
else()
|
||||
check_c_compiler_flag(-nodefaultlibs LIBCXX_SUPPORTS_NODEFAULTLIBS_FLAG)
|
||||
if (LIBCXX_SUPPORTS_NODEFAULTLIBS_FLAG)
|
||||
check_c_compiler_flag(-nodefaultlibs C_SUPPORTS_NODEFAULTLIBS_FLAG)
|
||||
if (C_SUPPORTS_NODEFAULTLIBS_FLAG)
|
||||
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nodefaultlibs")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (LIBCXX_SUPPORTS_NOSTDLIBXX_FLAG OR LIBCXX_SUPPORTS_NODEFAULTLIBS_FLAG)
|
||||
if (CXX_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG)
|
||||
if (LIBCXX_HAS_C_LIB)
|
||||
list(APPEND CMAKE_REQUIRED_LIBRARIES c)
|
||||
endif ()
|
||||
|
@ -98,7 +98,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
|||
check_c_source_compiles("
|
||||
#pragma comment(lib, \"c\")
|
||||
int main() { return 0; }
|
||||
" LIBCXX_HAS_COMMENT_LIB_PRAGMA)
|
||||
" C_SUPPORTS_COMMENT_LIB_PRAGMA)
|
||||
cmake_pop_check_state()
|
||||
endif()
|
||||
|
||||
|
|
|
@ -276,7 +276,7 @@ endif()
|
|||
# Configure compiler. Must happen after setting the target flags.
|
||||
include(config-ix)
|
||||
|
||||
if (LIBCXXABI_HAS_NOSTDINCXX_FLAG)
|
||||
if (CXX_SUPPORTS_NOSTDINCXX_FLAG)
|
||||
list(APPEND LIBCXXABI_COMPILE_FLAGS -nostdinc++)
|
||||
# cmake 3.14 and above remove system include paths that are explicitly
|
||||
# passed on the command line. We build with -nostdinc++ and explicitly add
|
||||
|
@ -497,7 +497,7 @@ if (LIBCXXABI_BAREMETAL)
|
|||
add_definitions(-DLIBCXXABI_BAREMETAL)
|
||||
endif()
|
||||
|
||||
if (LIBCXXABI_HAS_COMMENT_LIB_PRAGMA)
|
||||
if (C_SUPPORTS_COMMENT_LIB_PRAGMA)
|
||||
if (LIBCXXABI_HAS_PTHREAD_LIB)
|
||||
add_definitions(-D_LIBCXXABI_LINK_PTHREAD_LIB)
|
||||
endif()
|
||||
|
|
|
@ -41,7 +41,7 @@ endmacro(remove_flags)
|
|||
|
||||
macro(check_flag_supported flag)
|
||||
mangle_name("${flag}" flagname)
|
||||
check_cxx_compiler_flag("${flag}" "LIBCXXABI_SUPPORTS_${flagname}_FLAG")
|
||||
check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG")
|
||||
endmacro()
|
||||
|
||||
macro(append_flags DEST)
|
||||
|
@ -62,8 +62,8 @@ endmacro()
|
|||
macro(append_flags_if_supported DEST)
|
||||
foreach(flag ${ARGN})
|
||||
mangle_name("${flag}" flagname)
|
||||
check_cxx_compiler_flag("${flag}" "LIBCXXABI_SUPPORTS_${flagname}_FLAG")
|
||||
append_flags_if(LIBCXXABI_SUPPORTS_${flagname}_FLAG ${DEST} ${flag})
|
||||
check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG")
|
||||
append_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${DEST} ${flag})
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
|
@ -129,8 +129,8 @@ endmacro()
|
|||
macro(add_target_flags_if_supported)
|
||||
foreach(flag ${ARGN})
|
||||
mangle_name("${flag}" flagname)
|
||||
check_cxx_compiler_flag("${flag}" "LIBCXXABI_SUPPORTS_${flagname}_FLAG")
|
||||
add_target_flags_if(LIBCXXABI_SUPPORTS_${flagname}_FLAG ${flag})
|
||||
check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG")
|
||||
add_target_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag})
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
|
@ -156,8 +156,8 @@ endmacro()
|
|||
macro(add_flags_if_supported)
|
||||
foreach(flag ${ARGN})
|
||||
mangle_name("${flag}" flagname)
|
||||
check_cxx_compiler_flag("${flag}" "LIBCXXABI_SUPPORTS_${flagname}_FLAG")
|
||||
add_flags_if(LIBCXXABI_SUPPORTS_${flagname}_FLAG ${flag})
|
||||
check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG")
|
||||
add_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag})
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
|
@ -181,8 +181,8 @@ endmacro()
|
|||
macro(add_compile_flags_if_supported)
|
||||
foreach(flag ${ARGN})
|
||||
mangle_name("${flag}" flagname)
|
||||
check_cxx_compiler_flag("${flag}" "LIBCXXABI_SUPPORTS_${flagname}_FLAG")
|
||||
add_compile_flags_if(LIBCXXABI_SUPPORTS_${flagname}_FLAG ${flag})
|
||||
check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG")
|
||||
add_compile_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag})
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
|
@ -191,8 +191,8 @@ endmacro()
|
|||
macro(add_c_compile_flags_if_supported)
|
||||
foreach(flag ${ARGN})
|
||||
mangle_name("${flag}" flagname)
|
||||
check_c_compiler_flag("${flag}" "LIBCXXABI_SUPPORTS_${flagname}_FLAG")
|
||||
add_compile_flags_if(LIBCXXABI_SUPPORTS_${flagname}_FLAG ${flag})
|
||||
check_c_compiler_flag("${flag}" "C_SUPPORTS_${flagname}_FLAG")
|
||||
add_compile_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag})
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
|
@ -216,8 +216,8 @@ endmacro()
|
|||
macro(add_link_flags_if_supported)
|
||||
foreach(flag ${ARGN})
|
||||
mangle_name("${flag}" flagname)
|
||||
check_cxx_compiler_flag("${flag}" "LIBCXXABI_SUPPORTS_${flagname}_FLAG")
|
||||
add_link_flags_if(LIBCXXABI_SUPPORTS_${flagname}_FLAG ${flag})
|
||||
check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG")
|
||||
add_link_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag})
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
|
|
|
@ -23,17 +23,17 @@ endif ()
|
|||
# required for the link to go through. We remove sanitizers from the
|
||||
# configuration checks to avoid spurious link errors.
|
||||
|
||||
check_c_compiler_flag(-nostdlib++ LIBCXXABI_SUPPORTS_NOSTDLIBXX_FLAG)
|
||||
if (LIBCXXABI_SUPPORTS_NOSTDLIBXX_FLAG)
|
||||
check_cxx_compiler_flag(-nostdlib++ CXX_SUPPORTS_NOSTDLIBXX_FLAG)
|
||||
if (CXX_SUPPORTS_NOSTDLIBXX_FLAG)
|
||||
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++")
|
||||
else()
|
||||
check_c_compiler_flag(-nodefaultlibs LIBCXXABI_SUPPORTS_NODEFAULTLIBS_FLAG)
|
||||
if (LIBCXXABI_SUPPORTS_NODEFAULTLIBS_FLAG)
|
||||
check_c_compiler_flag(-nodefaultlibs C_SUPPORTS_NODEFAULTLIBS_FLAG)
|
||||
if (C_SUPPORTS_NODEFAULTLIBS_FLAG)
|
||||
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nodefaultlibs")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (LIBCXXABI_SUPPORTS_NOSTDLIBXX_FLAG OR LIBCXXABI_SUPPORTS_NODEFAULTLIBS_FLAG)
|
||||
if (CXX_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG)
|
||||
if (LIBCXXABI_HAS_C_LIB)
|
||||
list(APPEND CMAKE_REQUIRED_LIBRARIES c)
|
||||
endif ()
|
||||
|
@ -78,12 +78,12 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
|||
check_c_source_compiles("
|
||||
#pragma comment(lib, \"c\")
|
||||
int main() { return 0; }
|
||||
" LIBCXXABI_HAS_COMMENT_LIB_PRAGMA)
|
||||
" C_SUPPORTS_COMMENT_LIB_PRAGMA)
|
||||
cmake_pop_check_state()
|
||||
endif()
|
||||
|
||||
# Check compiler flags
|
||||
check_cxx_compiler_flag(-nostdinc++ LIBCXXABI_HAS_NOSTDINCXX_FLAG)
|
||||
check_cxx_compiler_flag(-nostdinc++ CXX_SUPPORTS_NOSTDINCXX_FLAG)
|
||||
|
||||
# Check libraries
|
||||
if(FUCHSIA)
|
||||
|
|
|
@ -116,7 +116,7 @@ if (NOT LIBCXXABI_USE_COMPILER_RT)
|
|||
endif ()
|
||||
|
||||
# Setup flags.
|
||||
if (LIBCXXABI_SUPPORTS_NOSTDLIBXX_FLAG)
|
||||
if (CXX_SUPPORTS_NOSTDLIBXX_FLAG)
|
||||
add_link_flags_if_supported(-nostdlib++)
|
||||
else()
|
||||
add_link_flags_if_supported(-nodefaultlibs)
|
||||
|
|
|
@ -276,7 +276,7 @@ set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
|
|||
add_compile_flags_if_supported(-funwind-tables)
|
||||
set(CMAKE_TRY_COMPILE_TARGET_TYPE ${_previous_CMAKE_TRY_COMPILE_TARGET_TYPE})
|
||||
|
||||
if (LIBUNWIND_USES_ARM_EHABI AND NOT LIBUNWIND_SUPPORTS_FUNWIND_TABLES_FLAG)
|
||||
if (LIBUNWIND_USES_ARM_EHABI AND NOT CXX_SUPPORTS_FUNWIND_TABLES_FLAG)
|
||||
message(SEND_ERROR "The -funwind-tables flag must be supported "
|
||||
"because this target uses ARM Exception Handling ABI")
|
||||
endif()
|
||||
|
@ -285,7 +285,7 @@ add_cxx_compile_flags_if_supported(-fno-exceptions)
|
|||
add_cxx_compile_flags_if_supported(-fno-rtti)
|
||||
|
||||
# Ensure that we don't depend on C++ standard library.
|
||||
if (LIBUNWIND_HAS_NOSTDINCXX_FLAG)
|
||||
if (CXX_SUPPORTS_NOSTDINCXX_FLAG)
|
||||
list(APPEND LIBUNWIND_COMPILE_FLAGS -nostdinc++)
|
||||
# Remove -stdlib flags to prevent them from causing an unused flag warning.
|
||||
string(REPLACE "--stdlib=libc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
|
@ -354,7 +354,7 @@ if (WIN32 AND LIBUNWIND_ENABLE_STATIC AND NOT LIBUNWIND_ENABLE_SHARED)
|
|||
add_definitions(-D_LIBUNWIND_HIDE_SYMBOLS)
|
||||
endif()
|
||||
|
||||
if (LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
|
||||
if (C_SUPPORTS_COMMENT_LIB_PRAGMA)
|
||||
if (LIBUNWIND_HAS_DL_LIB)
|
||||
add_definitions(-D_LIBUNWIND_LINK_DL_LIB)
|
||||
endif()
|
||||
|
|
|
@ -42,7 +42,7 @@ endmacro(remove_flags)
|
|||
|
||||
macro(check_flag_supported flag)
|
||||
mangle_name("${flag}" flagname)
|
||||
check_cxx_compiler_flag("${flag}" "LIBUNWIND_SUPPORTS_${flagname}_FLAG")
|
||||
check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG")
|
||||
endmacro()
|
||||
|
||||
macro(append_flags DEST)
|
||||
|
@ -63,8 +63,8 @@ endmacro()
|
|||
macro(append_flags_if_supported DEST)
|
||||
foreach(flag ${ARGN})
|
||||
mangle_name("${flag}" flagname)
|
||||
check_cxx_compiler_flag("${flag}" "LIBUNWIND_SUPPORTS_${flagname}_FLAG")
|
||||
append_flags_if(LIBUNWIND_SUPPORTS_${flagname}_FLAG ${DEST} ${flag})
|
||||
check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG")
|
||||
append_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${DEST} ${flag})
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
|
@ -130,8 +130,8 @@ endmacro()
|
|||
macro(add_target_flags_if_supported)
|
||||
foreach(flag ${ARGN})
|
||||
mangle_name("${flag}" flagname)
|
||||
check_cxx_compiler_flag("${flag}" "LIBUNWIND_SUPPORTS_${flagname}_FLAG")
|
||||
add_target_flags_if(LIBUNWIND_SUPPORTS_${flagname}_FLAG ${flag})
|
||||
check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG")
|
||||
add_target_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag})
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
|
@ -157,8 +157,8 @@ endmacro()
|
|||
macro(add_flags_if_supported)
|
||||
foreach(flag ${ARGN})
|
||||
mangle_name("${flag}" flagname)
|
||||
check_cxx_compiler_flag("${flag}" "LIBUNWIND_SUPPORTS_${flagname}_FLAG")
|
||||
add_flags_if(LIBUNWIND_SUPPORTS_${flagname}_FLAG ${flag})
|
||||
check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG")
|
||||
add_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag})
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
|
@ -182,8 +182,8 @@ endmacro()
|
|||
macro(add_compile_flags_if_supported)
|
||||
foreach(flag ${ARGN})
|
||||
mangle_name("${flag}" flagname)
|
||||
check_cxx_compiler_flag("${flag}" "LIBUNWIND_SUPPORTS_${flagname}_FLAG")
|
||||
add_compile_flags_if(LIBUNWIND_SUPPORTS_${flagname}_FLAG ${flag})
|
||||
check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG")
|
||||
add_compile_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag})
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
|
@ -207,8 +207,8 @@ endmacro()
|
|||
macro(add_c_compile_flags_if_supported)
|
||||
foreach(flag ${ARGN})
|
||||
mangle_name("${flag}" flagname)
|
||||
check_c_compiler_flag("${flag}" "LIBUNWIND_SUPPORTS_${flagname}_FLAG")
|
||||
add_c_flags_if(LIBUNWIND_SUPPORTS_${flagname}_FLAG ${flag})
|
||||
check_c_compiler_flag("${flag}" "C_SUPPORTS_${flagname}_FLAG")
|
||||
add_c_flags_if(C_SUPPORTS_${flagname}_FLAG ${flag})
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
|
@ -232,8 +232,8 @@ endmacro()
|
|||
macro(add_cxx_compile_flags_if_supported)
|
||||
foreach(flag ${ARGN})
|
||||
mangle_name("${flag}" flagname)
|
||||
check_cxx_compiler_flag("${flag}" "LIBUNWIND_SUPPORTS_${flagname}_FLAG")
|
||||
add_cxx_flags_if(LIBUNWIND_SUPPORTS_${flagname}_FLAG ${flag})
|
||||
check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG")
|
||||
add_cxx_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag})
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
|
@ -257,8 +257,8 @@ endmacro()
|
|||
macro(add_link_flags_if_supported)
|
||||
foreach(flag ${ARGN})
|
||||
mangle_name("${flag}" flagname)
|
||||
check_cxx_compiler_flag("${flag}" "LIBUNWIND_SUPPORTS_${flagname}_FLAG")
|
||||
add_link_flags_if(LIBUNWIND_SUPPORTS_${flagname}_FLAG ${flag})
|
||||
check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG")
|
||||
add_link_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag})
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
|
|
|
@ -9,8 +9,8 @@ include(CheckCSourceCompiles)
|
|||
# The compiler driver may be implicitly trying to link against libunwind, which
|
||||
# might not work if libunwind doesn't exist yet. Try to check if
|
||||
# --unwindlib=none is supported, and use that if possible.
|
||||
llvm_check_compiler_linker_flag(C "--unwindlib=none" LIBUNWIND_SUPPORTS_UNWINDLIB_NONE_FLAG)
|
||||
if (LIBUNWIND_SUPPORTS_UNWINDLIB_NONE_FLAG)
|
||||
llvm_check_compiler_linker_flag(C "--unwindlib=none" CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG)
|
||||
if (CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG)
|
||||
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} --unwindlib=none")
|
||||
endif()
|
||||
|
||||
|
@ -34,17 +34,17 @@ endif()
|
|||
# required for the link to go through. We remove sanitizers from the
|
||||
# configuration checks to avoid spurious link errors.
|
||||
|
||||
llvm_check_compiler_linker_flag(C "-nostdlib++" LIBUNWIND_SUPPORTS_NOSTDLIBXX_FLAG)
|
||||
if (LIBUNWIND_SUPPORTS_NOSTDLIBXX_FLAG)
|
||||
llvm_check_compiler_linker_flag(C "-nostdlib++" CXX_SUPPORTS_NOSTDLIBXX_FLAG)
|
||||
if (CXX_SUPPORTS_NOSTDLIBXX_FLAG)
|
||||
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++")
|
||||
else()
|
||||
llvm_check_compiler_linker_flag(C "-nodefaultlibs" LIBUNWIND_SUPPORTS_NODEFAULTLIBS_FLAG)
|
||||
if (LIBUNWIND_SUPPORTS_NODEFAULTLIBS_FLAG)
|
||||
if (C_SUPPORTS_NODEFAULTLIBS_FLAG)
|
||||
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nodefaultlibs")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (LIBUNWIND_SUPPORTS_NOSTDLIBXX_FLAG OR LIBUNWIND_SUPPORTS_NODEFAULTLIBS_FLAG)
|
||||
if (CXX_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG)
|
||||
if (LIBUNWIND_HAS_C_LIB)
|
||||
list(APPEND CMAKE_REQUIRED_LIBRARIES c)
|
||||
endif ()
|
||||
|
@ -89,12 +89,12 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
|||
check_c_source_compiles("
|
||||
#pragma comment(lib, \"c\")
|
||||
int main() { return 0; }
|
||||
" LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
|
||||
" C_SUPPORTS_COMMENT_LIB_PRAGMA)
|
||||
cmake_pop_check_state()
|
||||
endif()
|
||||
|
||||
# Check compiler flags
|
||||
check_cxx_compiler_flag(-nostdinc++ LIBUNWIND_HAS_NOSTDINCXX_FLAG)
|
||||
check_cxx_compiler_flag(-nostdinc++ CXX_SUPPORTS_NOSTDINCXX_FLAG)
|
||||
|
||||
# Check symbols
|
||||
check_symbol_exists(__arm__ "" LIBUNWIND_TARGET_ARM)
|
||||
|
|
|
@ -93,8 +93,8 @@ if (LIBUNWIND_ENABLE_THREADS)
|
|||
endif()
|
||||
|
||||
# Setup flags.
|
||||
add_link_flags_if(LIBUNWIND_SUPPORTS_UNWINDLIB_NONE_FLAG --unwindlib=none)
|
||||
if (LIBUNWIND_SUPPORTS_NOSTDLIBXX_FLAG)
|
||||
add_link_flags_if(CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG --unwindlib=none)
|
||||
if (CXX_SUPPORTS_NOSTDLIBXX_FLAG)
|
||||
add_link_flags_if_supported(-nostdlib++)
|
||||
else()
|
||||
add_link_flags_if_supported(-nodefaultlibs)
|
||||
|
@ -104,8 +104,8 @@ endif()
|
|||
add_library_flags_if(MINGW "${MINGW_LIBRARIES}")
|
||||
|
||||
if (LIBUNWIND_ENABLE_SHARED AND
|
||||
NOT (LIBUNWIND_SUPPORTS_FNO_EXCEPTIONS_FLAG AND
|
||||
LIBUNWIND_SUPPORTS_FUNWIND_TABLES_FLAG))
|
||||
NOT (CXX_SUPPORTS_FNO_EXCEPTIONS_FLAG AND
|
||||
CXX_SUPPORTS_FUNWIND_TABLES_FLAG))
|
||||
message(FATAL_ERROR
|
||||
"Compiler doesn't support generation of unwind tables if exception "
|
||||
"support is disabled. Building libunwind DSO with runtime dependency "
|
||||
|
|
|
@ -110,12 +110,12 @@ endif()
|
|||
# Check for -nostdlib++ first; if there's no C++ standard library yet,
|
||||
# all check_cxx_compiler_flag commands will fail until we add -nostdlib++
|
||||
# (or -nodefaultlibs).
|
||||
llvm_check_compiler_linker_flag(C "-nostdlib++" LLVM_RUNTIMES_SUPPORT_NOSTDLIBXX_FLAG)
|
||||
if (LLVM_RUNTIMES_SUPPORT_NOSTDLIBXX_FLAG)
|
||||
llvm_check_compiler_linker_flag(C "-nostdlib++" CXX_SUPPORTS_NOSTDLIBXX_FLAG)
|
||||
if (CXX_SUPPORTS_NOSTDLIBXX_FLAG)
|
||||
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++")
|
||||
endif()
|
||||
check_cxx_compiler_flag(-nostdinc++ LLVM_RUNTIMES_SUPPORT_NOSTDINCXX_FLAG)
|
||||
if (LLVM_RUNTIMES_SUPPORT_NOSTDINCXX_FLAG)
|
||||
check_cxx_compiler_flag(-nostdinc++ CXX_SUPPORTS_NOSTDINCXX_FLAG)
|
||||
if (CXX_SUPPORTS_NOSTDINCXX_FLAG)
|
||||
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdinc++")
|
||||
endif()
|
||||
|
||||
|
|
Loading…
Reference in New Issue