brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.5 KiB · d42ceff Raw
74 lines · plain
1include(CMakePushCheckState)2include(CheckCCompilerFlag)3include(CheckCXXCompilerFlag)4include(CheckLibraryExists)5include(LLVMCheckCompilerLinkerFlag)6include(CheckSymbolExists)7include(CheckCSourceCompiles)8 9# The compiler driver may be implicitly trying to link against libunwind, which10# might not work if libunwind doesn't exist yet. Try to check if11# --unwindlib=none is supported, and use that if possible.12llvm_check_compiler_linker_flag(C "--unwindlib=none" CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG)13 14if (HAIKU)15  check_library_exists(root fopen "" LIBUNWIND_HAS_ROOT_LIB)16else()17  check_library_exists(c fopen "" LIBUNWIND_HAS_C_LIB)18endif()19 20if (NOT LIBUNWIND_USE_COMPILER_RT)21  if (ANDROID)22    check_library_exists(gcc __gcc_personality_v0 "" LIBUNWIND_HAS_GCC_LIB)23  else ()24    check_library_exists(gcc_s __gcc_personality_v0 "" LIBUNWIND_HAS_GCC_S_LIB)25    check_library_exists(gcc __absvdi2 "" LIBUNWIND_HAS_GCC_LIB)26  endif ()27endif()28 29if (CXX_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG)30  if (CMAKE_C_FLAGS MATCHES -fsanitize OR CMAKE_CXX_FLAGS MATCHES -fsanitize)31    set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-sanitize=all")32  endif ()33  if (CMAKE_C_FLAGS MATCHES -fsanitize-coverage OR CMAKE_CXX_FLAGS MATCHES -fsanitize-coverage)34    set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fsanitize-coverage=0")35  endif ()36endif ()37 38# Check compiler pragmas39if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")40  cmake_push_check_state()41  set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror=unknown-pragmas")42  check_c_source_compiles("43#pragma comment(lib, \"c\")44int main(void) { return 0; }45" C_SUPPORTS_COMMENT_LIB_PRAGMA)46  cmake_pop_check_state()47endif()48 49# Check compiler flags50check_cxx_compiler_flag(-nostdinc++ CXX_SUPPORTS_NOSTDINCXX_FLAG)51 52# Check symbols53check_symbol_exists(__arm__ "" LIBUNWIND_TARGET_ARM)54check_symbol_exists(__USING_SJLJ_EXCEPTIONS__ "" LIBUNWIND_USES_SJLJ_EXCEPTIONS)55check_symbol_exists(__ARM_DWARF_EH__ "" LIBUNWIND_USES_DWARF_EH)56 57if(LIBUNWIND_TARGET_ARM AND NOT LIBUNWIND_USES_SJLJ_EXCEPTIONS AND NOT LIBUNWIND_USES_DWARF_EH)58  # This condition is copied from __libunwind_config.h59  set(LIBUNWIND_USES_ARM_EHABI ON)60endif()61 62# Check libraries63if(FUCHSIA)64  set(LIBUNWIND_HAS_DL_LIB NO)65  set(LIBUNWIND_HAS_PTHREAD_LIB NO)66else()67  check_library_exists(dl dladdr "" LIBUNWIND_HAS_DL_LIB)68  check_library_exists(pthread pthread_once "" LIBUNWIND_HAS_PTHREAD_LIB)69endif()70 71if(HAIKU)72  check_library_exists(bsd dl_iterate_phdr "" LIBUNWIND_HAS_BSD_LIB)73endif()74