Przeglądaj źródła

Merge topic 'LLVMFlang-MSVC-debug' into release-3.28

ef49ed0fe1 LLVMFlang: Fix MSVC ABI debug information format options

Acked-by: Kitware Robot <[email protected]>
Merge-request: !9037
Brad King 2 lat temu
rodzic
commit
91392d7741

+ 7 - 5
Modules/Platform/Windows-LLVMFlang-Fortran.cmake

@@ -17,11 +17,13 @@ elseif("x${CMAKE_Fortran_SIMULATE_ID}" STREQUAL "xMSVC")
   set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug    "")
   set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL "")
 
-  # FIXME(LLVMFlang): It does not provide all debug information format flags or predefines.
-  # It should be given a flag to enable Embedded debug information like MSVC -Z7.
-  #set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_Embedded)        # not supported by LLVMFlang
-  #set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_EditAndContinue) # not supported by LLVMFlang
-  set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_ProgramDatabase "-g")
+  # 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
+  # other debug information formats, pretend to support them, and just do not
+  # actually generate any debug information for Fortran.
+  set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_Embedded        -g)
+  set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_ProgramDatabase "") # not supported by LLVMFlang
+  set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_EditAndContinue "") # not supported by LLVMFlang
 
   set(CMAKE_Fortran_COMPILE_OBJECT "<CMAKE_Fortran_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>")
 

+ 1 - 4
Tests/CMakeLists.txt

@@ -2154,10 +2154,7 @@ if(BUILD_TESTING)
     endif()
 
     set(MSVCDebugInformationFormat_BUILD_OPTIONS -DCMake_TEST_CUDA=${CMake_TEST_CUDA})
-    if(CMAKE_Fortran_COMPILER
-        # FIXME(LLVMFlang): It does not provide debug information format flags or predefines.
-        AND NOT CMAKE_Fortran_COMPILER_ID STREQUAL "LLVMFlang"
-        )
+    if(CMAKE_Fortran_COMPILER)
       list(APPEND MSVCDebugInformationFormat_BUILD_OPTIONS -DCMake_TEST_Fortran=1)
     endif()
     ADD_TEST_MACRO(MSVCDebugInformationFormat)

+ 8 - 0
Tests/MSVCDebugInformationFormat/override-Fortran.cmake

@@ -2,3 +2,11 @@ set(var "CMAKE_Fortran_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_Embedded")
 string(REPLACE "-Z7" "-Z7;-DTEST_Z7" "${var}" "${${var}}")
 set(var "CMAKE_Fortran_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_ProgramDatabase")
 string(REPLACE "-Zi" "-Zi;-DTEST_Zi" "${var}" "${${var}}")
+
+if(CMAKE_Fortran_COMPILER_ID STREQUAL "LLVMFlang")
+  set(var "CMAKE_Fortran_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_Embedded")
+  string(REPLACE "-g" "-g;-DTEST_Z7" "${var}" "${${var}}")
+  # LLVMFlang does not actually support these, but Windows-LLVMFlang-Fortran pretends it does.
+  set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_ProgramDatabase "-DTEST_Zi")
+  set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_EditAndContinue "-DTEST_ZI")
+endif()