diff --git a/flang-rt/CMakeLists.txt b/flang-rt/CMakeLists.txt index 50b8e83..319c496 100644 --- a/flang-rt/CMakeLists.txt +++ b/flang-rt/CMakeLists.txt @@ -138,6 +138,8 @@ cmake_path(NORMAL_PATH FLANG_RT_INSTALL_RESOURCE_LIB_PATH) # with this prefix will be forwarded in bootstrap builds. option(FLANG_RT_INCLUDE_TESTS "Generate build targets for the flang-rt unit and regression-tests." "${LLVM_INCLUDE_TESTS}") +set(FLANG_RT_BUILTINS_LIBRARY "" CACHE FILEPATH + "Path to an existing compiler-rt builtins library to use when Flang-RT needs compiler builtins.") # Provide an interface to link against the LLVM libc/libc++ projects directly. set(FLANG_RT_SUPPORTED_PROVIDERS system llvm) @@ -236,7 +238,9 @@ check_cxx_source_compiles( # Search for clang_rt.builtins library. Need in addition to msvcrt. if (WIN32) - find_compiler_rt_library(builtins FLANG_RT_BUILTINS_LIBRARY) + if (NOT FLANG_RT_BUILTINS_LIBRARY) + find_compiler_rt_library(builtins FLANG_RT_BUILTINS_LIBRARY) + endif () endif () # Build with _XOPEN_SOURCE on AIX to avoid errors caused by _ALL_SOURCE. diff --git a/flang-rt/README.md b/flang-rt/README.md index 4fe66a8..d56fbe1 100644 --- a/flang-rt/README.md +++ b/flang-rt/README.md @@ -138,6 +138,12 @@ CMake itself provide. When `OFF`, does not add any tests and unittests. The `check-flang-rt` build target will do nothing. + * `FLANG_RT_BUILTINS_LIBRARY` (path; default: `""`) + + Path to an existing compiler-rt builtins library. When left empty, Flang-RT + uses the compiler to find the builtins library on platforms where one is + needed. + * `FLANG_RUNTIME_F128_MATH_LIB` (default: `""`) Determines the implementation of `REAL(16)` math functions. If set to diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index fcbfed4..77e4e41 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -654,11 +654,19 @@ if(LLVM_EXPERIMENTAL_TARGETS_TO_BUILD STREQUAL "all") set(LLVM_EXPERIMENTAL_TARGETS_TO_BUILD ${LLVM_ALL_EXPERIMENTAL_TARGETS}) endif() +option(FLANG_USE_SYSTEM_COMPILER_RT + "Use an installed compiler-rt instead of adding compiler-rt to LLVM_ENABLE_RUNTIMES for Flang." + OFF) + if("flang" IN_LIST LLVM_ENABLE_PROJECTS AND "AArch64" IN_LIST LLVM_TARGETS_TO_BUILD AND NOT ("compiler-rt" IN_LIST LLVM_ENABLE_RUNTIMES OR "compiler-rt" IN_LIST LLVM_ENABLE_PROJECTS)) - message(STATUS "Enabling compiler-rt as a dependency of Flang") - list(APPEND LLVM_ENABLE_RUNTIMES "compiler-rt") + if(FLANG_USE_SYSTEM_COMPILER_RT) + message(STATUS "Using system compiler-rt for Flang") + else() + message(STATUS "Enabling compiler-rt as a dependency of Flang") + list(APPEND LLVM_ENABLE_RUNTIMES "compiler-rt") + endif() endif() set(LLVM_TARGETS_TO_BUILD