summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Modules/CMakeDetermineFortranCompiler.cmake4
-rw-r--r--Modules/Platform/Windows-LLVMFlang-Fortran.cmake27
-rw-r--r--Tests/MSVCRuntimeLibrary/Fortran/CMakeLists.txt8
3 files changed, 23 insertions, 16 deletions
diff --git a/Modules/CMakeDetermineFortranCompiler.cmake b/Modules/CMakeDetermineFortranCompiler.cmake
index 3ed7d58..613b0c4 100644
--- a/Modules/CMakeDetermineFortranCompiler.cmake
+++ b/Modules/CMakeDetermineFortranCompiler.cmake
@@ -265,8 +265,8 @@ if("${CMAKE_Fortran_COMPILER_ID};${CMAKE_Fortran_SIMULATE_ID}" STREQUAL "LLVMFla
"${log}\n"
)
set(_CMAKE_Fortran_IMPLICIT_LINK_INFORMATION_DETERMINED_EARLY 1)
- if("x${CMAKE_Fortran_COMPILER_ARCHITECTURE_ID}" STREQUAL "xARM64")
- # FIXME(LLVMFlang): It does not add `-defaultlib:` fields to object
+ if("x${CMAKE_Fortran_COMPILER_ARCHITECTURE_ID}" STREQUAL "xARM64" AND CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 18.0)
+ # LLVMFlang < 18.0 does not add `-defaultlib:` fields to object
# files to specify link dependencies on its runtime libraries.
# For now, we add them ourselves.
list(APPEND CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES "clang_rt.builtins-aarch64.lib")
diff --git a/Modules/Platform/Windows-LLVMFlang-Fortran.cmake b/Modules/Platform/Windows-LLVMFlang-Fortran.cmake
index 57e36c6..10e3b2c 100644
--- a/Modules/Platform/Windows-LLVMFlang-Fortran.cmake
+++ b/Modules/Platform/Windows-LLVMFlang-Fortran.cmake
@@ -5,17 +5,22 @@ elseif("x${CMAKE_Fortran_SIMULATE_ID}" STREQUAL "xMSVC")
include(Platform/Windows-MSVC)
__windows_compiler_msvc(Fortran)
- # FIXME(LLVMFlang): It does not provides MSVC runtime library selection flags.
- # It should be given a flag like classic Flang's `-Xclang --dependent-lib=`, or a
- # dedicated flag to select among multiple `Fortran*.lib` runtime library variants
- # that each depend on a different MSVC runtime library. For now, LLVMFlang's
- # `Fortran*.lib` runtime libraries hard-code use of msvcrt (MultiThreadedDLL),
- # so we link to it ourselves.
- set(_LLVMFlang_LINK_RUNTIME "-defaultlib:msvcrt")
- set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded "")
- set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL "")
- set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug "")
- set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL "")
+ if(CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL 18.0)
+ set(_LLVMFlang_LINK_RUNTIME "")
+ set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded "-fms-runtime-lib=static")
+ set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL "-fms-runtime-lib=dll")
+ set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug "-fms-runtime-lib=static_dbg")
+ set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL "-fms-runtime-lib=dll_dbg")
+ else()
+ # LLVMFlang < 18.0 does not have MSVC runtime library selection flags.
+ # The official distrubtion's `Fortran*.lib` runtime libraries hard-code
+ # use of msvcrt (MultiThreadedDLL), so we link to it ourselves.
+ set(_LLVMFlang_LINK_RUNTIME "-defaultlib:msvcrt")
+ set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded "")
+ set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL "")
+ set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug "")
+ set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL "")
+ endif()
# LLVMFlang, like Clang, does not provide all debug information format flags.
# In order to provide easy integration with C and C++ projects that use the
diff --git a/Tests/MSVCRuntimeLibrary/Fortran/CMakeLists.txt b/Tests/MSVCRuntimeLibrary/Fortran/CMakeLists.txt
index 2a8a152..4cd200a 100644
--- a/Tests/MSVCRuntimeLibrary/Fortran/CMakeLists.txt
+++ b/Tests/MSVCRuntimeLibrary/Fortran/CMakeLists.txt
@@ -21,14 +21,16 @@ foreach(t MultiThreaded SingleThreaded)
endforeach()
endforeach()
endforeach()
-if(CMAKE_Fortran_COMPILER_ID STREQUAL "LLVMFlang")
- # LLVMFlang does not actually define these, so inject them
+if(CMAKE_Fortran_COMPILER_ID STREQUAL "LLVMFlang" AND CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 18.0)
+ # LLVMFlang < 18.0 does not define these, so inject them.
set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded "-D_MT")
set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL "-D_MT;-D_DLL")
set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug "-D_MT;-D_DEBUG")
set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL "-D_MT;-D_DEBUG;-D_DLL")
endif()
-string(APPEND CMAKE_Fortran_FLAGS " -w")
+if(NOT CMAKE_Fortran_SIMULATE_ID STREQUAL "MSVC")
+ string(APPEND CMAKE_Fortran_FLAGS " -w")
+endif()
function(verify_combinations threads lang src)
set(verify_tc_config_ Release)