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
This commit is contained in:
Brad King
2022-10-11 15:35:43 -04:00
parent 5d24e9e09b
commit 0301779e85
6 changed files with 50 additions and 2 deletions

View File

@@ -1,3 +1,5 @@
set(CMAKE_Fortran_VERBOSE_FLAG "-v")
set(CMAKE_Fortran_SUBMODULE_SEP "-")
set(CMAKE_Fortran_SUBMODULE_EXT ".mod")

View File

@@ -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()

View File

@@ -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()

View File

@@ -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'

View File

@@ -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

View File

@@ -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