summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2024-10-25 12:19:47 (GMT)
committerKitware Robot <kwrobot@kitware.com>2024-10-25 12:19:54 (GMT)
commit0a37acc60790a28ed05032b21c0634da5ce41afe (patch)
tree334abe17ae7f72c08aa638ace20f6ada3b2ad153
parent4dd738b53c044969aba3e79b69b59670303236f7 (diff)
parent34067963cc7941c3606d7a8530243bc17aa3a38b (diff)
downloadCMake-0a37acc60790a28ed05032b21c0634da5ce41afe.zip
CMake-0a37acc60790a28ed05032b21c0634da5ce41afe.tar.gz
CMake-0a37acc60790a28ed05032b21c0634da5ce41afe.tar.bz2
Merge topic 'lfortran-link-info' into release-3.31
34067963cc LFortran: Improve detection of implicit link information for lfortran 0.40+ Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !9939
-rw-r--r--Modules/CMakeParseImplicitLinkInfo.cmake15
-rw-r--r--Modules/Compiler/LFortran-Fortran.cmake2
-rw-r--r--Tests/RunCMake/ParseImplicitData/linux-Fortran-LFortran-0.41.0-clang.input38
-rw-r--r--Tests/RunCMake/ParseImplicitData/linux-Fortran-LFortran-0.41.0-gcc.input43
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/ParseImplicitLinkInfo.cmake2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/linux-Fortran-LFortran-0.41.0-clang.output4
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/linux-Fortran-LFortran-0.41.0-gcc.output4
7 files changed, 100 insertions, 8 deletions
diff --git a/Modules/CMakeParseImplicitLinkInfo.cmake b/Modules/CMakeParseImplicitLinkInfo.cmake
index 87c9e8a..d9ecbd8 100644
--- a/Modules/CMakeParseImplicitLinkInfo.cmake
+++ b/Modules/CMakeParseImplicitLinkInfo.cmake
@@ -49,20 +49,21 @@ function(cmake_parse_implicit_link_info2 text log_var obj_regex)
set(multiValueArgs )
cmake_parse_arguments(EXTRA_PARSE "${keywordArgs}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
- set(is_lfortran 0)
+ set(is_lfortran_less_0_40 0)
set(is_msvc 0)
if(EXTRA_PARSE_LANGUAGE)
if("x${CMAKE_${EXTRA_PARSE_LANGUAGE}_COMPILER_ID}" STREQUAL "xMSVC" OR
"x${CMAKE_${EXTRA_PARSE_LANGUAGE}_SIMULATE_ID}" STREQUAL "xMSVC")
set(is_msvc 1)
- elseif("x${CMAKE_${EXTRA_PARSE_LANGUAGE}_COMPILER_ID}" STREQUAL "xLFortran")
- set(is_lfortran 1)
+ elseif("x${CMAKE_${EXTRA_PARSE_LANGUAGE}_COMPILER_ID}" STREQUAL "xLFortran"
+ AND CMAKE_${EXTRA_PARSE_LANGUAGE}_COMPILER_VERSION VERSION_LESS "0.40")
+ set(is_lfortran_less_0_40 1)
endif()
endif()
# Parse implicit linker arguments.
set(linker "ld[0-9]*(\\.[a-z]+)?")
- if(is_lfortran)
- # FIXME(lfortran): No way to pass -v to clang/gcc driver.
+ if(is_lfortran_less_0_40)
+ # lfortran < 0.40 has no way to pass -v to clang/gcc driver.
string(APPEND linker "|clang|gcc")
endif()
if(is_msvc)
@@ -85,8 +86,8 @@ function(cmake_parse_implicit_link_info2 text log_var obj_regex)
set(linker_exclude_regex "collect2 version |^[A-Za-z0-9_]+=|/ldfe ")
set(linker_tool_regex "^[ \t]*(->|\")?[ \t]*(([^\"]*[/\\])?(${linker}))(\"|,| |$)")
set(linker_tool_exclude_regex "cuda-fake-ld|-fuse-ld=|^ExecuteExternalTool ")
- if(is_lfortran)
- # FIXME(lfortran): No way to pass -v to clang/gcc driver.
+ if(is_lfortran_less_0_40)
+ # lfortran < 0.40 has no way to pass -v to clang/gcc driver.
string(APPEND linker_tool_exclude_regex "|^clang |^gcc ")
endif()
set(linker_tool "NOTFOUND")
diff --git a/Modules/Compiler/LFortran-Fortran.cmake b/Modules/Compiler/LFortran-Fortran.cmake
index 4180730..9090e1d 100644
--- a/Modules/Compiler/LFortran-Fortran.cmake
+++ b/Modules/Compiler/LFortran-Fortran.cmake
@@ -3,7 +3,7 @@ string(APPEND CMAKE_Fortran_FLAGS_MINSIZEREL_INIT " ")
string(APPEND CMAKE_Fortran_FLAGS_RELEASE_INIT " -O3")
string(APPEND CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT " -O2 -g")
set(CMAKE_Fortran_MODDIR_FLAG "-J")
-set(CMAKE_Fortran_VERBOSE_FLAG "-v")
+set(CMAKE_Fortran_VERBOSE_FLAG "-v -Wl,-v")
set(CMAKE_Fortran_FORMAT_FIXED_FLAG "--fixed-form")
set(CMAKE_Fortran_LINKER_WRAPPER_FLAG "-Wl,")
set(CMAKE_Fortran_COMPILE_OPTIONS_PREPROCESS_ON "--cpp")
diff --git a/Tests/RunCMake/ParseImplicitData/linux-Fortran-LFortran-0.41.0-clang.input b/Tests/RunCMake/ParseImplicitData/linux-Fortran-LFortran-0.41.0-clang.input
new file mode 100644
index 0000000..7f84f44
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/linux-Fortran-LFortran-0.41.0-clang.input
@@ -0,0 +1,38 @@
+CMAKE_LANG=Fortran
+CMAKE_LINKER=/usr/bin/ld
+CMAKE_Fortran_COMPILER_ABI=ELF
+CMAKE_Fortran_COMPILER_AR=
+CMAKE_Fortran_COMPILER_ARCHITECTURE_ID=
+CMAKE_Fortran_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_Fortran_COMPILER_ID=LFortran
+CMAKE_Fortran_COMPILER_LAUNCHER=
+CMAKE_Fortran_COMPILER_LOADED=1
+CMAKE_Fortran_COMPILER_RANLIB=
+CMAKE_Fortran_COMPILER_TARGET=
+CMAKE_Fortran_COMPILER_VERSION=0.41.0
+CMAKE_Fortran_COMPILER_VERSION_INTERAL=
+Change Dir: '/tmp/ii/CMakeFiles/CMakeTmp'
+
+Run Build Command(s): /tmp/CMake/bin/cmake -E env VERBOSE=1 /usr/bin/gmake -f Makefile cmTC_e3038/fast
+/usr/bin/gmake -f CMakeFiles/cmTC_e3038.dir/build.make CMakeFiles/cmTC_e3038.dir/build
+gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp'
+Building Fortran object CMakeFiles/cmTC_e3038.dir/CMakeFortranCompilerABI.F.o
+/usr/bin/lfortran --cpp-infer -v -Wl,-v --generate-object-code -c /tmp/CMake/Modules/CMakeFortranCompilerABI.F -o CMakeFiles/cmTC_e3038.dir/CMakeFortranCompilerABI.F.o
+Linking Fortran executable cmTC_e3038
+/tmp/CMake/bin/cmake -E cmake_link_script CMakeFiles/cmTC_e3038.dir/link.txt --verbose=1
+clang -o cmTC_e3038 CMakeFiles/cmTC_e3038.dir/CMakeFortranCompilerABI.F.o -L"/usr/bin/../lib64" -Wl,-rpath,"/usr/bin/../lib64" -Wl,-v -llfortran_runtime -lm -v
+clang version 19.1.0 (Fedora 19.1.0-1.fc41)
+Target: x86_64-redhat-linux-gnu
+Thread model: posix
+InstalledDir: /usr/bin
+Configuration file: /etc/clang/x86_64-redhat-linux-gnu-clang.cfg
+System configuration file directory: /etc/clang/
+Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-redhat-linux/14
+Selected GCC installation: /usr/bin/../lib/gcc/x86_64-redhat-linux/14
+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_e3038 /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../lib64/crt1.o /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../lib64/crti.o /usr/bin/../lib/gcc/x86_64-redhat-linux/14/crtbegin.o -L/usr/bin/../lib64 -L/usr/bin/../lib/clang/19/lib/x86_64-redhat-linux-gnu -L/usr/bin/../lib/gcc/x86_64-redhat-linux/14 -L/usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/lib -L/usr/lib CMakeFiles/cmTC_e3038.dir/CMakeFortranCompilerABI.F.o -rpath /usr/bin/../lib64 -v -llfortran_runtime -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/14/crtend.o /usr/bin/../lib/gcc/x86_64-redhat-linux/14/../../../../lib64/crtn.o
+GNU ld version 2.43.1-2.fc41
+/usr/bin/lfortran -v -Wl,-v CMakeFiles/cmTC_e3038.dir/CMakeFortranCompilerABI.F.o -o cmTC_e3038
+gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/linux-Fortran-LFortran-0.41.0-gcc.input b/Tests/RunCMake/ParseImplicitData/linux-Fortran-LFortran-0.41.0-gcc.input
new file mode 100644
index 0000000..4a79262
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/linux-Fortran-LFortran-0.41.0-gcc.input
@@ -0,0 +1,43 @@
+CMAKE_LANG=Fortran
+CMAKE_LINKER=/usr/bin/ld
+CMAKE_Fortran_COMPILER_ABI=ELF
+CMAKE_Fortran_COMPILER_AR=
+CMAKE_Fortran_COMPILER_ARCHITECTURE_ID=
+CMAKE_Fortran_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_Fortran_COMPILER_ID=LFortran
+CMAKE_Fortran_COMPILER_LAUNCHER=
+CMAKE_Fortran_COMPILER_LOADED=1
+CMAKE_Fortran_COMPILER_RANLIB=
+CMAKE_Fortran_COMPILER_TARGET=
+CMAKE_Fortran_COMPILER_VERSION=0.41.0
+CMAKE_Fortran_COMPILER_VERSION_INTERAL=
+Change Dir: '/tmp/ii/CMakeFiles/CMakeTmp'
+
+Run Build Command(s): /tmp/CMake/bin/cmake -E env VERBOSE=1 /usr/bin/gmake -f Makefile cmTC_fdc77/fast
+/usr/bin/gmake -f CMakeFiles/cmTC_fdc77.dir/build.make CMakeFiles/cmTC_fdc77.dir/build
+gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp'
+Building Fortran object CMakeFiles/cmTC_fdc77.dir/CMakeFortranCompilerABI.F.o
+/usr/bin/lfortran --cpp-infer --link-with-gcc -v -Wl,-v --generate-object-code -c /tmp/CMake/Modules/CMakeFortranCompilerABI.F -o CMakeFiles/cmTC_fdc77.dir/CMakeFortranCompilerABI.F.o
+Linking Fortran executable cmTC_fdc77
+/tmp/CMake/bin/cmake -E cmake_link_script CMakeFiles/cmTC_fdc77.dir/link.txt --verbose=1
+gcc -o cmTC_fdc77 CMakeFiles/cmTC_fdc77.dir/CMakeFortranCompilerABI.F.o -L"/usr/bin/../lib64" -Wl,-rpath,"/usr/bin/../lib64" -Wl,-v -llfortran_runtime -lm -v
+Using built-in specs.
+COLLECT_GCC=gcc
+COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/14/lto-wrapper
+OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
+OFFLOAD_TARGET_DEFAULT=1
+Target: x86_64-redhat-linux
+Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,objc,obj-c++,ada,go,d,m2,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --enable-libstdcxx-backtrace --with-libstdcxx-zoneinfo=/usr/share/zoneinfo --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-14.2.1-build/gcc-14.2.1-20240912/obj-x86_64-redhat-linux/isl-install --enable-offload-targets=nvptx-none,amdgcn-amdhsa --enable-offload-defaulted --without-cuda-driver --enable-gnu-indirect-function --enable-cet --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux --with-build-config=bootstrap-lto --enable-link-serialization=1
+Thread model: posix
+Supported LTO compression algorithms: zlib zstd
+gcc version 14.2.1 20240912 (Red Hat 14.2.1-3) (GCC)
+COMPILER_PATH=/usr/libexec/gcc/x86_64-redhat-linux/14/:/usr/libexec/gcc/x86_64-redhat-linux/14/:/usr/libexec/gcc/x86_64-redhat-linux/:/usr/lib/gcc/x86_64-redhat-linux/14/:/usr/lib/gcc/x86_64-redhat-linux/
+LIBRARY_PATH=/usr/lib/gcc/x86_64-redhat-linux/14/:/usr/lib/gcc/x86_64-redhat-linux/14/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/usr/lib/gcc/x86_64-redhat-linux/14/../../../:/lib/:/usr/lib/
+COLLECT_GCC_OPTIONS='-o' 'cmTC_fdc77' '-L/usr/bin/../lib64' '-foffload-options=-l_GCC_m' '-v' '-mtune=generic' '-march=x86-64' '-dumpdir' 'cmTC_fdc77.'
+ /usr/libexec/gcc/x86_64-redhat-linux/14/collect2 -plugin /usr/libexec/gcc/x86_64-redhat-linux/14/liblto_plugin.so -plugin-opt=/usr/libexec/gcc/x86_64-redhat-linux/14/lto-wrapper -plugin-opt=-fresolution=/tmp/ccg4ypde.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --build-id --no-add-needed --eh-frame-hdr --hash-style=gnu -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o cmTC_fdc77 /usr/lib/gcc/x86_64-redhat-linux/14/../../../../lib64/crt1.o /usr/lib/gcc/x86_64-redhat-linux/14/../../../../lib64/crti.o /usr/lib/gcc/x86_64-redhat-linux/14/crtbegin.o -L/usr/bin/../lib64 -L/usr/lib/gcc/x86_64-redhat-linux/14 -L/usr/lib/gcc/x86_64-redhat-linux/14/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-redhat-linux/14/../../.. CMakeFiles/cmTC_fdc77.dir/CMakeFortranCompilerABI.F.o -rpath /usr/bin/../lib64 -v -llfortran_runtime -lm -lgcc --push-state --as-needed -lgcc_s --pop-state -lc -lgcc --push-state --as-needed -lgcc_s --pop-state /usr/lib/gcc/x86_64-redhat-linux/14/crtend.o /usr/lib/gcc/x86_64-redhat-linux/14/../../../../lib64/crtn.o
+collect2 version 14.2.1 20240912 (Red Hat 14.2.1-3)
+/usr/bin/ld -plugin /usr/libexec/gcc/x86_64-redhat-linux/14/liblto_plugin.so -plugin-opt=/usr/libexec/gcc/x86_64-redhat-linux/14/lto-wrapper -plugin-opt=-fresolution=/tmp/ccg4ypde.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --build-id --no-add-needed --eh-frame-hdr --hash-style=gnu -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o cmTC_fdc77 /usr/lib/gcc/x86_64-redhat-linux/14/../../../../lib64/crt1.o /usr/lib/gcc/x86_64-redhat-linux/14/../../../../lib64/crti.o /usr/lib/gcc/x86_64-redhat-linux/14/crtbegin.o -L/usr/bin/../lib64 -L/usr/lib/gcc/x86_64-redhat-linux/14 -L/usr/lib/gcc/x86_64-redhat-linux/14/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-redhat-linux/14/../../.. CMakeFiles/cmTC_fdc77.dir/CMakeFortranCompilerABI.F.o -rpath /usr/bin/../lib64 -v -llfortran_runtime -lm -lgcc --push-state --as-needed -lgcc_s --pop-state -lc -lgcc --push-state --as-needed -lgcc_s --pop-state /usr/lib/gcc/x86_64-redhat-linux/14/crtend.o /usr/lib/gcc/x86_64-redhat-linux/14/../../../../lib64/crtn.o
+GNU ld version 2.43.1-2.fc41
+COLLECT_GCC_OPTIONS='-o' 'cmTC_fdc77' '-L/usr/bin/../lib64' '-foffload-options=-l_GCC_m' '-v' '-mtune=generic' '-march=x86-64' '-dumpdir' 'cmTC_fdc77.'
+/usr/bin/lfortran -v -Wl,-v --link-with-gcc CMakeFiles/cmTC_fdc77.dir/CMakeFortranCompilerABI.F.o -o cmTC_fdc77
+gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/ParseImplicitLinkInfo.cmake b/Tests/RunCMake/ParseImplicitLinkInfo/ParseImplicitLinkInfo.cmake
index 121a1d2..5b4b8d8 100644
--- a/Tests/RunCMake/ParseImplicitLinkInfo/ParseImplicitLinkInfo.cmake
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/ParseImplicitLinkInfo.cmake
@@ -43,6 +43,8 @@ set(targets
linux-Fortran-LLVMFlang-15.0.0
linux-Fortran-LFortran-0.35.0-clang
linux-Fortran-LFortran-0.35.0-gcc
+ linux-Fortran-LFortran-0.41.0-clang
+ linux-Fortran-LFortran-0.41.0-gcc
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-LFortran-0.41.0-clang.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-Fortran-LFortran-0.41.0-clang.output
new file mode 100644
index 0000000..e0af3e3
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-Fortran-LFortran-0.41.0-clang.output
@@ -0,0 +1,4 @@
+libs=lfortran_runtime;m;gcc;gcc_s;c;gcc;gcc_s
+dirs=/usr/lib64;/usr/lib/clang/19/lib/x86_64-redhat-linux-gnu;/usr/lib/gcc/x86_64-redhat-linux/14;/lib64;/lib;/usr/lib
+library_arch=x86_64-redhat-linux-gnu
+linker_tool=/usr/bin/ld
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-Fortran-LFortran-0.41.0-gcc.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-Fortran-LFortran-0.41.0-gcc.output
new file mode 100644
index 0000000..f1b1993
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-Fortran-LFortran-0.41.0-gcc.output
@@ -0,0 +1,4 @@
+libs=lfortran_runtime;m;gcc;gcc_s;c;gcc;gcc_s
+dirs=/usr/lib64;/usr/lib/gcc/x86_64-redhat-linux/14;/lib64;/usr/lib
+library_arch=
+linker_tool=/usr/bin/ld