comparison compiler-rt/CMakeLists.txt @ 173:0572611fdcc8 llvm10 llvm12

reorgnization done
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 11:55:54 +0900
parents 1d019706d866
children 2e18cbf3894f
comparison
equal deleted inserted replaced
172:9fbae9c8bf63 173:0572611fdcc8
79 # Loading the llvm config causes this target to be imported so place it 79 # Loading the llvm config causes this target to be imported so place it
80 # under the appropriate folder in an IDE. 80 # under the appropriate folder in an IDE.
81 set_target_properties(intrinsics_gen PROPERTIES FOLDER "Compiler-RT Misc") 81 set_target_properties(intrinsics_gen PROPERTIES FOLDER "Compiler-RT Misc")
82 endif() 82 endif()
83 83
84 # Find Python interpreter. 84 if(CMAKE_VERSION VERSION_LESS 3.12)
85 include(FindPythonInterp) 85 # Find Python interpreter.
86 if(NOT PYTHONINTERP_FOUND) 86 include(FindPythonInterp)
87 message(FATAL_ERROR " 87 if(NOT PYTHONINTERP_FOUND)
88 Unable to find Python interpreter required testing. Please install Python 88 message(FATAL_ERROR "
89 or specify the PYTHON_EXECUTABLE CMake variable.") 89 Unable to find Python interpreter required testing. Please install Python
90 or specify the PYTHON_EXECUTABLE CMake variable.")
91 endif()
92
93 add_executable(Python3::Interpreter IMPORTED)
94 set_target_properties(Python3::Interpreter PROPERTIES
95 IMPORTED_LOCATION ${PYTHON_EXECUTABLE})
96 set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE})
97 else()
98 find_package(Python3 COMPONENTS Interpreter)
99 if(NOT Python3_Interpreter_FOUND)
100 message(WARNING "Python3 not found, using python2 as a fallback")
101 find_package(Python2 COMPONENTS Interpreter REQUIRED)
102 if(Python2_VERSION VERSION_LESS 2.7)
103 message(SEND_ERROR "Python 2.7 or newer is required")
104 endif()
105
106 # Treat python2 as python3
107 add_executable(Python3::Interpreter IMPORTED)
108 set_target_properties(Python3::Interpreter PROPERTIES
109 IMPORTED_LOCATION ${Python2_EXECUTABLE})
110 set(Python3_EXECUTABLE ${Python2_EXECUTABLE})
111 endif()
90 endif() 112 endif()
91 113
92 # Ensure that fat libraries are built correctly on Darwin 114 # Ensure that fat libraries are built correctly on Darwin
93 if(CMAKE_HOST_APPLE AND APPLE) 115 if(CMAKE_HOST_APPLE AND APPLE)
94 include(UseLibtool) 116 include(UseLibtool)
278 append_list_if(COMPILER_RT_HAS_FVISIBILITY_HIDDEN_FLAG -fvisibility=hidden SANITIZER_COMMON_CFLAGS) 300 append_list_if(COMPILER_RT_HAS_FVISIBILITY_HIDDEN_FLAG -fvisibility=hidden SANITIZER_COMMON_CFLAGS)
279 if(NOT COMPILER_RT_HAS_FVISIBILITY_HIDDEN_FLAG) 301 if(NOT COMPILER_RT_HAS_FVISIBILITY_HIDDEN_FLAG)
280 append_list_if(COMPILER_RT_HAS_FVISIBILITY_INLINES_HIDDEN_FLAG -fvisibility-inlines-hidden SANITIZER_COMMON_CFLAGS) 302 append_list_if(COMPILER_RT_HAS_FVISIBILITY_INLINES_HIDDEN_FLAG -fvisibility-inlines-hidden SANITIZER_COMMON_CFLAGS)
281 endif() 303 endif()
282 append_list_if(COMPILER_RT_HAS_FNO_LTO_FLAG -fno-lto SANITIZER_COMMON_CFLAGS) 304 append_list_if(COMPILER_RT_HAS_FNO_LTO_FLAG -fno-lto SANITIZER_COMMON_CFLAGS)
305
306 # By default do not instrument or use profdata for compiler-rt.
307 if(NOT COMPILER_RT_ENABLE_PGO)
308 if(LLVM_PROFDATA_FILE AND COMPILER_RT_HAS_FNO_PROFILE_INSTR_USE_FLAG)
309 list(APPEND SANITIZER_COMMON_CFLAGS "-fno-profile-instr-use")
310 endif()
311 if(LLVM_BUILD_INSTRUMENTED MATCHES IR AND COMPILER_RT_HAS_FNO_PROFILE_GENERATE_FLAG)
312 list(APPEND SANITIZER_COMMON_CFLAGS "-fno-profile-generate")
313 elseif(LLVM_BUILD_INSTRUMENTED AND COMPILER_RT_HAS_FNO_PROFILE_INSTR_GENERATE_FLAG)
314 list(APPEND SANITIZER_COMMON_CFLAGS "-fno-profile-instr-generate")
315 endif()
316 endif()
283 317
284 # The following is a workaround for powerpc64le. This is the only architecture 318 # The following is a workaround for powerpc64le. This is the only architecture
285 # that requires -fno-function-sections to work properly. If lacking, the ASan 319 # that requires -fno-function-sections to work properly. If lacking, the ASan
286 # Linux test function-sections-are-bad.cpp fails with the following error: 320 # Linux test function-sections-are-bad.cpp fails with the following error:
287 # 'undefined symbol: __sanitizer_unaligned_load32'. 321 # 'undefined symbol: __sanitizer_unaligned_load32'.
399 # Set common link flags. 433 # Set common link flags.
400 append_list_if(COMPILER_RT_HAS_NODEFAULTLIBS_FLAG -nodefaultlibs SANITIZER_COMMON_LINK_FLAGS) 434 append_list_if(COMPILER_RT_HAS_NODEFAULTLIBS_FLAG -nodefaultlibs SANITIZER_COMMON_LINK_FLAGS)
401 append_list_if(COMPILER_RT_HAS_Z_TEXT -Wl,-z,text SANITIZER_COMMON_LINK_FLAGS) 435 append_list_if(COMPILER_RT_HAS_Z_TEXT -Wl,-z,text SANITIZER_COMMON_LINK_FLAGS)
402 436
403 if (COMPILER_RT_USE_BUILTINS_LIBRARY) 437 if (COMPILER_RT_USE_BUILTINS_LIBRARY)
404 list(APPEND SANITIZER_COMMON_LINK_LIBS ${COMPILER_RT_BUILTINS_LIBRARY})
405 string(REPLACE "-Wl,-z,defs" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}") 438 string(REPLACE "-Wl,-z,defs" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
406 else() 439 else()
407 if (ANDROID) 440 if (ANDROID)
408 append_list_if(COMPILER_RT_HAS_GCC_LIB gcc SANITIZER_COMMON_LINK_LIBS) 441 append_list_if(COMPILER_RT_HAS_GCC_LIB gcc SANITIZER_COMMON_LINK_LIBS)
409 else() 442 else()
516 if (COMPILER_RT_STANDALONE_BUILD) 549 if (COMPILER_RT_STANDALONE_BUILD)
517 # If we have a valid source tree, generate llvm-lit into the bin directory. 550 # If we have a valid source tree, generate llvm-lit into the bin directory.
518 # The user can still choose to have the check targets *use* a different lit 551 # The user can still choose to have the check targets *use* a different lit
519 # by specifying -DLLVM_EXTERNAL_LIT, but we generate it regardless. 552 # by specifying -DLLVM_EXTERNAL_LIT, but we generate it regardless.
520 if (EXISTS ${LLVM_MAIN_SRC_DIR}/utils/llvm-lit) 553 if (EXISTS ${LLVM_MAIN_SRC_DIR}/utils/llvm-lit)
554 # Needed for lit support in standalone builds.
555 include(AddLLVM)
521 add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/llvm-lit ${CMAKE_CURRENT_BINARY_DIR}/llvm-lit) 556 add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/llvm-lit ${CMAKE_CURRENT_BINARY_DIR}/llvm-lit)
522 elseif(NOT EXISTS ${LLVM_EXTERNAL_LIT}) 557 elseif(NOT EXISTS ${LLVM_EXTERNAL_LIT})
523 message(WARNING "Could not find LLVM source directory and LLVM_EXTERNAL_LIT does not" 558 message(WARNING "Could not find LLVM source directory and LLVM_EXTERNAL_LIT does not"
524 "point to a valid file. You will not be able to run tests.") 559 "point to a valid file. You will not be able to run tests.")
525 endif() 560 endif()