diff --git a/flang-rt/CMakeLists.txt b/flang-rt/CMakeLists.txt index 33b987735979..b0e40bba44d8 100644 --- a/flang-rt/CMakeLists.txt +++ b/flang-rt/CMakeLists.txt @@ -139,7 +139,6 @@ cmake_path(NORMAL_PATH FLANG_RT_INSTALL_RESOURCE_LIB_PATH) # Important: flang-rt user options must be prefixed with "FLANG_RT_". Variables # with this prefix will be forwarded in bootstrap builds. - # Provide an interface to link against the LLVM libc/libc++ projects directly. set(FLANG_RT_SUPPORTED_PROVIDERS system llvm) set(FLANG_RT_LIBC_PROVIDER "system" CACHE STRING "Specify C library to use. Supported values are ${FLANG_RT_SUPPORTED_PROVIDERS}.") @@ -169,7 +168,7 @@ endif () # TODO: Support tests for the GPU target. set(FLANG_RT_INCLUDE_TESTS_default ${LLVM_INCLUDE_TESTS}) -if ("${LLVM_RUNTIMES_TARGET}" MATCHES "^amdgcn|^nvptx") +if ("${LLVM_DEFAULT_TARGET_TRIPLE}" MATCHES "^amdgcn|^nvptx") set(FLANG_RT_INCLUDE_TESTS_default OFF) elseif (NOT FLANG_RT_ENABLE_STATIC AND NOT FLANG_RT_ENABLE_SHARED) set(FLANG_RT_INCLUDE_TESTS_default OFF) @@ -268,7 +267,7 @@ find_package(Threads) # FIXME: The NVPTX target will erroneously report it has backtrace support. This # is caused by using "-c -flto" in the required flags to suppress CUDA # tools from being required for the CMake flag checks to succeed. -if (NOT "${LLVM_RUNTIMES_TARGET}" MATCHES "^nvptx") +if (NOT "${LLVM_DEFAULT_TARGET_TRIPLE}" MATCHES "^nvptx") find_package(Backtrace) endif() set(HAVE_BACKTRACE ${Backtrace_FOUND}) diff --git a/flang-rt/README.md b/flang-rt/README.md index a7dde887b31e..68bc9c9f6057 100644 --- a/flang-rt/README.md +++ b/flang-rt/README.md @@ -112,11 +112,10 @@ The `CMAKE_Fortran_COMPILER_WORKS` parameter must be set because otherwise CMake will test whether the Fortran compiler can compile and link programs which will obviously fail without a runtime library available yet. -Building Flang-RT for cross-compilation triple, the target triple can -be selected using `LLVM_DEFAULT_TARGET_TRIPLE` AND `LLVM_RUNTIMES_TARGET`. -Of course, Flang-RT can be built multiple times with different build -configurations, but have to be located manually when using with the Flang -driver using the `-L` option. +Building Flang-RT for cross-compilation triple, the target triple can be +selected using `LLVM_DEFAULT_TARGET_TRIPLE`. Of course, Flang-RT can be built +multiple times with different build configurations, but have to be located +manually when using with the Flang driver using the `-L` option. After configuration, build, test, and install the runtime via diff --git a/flang-rt/cmake/modules/AddFlangRT.cmake b/flang-rt/cmake/modules/AddFlangRT.cmake index 8f49299ddc6a..2cca6d8adb3d 100644 --- a/flang-rt/cmake/modules/AddFlangRT.cmake +++ b/flang-rt/cmake/modules/AddFlangRT.cmake @@ -266,11 +266,11 @@ function (add_flangrt_library name) endif () # Add target specific options if necessary. - if ("${LLVM_RUNTIMES_TARGET}" MATCHES "^amdgcn") + if ("${LLVM_DEFAULT_TARGET_TRIPLE}" MATCHES "^amdgcn") target_compile_options(${tgtname} PRIVATE $<$:-nogpulib -flto -fvisibility=hidden> ) - elseif ("${LLVM_RUNTIMES_TARGET}" MATCHES "^nvptx") + elseif ("${LLVM_DEFAULT_TARGET_TRIPLE}" MATCHES "^nvptx") target_compile_options(${tgtname} PRIVATE $<$:-nogpulib -flto -fvisibility=hidden -Wno-unknown-cuda-version --cuda-feature=+ptx63> ) diff --git a/flang-rt/lib/runtime/CMakeLists.txt b/flang-rt/lib/runtime/CMakeLists.txt index ad3b1f187f28..cc5d88e98532 100644 --- a/flang-rt/lib/runtime/CMakeLists.txt +++ b/flang-rt/lib/runtime/CMakeLists.txt @@ -188,7 +188,7 @@ if (TARGET FortranFloat128MathILib) endif () endif () -if ("${LLVM_RUNTIMES_TARGET}" MATCHES "^amdgcn|^nvptx") +if ("${LLVM_DEFAULT_TARGET_TRIPLE}" MATCHES "^amdgcn|^nvptx") set(sources ${gpu_sources}) elseif(FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT STREQUAL "CUDA") set(sources ${supported_sources}) diff --git a/libc/cmake/modules/LLVMLibCArchitectures.cmake b/libc/cmake/modules/LLVMLibCArchitectures.cmake index bb96c07b1e7a..b24ea353df48 100644 --- a/libc/cmake/modules/LLVMLibCArchitectures.cmake +++ b/libc/cmake/modules/LLVMLibCArchitectures.cmake @@ -98,21 +98,22 @@ string(SUBSTRING ${libc_compiler_target_info} 8 -1 libc_compiler_triple) # One should not set LLVM_RUNTIMES_TARGET and LIBC_TARGET_TRIPLE if(LLVM_RUNTIMES_TARGET AND LIBC_TARGET_TRIPLE) message(FATAL_ERROR - "libc build: Specify only LLVM_RUNTIMES_TARGET if you are doing a " + "libc build: Specify only LLVM_DEFAULT_TARGET_TRIPLE if you are doing a " "runtimes/bootstrap build. If you are doing a standalone build, " "specify only LIBC_TARGET_TRIPLE.") endif() set(explicit_target_triple) if(LLVM_RUNTIMES_TARGET) - set(explicit_target_triple ${LLVM_RUNTIMES_TARGET}) + # LLVM_RUNTIMES_TARGET may contain multilib flags, use the clean triple. + set(explicit_target_triple ${LLVM_DEFAULT_TARGET_TRIPLE}) elseif(LIBC_TARGET_TRIPLE) set(explicit_target_triple ${LIBC_TARGET_TRIPLE}) endif() # The libc's target architecture and OS are set to match the compiler's default # target triple above. However, one can explicitly set LIBC_TARGET_TRIPLE or -# LLVM_RUNTIMES_TARGET (for runtimes/bootstrap build). If one of them is set, +# LLVM_DEFAULT_TARGET_TRIPLE (for runtimes/bootstrap build). If one of them is set, # then we will use that target triple to deduce libc's target OS and # architecture. if(explicit_target_triple) @@ -124,7 +125,7 @@ if(explicit_target_triple) set(LIBC_TARGET_ARCHITECTURE ${libc_arch}) set(LIBC_TARGET_OS ${libc_sys}) # If the compiler target triple is not the same as the triple specified by - # LIBC_TARGET_TRIPLE or LLVM_RUNTIMES_TARGET, we will add a --target option + # LIBC_TARGET_TRIPLE or LLVM_DEFAULT_TARGET_TRIPLE, we will add a --target option # if the compiler is clang. If the compiler is GCC we just error out as there # is no equivalent of an option like --target. if(NOT libc_compiler_triple STREQUAL explicit_target_triple) @@ -216,7 +217,7 @@ else() endif() # If the compiler target triple is not the same as the triple specified by -# LIBC_TARGET_TRIPLE or LLVM_RUNTIMES_TARGET, we will add a --target option +# LIBC_TARGET_TRIPLE or LLVM_DEFAULT_TARGET_TRIPLE, we will add a --target option # if the compiler is clang. If the compiler is GCC we just error out as there # is no equivalent of an option like --target. if(explicit_target_triple AND diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake index 21fec1d064ff..f645de127768 100644 --- a/llvm/cmake/modules/HandleLLVMOptions.cmake +++ b/llvm/cmake/modules/HandleLLVMOptions.cmake @@ -1159,7 +1159,7 @@ if (UNIX AND endif() # lld doesn't print colored diagnostics when invoked from Ninja -if (UNIX AND CMAKE_GENERATOR MATCHES "Ninja" AND NOT "${LLVM_RUNTIMES_TARGET}" MATCHES "^nvptx64") +if (UNIX AND CMAKE_GENERATOR MATCHES "Ninja" AND NOT "${LLVM_DEFAULT_TARGET_TRIPLE}" MATCHES "^nvptx64") include(CheckLinkerFlag) check_linker_flag(CXX "-Wl,--color-diagnostics" LINKER_SUPPORTS_COLOR_DIAGNOSTICS) append_if(LINKER_SUPPORTS_COLOR_DIAGNOSTICS "-Wl,--color-diagnostics" diff --git a/runtimes/CMakeLists.txt b/runtimes/CMakeLists.txt index c12e2406b5d0..b067fe97be27 100644 --- a/runtimes/CMakeLists.txt +++ b/runtimes/CMakeLists.txt @@ -191,7 +191,7 @@ if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") endif() # The NVPTX target needs to override linking to pass compiler flag checks. -if("${LLVM_RUNTIMES_TARGET}" MATCHES "^nvptx") +if("${LLVM_DEFAULT_TARGET_TRIPLE}" MATCHES "^nvptx") set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -flto -c") endif()