[flang-rt] Use correct flang-rt build for flang-rt unit tests on Windows (#152318)
Currrently flang-rt assumes that LLVM was always built with the dynamic MSVC runtime. This may not be the case, if the user has specified a different runtime with -DCMAKE_MSVC_RUNTIME_LIBRARY. Since this flag is implied by -DLLVM_ENABLE_RPMALLOC=On, which is used by the Windows release script, this is causing that script to fail. Fixes #151920 (cherry picked from commit f73a3028c2d46928280d69d9e953ff79d2eb0fbb)
This commit is contained in:
parent
b398447cbc
commit
2555a85378
@ -251,19 +251,33 @@ else()
|
||||
add_win_flangrt_runtime(STATIC dynamic MultiThreadedDLL INSTALL_WITH_TOOLCHAIN)
|
||||
add_win_flangrt_runtime(STATIC dynamic_dbg MultiThreadedDebugDLL INSTALL_WITH_TOOLCHAIN)
|
||||
|
||||
# Unittests link against LLVMSupport which is using CMake's default runtime
|
||||
# library selection, which is either MultiThreadedDLL or MultiThreadedDebugDLL
|
||||
# depending on the configuration. They have to match or linking will fail.
|
||||
# Unittests link against LLVMSupport. If CMAKE_MSVC_RUNTIME_LIBRARY is set,
|
||||
# that will have been used for LLVMSupport so it must also be used here.
|
||||
# Otherwise this will use CMake's default runtime library selection, which
|
||||
# is either MultiThreadedDLL or MultiThreadedDebugDLL depending on the configuration.
|
||||
# They have to match or linking will fail.
|
||||
if (GENERATOR_IS_MULTI_CONFIG)
|
||||
# We cannot select an ALIAS library because it may be different
|
||||
# per configuration. Fallback to CMake's default.
|
||||
add_win_flangrt_runtime(STATIC unittest "" EXCLUDE_FROM_ALL)
|
||||
else ()
|
||||
string(TOLOWER ${CMAKE_BUILD_TYPE} build_type)
|
||||
if (build_type STREQUAL "debug")
|
||||
add_library(flang_rt.runtime.unittest ALIAS flang_rt.runtime.dynamic_dbg)
|
||||
else ()
|
||||
add_library(flang_rt.runtime.unittest ALIAS flang_rt.runtime.dynamic)
|
||||
endif ()
|
||||
# Check if CMAKE_MSVC_RUNTIME_LIBRARY was set.
|
||||
if (CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL "MultiThreaded")
|
||||
add_library(flang_rt.runtime.unittest ALIAS flang_rt.runtime.static)
|
||||
elseif (CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL "MultiThreadedDLL")
|
||||
add_library(flang_rt.runtime.unittest ALIAS flang_rt.runtime.dynamic)
|
||||
elseif (CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL "MultiThreadedDebug")
|
||||
add_library(flang_rt.runtime.unittest ALIAS flang_rt.runtime.static_dbg)
|
||||
elseif (CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL "MultiThreadedDebugDLL")
|
||||
add_library(flang_rt.runtime.unittest ALIAS flang_rt.runtime.dynamic_dbg)
|
||||
else()
|
||||
# Default based on the build type.
|
||||
string(TOLOWER ${CMAKE_BUILD_TYPE} build_type)
|
||||
if (build_type STREQUAL "debug")
|
||||
add_library(flang_rt.runtime.unittest ALIAS flang_rt.runtime.dynamic_dbg)
|
||||
else ()
|
||||
add_library(flang_rt.runtime.unittest ALIAS flang_rt.runtime.dynamic)
|
||||
endif ()
|
||||
endif()
|
||||
endif ()
|
||||
endif()
|
||||
|
@ -94,14 +94,6 @@ function(add_flangrt_unittest test_dirname)
|
||||
target_link_libraries(${test_dirname} PRIVATE ${ARG_LINK_LIBS})
|
||||
add_flangrt_unittest_offload_properties(${test_dirname})
|
||||
add_flangrt_dependent_libs(${test_dirname})
|
||||
|
||||
# Required because LLVMSupport is compiled with this option.
|
||||
# FIXME: According to CMake documentation, this is the default. Why is it
|
||||
# needed? LLVM's add_unittest doesn't set it either.
|
||||
set_target_properties(${test_dirname}
|
||||
PROPERTIES
|
||||
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL"
|
||||
)
|
||||
endfunction()
|
||||
|
||||
function(add_flangrt_nongtest_unittest test_name)
|
||||
|
Loading…
x
Reference in New Issue
Block a user