summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-10-11 19:35:43 (GMT)
committerBrad King <brad.king@kitware.com>2022-10-11 19:38:48 (GMT)
commit0301779e8532626c106f38e4f8e227c89ba1b158 (patch)
tree3b4cd5af8acb117c7db937f28dee6d1db829cf61
parent5d24e9e09b21b05c7bad67303adbbac0137b51c3 (diff)
downloadCMake-0301779e8532626c106f38e4f8e227c89ba1b158.zip
CMake-0301779e8532626c106f38e4f8e227c89ba1b158.tar.gz
CMake-0301779e8532626c106f38e4f8e227c89ba1b158.tar.bz2
LLVMFlang: Add support for mixed-language linking with Fortran
Parse implicit link information for this compiler to support mixed-language linking. This was missed by commit 85749766df (LLVMFlang: Add support for LLVM Flang, 2021-07-07, v3.24.0-rc1~86^2). Also activate mixed-language test cases that would have caught this. Issue: #22387
-rw-r--r--Modules/Compiler/LLVMFlang-Fortran.cmake2
-rw-r--r--Tests/Fortran/CMakeLists.txt2
-rw-r--r--Tests/FortranC/CMakeLists.txt2
-rw-r--r--Tests/RunCMake/ParseImplicitData/linux-Fortran-LLVMFlang-15.0.0.input43
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/ParseImplicitLinkInfo.cmake1
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/linux-Fortran-LLVMFlang-15.0.0.output2
6 files changed, 50 insertions, 2 deletions
diff --git a/Modules/Compiler/LLVMFlang-Fortran.cmake b/Modules/Compiler/LLVMFlang-Fortran.cmake
index 7e9ba5e..651bf51 100644
--- a/Modules/Compiler/LLVMFlang-Fortran.cmake
+++ b/Modules/Compiler/LLVMFlang-Fortran.cmake
@@ -1,3 +1,5 @@
+set(CMAKE_Fortran_VERBOSE_FLAG "-v")
+
set(CMAKE_Fortran_SUBMODULE_SEP "-")
set(CMAKE_Fortran_SUBMODULE_EXT ".mod")
diff --git a/Tests/Fortran/CMakeLists.txt b/Tests/Fortran/CMakeLists.txt
index cdc08c4..0fede25 100644
--- a/Tests/Fortran/CMakeLists.txt
+++ b/Tests/Fortran/CMakeLists.txt
@@ -123,7 +123,7 @@ endfunction()
# if the id's match or the compilers are compatible, then
# call the test_fortran_c_interface_module function
if("${CMAKE_Fortran_COMPILER_ID}:${CMAKE_C_COMPILER_ID}" MATCHES
- "(Intel(LLVM)?:MSVC|Absoft:GNU)"
+ "(Intel(LLVM)?:MSVC|Absoft:GNU|LLVMFlang:(GNU|Clang))"
OR ("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "${CMAKE_C_COMPILER_ID}" ))
test_fortran_c_interface_module()
else()
diff --git a/Tests/FortranC/CMakeLists.txt b/Tests/FortranC/CMakeLists.txt
index 83c2729..1403aa0 100644
--- a/Tests/FortranC/CMakeLists.txt
+++ b/Tests/FortranC/CMakeLists.txt
@@ -3,7 +3,7 @@ project(FortranC C Fortran)
# Skip this test for compilers not known to be compatible.
if(NOT (CMAKE_C_COMPILER_ID STREQUAL CMAKE_Fortran_COMPILER_ID OR
- "${CMAKE_C_COMPILER_ID}-${CMAKE_Fortran_COMPILER_ID}" MATCHES "^(MSVC-Intel)$"))
+ "${CMAKE_C_COMPILER_ID}-${CMAKE_Fortran_COMPILER_ID}" MATCHES "^(MSVC-Intel|(GNU|Clang)-LLVMFlang)$"))
message(STATUS "${CMAKE_C_COMPILER_ID} C and ${CMAKE_Fortran_COMPILER_ID} Fortran not known to be compatible!")
return()
endif()
diff --git a/Tests/RunCMake/ParseImplicitData/linux-Fortran-LLVMFlang-15.0.0.input b/Tests/RunCMake/ParseImplicitData/linux-Fortran-LLVMFlang-15.0.0.input
new file mode 100644
index 0000000..5a53c88
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/linux-Fortran-LLVMFlang-15.0.0.input
@@ -0,0 +1,43 @@
+CMAKE_LANG=Fortran
+CMAKE_LINKER=/usr/bin/ld
+CMAKE_Fortran_COMPILER_ABI=
+CMAKE_Fortran_COMPILER_AR=
+CMAKE_Fortran_COMPILER_ARCHITECTURE_ID=
+CMAKE_Fortran_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_Fortran_COMPILER_ID=LLVMFlang
+CMAKE_Fortran_COMPILER_LAUNCHER=
+CMAKE_Fortran_COMPILER_LOADED=1
+CMAKE_Fortran_COMPILER_RANLIB=
+CMAKE_Fortran_COMPILER_TARGET=
+CMAKE_Fortran_COMPILER_VERSION=15.0.0
+CMAKE_Fortran_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command(s):/usr/bin/gmake -f Makefile cmTC_2e9b9/fast && /usr/bin/gmake -f CMakeFiles/cmTC_2e9b9.dir/build.make CMakeFiles/cmTC_2e9b9.dir/build
+gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp'
+Building Fortran object CMakeFiles/cmTC_2e9b9.dir/CMakeFortranCompilerABI.F.o
+/usr/bin/flang-new -v -c /tmp/CMake/Modules/CMakeFortranCompilerABI.F -o CMakeFiles/cmTC_2e9b9.dir/CMakeFortranCompilerABI.F.o
+flang-new version 15.0.0 (Fedora 15.0.0-4.fc38)
+Target: x86_64-redhat-linux-gnu
+Thread model: posix
+InstalledDir: /usr/bin
+Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-redhat-linux/12
+Selected GCC installation: /usr/bin/../lib/gcc/x86_64-redhat-linux/12
+Candidate multilib: .@m64
+Candidate multilib: 32@m32
+Selected multilib: .@m64
+ "/usr/bin/flang-new" -fc1 -triple x86_64-redhat-linux-gnu -emit-obj -o CMakeFiles/cmTC_2e9b9.dir/CMakeFortranCompilerABI.F.o -x f95-cpp-input /tmp/CMake/Modules/CMakeFortranCompilerABI.F
+Linking Fortran executable cmTC_2e9b9
+/tmp/CMake/bin/cmake -E cmake_link_script CMakeFiles/cmTC_2e9b9.dir/link.txt --verbose=1
+/usr/bin/flang-new -v CMakeFiles/cmTC_2e9b9.dir/CMakeFortranCompilerABI.F.o -o cmTC_2e9b9
+flang-new version 15.0.0 (Fedora 15.0.0-4.fc38)
+Target: x86_64-redhat-linux-gnu
+Thread model: posix
+InstalledDir: /usr/bin
+Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-redhat-linux/12
+Selected GCC installation: /usr/bin/../lib/gcc/x86_64-redhat-linux/12
+Candidate multilib: .@m64
+Candidate multilib: 32@m32
+Selected multilib: .@m64
+ "/usr/bin/ld" --hash-style=gnu --build-id --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o cmTC_2e9b9 /usr/bin/../lib/gcc/x86_64-redhat-linux/12/../../../../lib64/crt1.o /usr/bin/../lib/gcc/x86_64-redhat-linux/12/../../../../lib64/crti.o /usr/bin/../lib/gcc/x86_64-redhat-linux/12/crtbegin.o -L/usr/bin/../lib/gcc/x86_64-redhat-linux/12 -L/usr/bin/../lib/gcc/x86_64-redhat-linux/12/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/lib -L/usr/lib CMakeFiles/cmTC_2e9b9.dir/CMakeFortranCompilerABI.F.o -lFortran_main -lFortranRuntime -lFortranDecimal -lm -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/bin/../lib/gcc/x86_64-redhat-linux/12/crtend.o /usr/bin/../lib/gcc/x86_64-redhat-linux/12/../../../../lib64/crtn.o
+gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/ParseImplicitLinkInfo.cmake b/Tests/RunCMake/ParseImplicitLinkInfo/ParseImplicitLinkInfo.cmake
index 51c8832..1410eae 100644
--- a/Tests/RunCMake/ParseImplicitLinkInfo/ParseImplicitLinkInfo.cmake
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/ParseImplicitLinkInfo.cmake
@@ -38,6 +38,7 @@ set(targets
linux-C-XL-16.1.0.0 linux-CXX-XL-16.1.0.0
linux-CUDA-NVIDIA-10.1.168-CLANG linux-CUDA-NVIDIA-10.1.168-XLClang-v
linux-CUDA-NVIDIA-9.2.148-GCC
+ linux-Fortran-LLVMFlang-15.0.0
linux-custom_clang-C-Clang-13.0.0 linux-custom_clang-CXX-Clang-13.0.0
mingw.org-C-GNU-4.9.3 mingw.org-CXX-GNU-4.9.3
netbsd-C-GNU-4.8.5 netbsd-CXX-GNU-4.8.5
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-Fortran-LLVMFlang-15.0.0.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-Fortran-LLVMFlang-15.0.0.output
new file mode 100644
index 0000000..cea8a68
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-Fortran-LLVMFlang-15.0.0.output
@@ -0,0 +1,2 @@
+libs=Fortran_main;FortranRuntime;FortranDecimal;m;gcc;gcc_s;c;gcc;gcc_s
+dirs=/usr/lib/gcc/x86_64-redhat-linux/12;/usr/lib64;/lib64;/lib;/usr/lib