diff --git a/Modules/FortranCInterface/CMakeLists.txt b/Modules/FortranCInterface/CMakeLists.txt index af7d32d27f..cabbb32b6a 100644 --- a/Modules/FortranCInterface/CMakeLists.txt +++ b/Modules/FortranCInterface/CMakeLists.txt @@ -104,7 +104,12 @@ target_link_libraries(symbols PUBLIC myfort) set_property(TARGET symbols PROPERTY POSITION_INDEPENDENT_CODE 1) if(CMAKE_Fortran_COMPILER_ID STREQUAL "LFortran") - add_compile_options(--implicit-interface --generate-object-code) + if(CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL "0.55") + set(_LFORTRAN_SC_FLAG --separate-compilation) + else() + set(_LFORTRAN_SC_FLAG --generate-object-code) + endif() + add_compile_options(--implicit-interface ${_LFORTRAN_SC_FLAG}) endif() # Require symbols through Fortran. diff --git a/Modules/FortranCInterface/Verify/CMakeLists.txt b/Modules/FortranCInterface/Verify/CMakeLists.txt index 7367968825..04fa6aa4ee 100644 --- a/Modules/FortranCInterface/Verify/CMakeLists.txt +++ b/Modules/FortranCInterface/Verify/CMakeLists.txt @@ -5,7 +5,12 @@ cmake_minimum_required(VERSION ${CMAKE_VERSION}) project(VerifyFortranC C Fortran) if(CMAKE_Fortran_COMPILER_ID STREQUAL "LFortran") - add_compile_options("$<$:--generate-object-code>") + if(CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL "0.55") + set(_LFORTRAN_SC_FLAG --separate-compilation) + else() + set(_LFORTRAN_SC_FLAG --generate-object-code) + endif() + add_compile_options("$<$:${_LFORTRAN_SC_FLAG}>") endif() option(VERIFY_CXX "Whether to verify C++ and Fortran" OFF) diff --git a/Tests/Fortran/CMakeLists.txt b/Tests/Fortran/CMakeLists.txt index ce36829a37..4769ab22ea 100644 --- a/Tests/Fortran/CMakeLists.txt +++ b/Tests/Fortran/CMakeLists.txt @@ -38,7 +38,12 @@ if(WIN32 AND NOT CYGWIN) endif() if(CMAKE_Fortran_COMPILER_ID STREQUAL "LFortran") - add_compile_options("$<$:--implicit-interface;--generate-object-code>") + if(CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL "0.55") + set(_LFORTRAN_SC_FLAG --separate-compilation) + else() + set(_LFORTRAN_SC_FLAG --generate-object-code) + endif() + add_compile_options("$<$:--implicit-interface;${_LFORTRAN_SC_FLAG}>") endif() add_library(hello STATIC hello.f) diff --git a/Tests/FortranOnly/CMakeLists.txt b/Tests/FortranOnly/CMakeLists.txt index d32c3bdff6..a59cf83675 100644 --- a/Tests/FortranOnly/CMakeLists.txt +++ b/Tests/FortranOnly/CMakeLists.txt @@ -9,7 +9,12 @@ if("${CMAKE_Fortran_COMPILER_ID};${CMAKE_Fortran_SIMULATE_ID}" MATCHES "^Intel(L endif() if(CMAKE_Fortran_COMPILER_ID STREQUAL "LFortran") - add_compile_options(--implicit-interface --generate-object-code) + if(CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL "0.55") + set(_LFORTRAN_SC_FLAG --separate-compilation) + else() + set(_LFORTRAN_SC_FLAG --generate-object-code) + endif() + add_compile_options(--implicit-interface ${_LFORTRAN_SC_FLAG}) endif() # create a library with hello and world functions diff --git a/Tests/Module/CheckIPOSupported-Fortran/CMakeLists.txt b/Tests/Module/CheckIPOSupported-Fortran/CMakeLists.txt index 4d03a93891..3017898e24 100644 --- a/Tests/Module/CheckIPOSupported-Fortran/CMakeLists.txt +++ b/Tests/Module/CheckIPOSupported-Fortran/CMakeLists.txt @@ -4,7 +4,12 @@ project(CheckIPOSupported-Fortran LANGUAGES Fortran) cmake_policy(SET CMP0069 NEW) if(CMAKE_Fortran_COMPILER_ID STREQUAL "LFortran") - add_compile_options(--implicit-interface --generate-object-code) + if(CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL "0.55") + set(_LFORTRAN_SC_FLAG --separate-compilation) + else() + set(_LFORTRAN_SC_FLAG --generate-object-code) + endif() + add_compile_options(--implicit-interface ${_LFORTRAN_SC_FLAG}) endif() include(CheckIPOSupported) diff --git a/Tests/RunCMake/ParseImplicitData/linux-Fortran-LFortran-0.55.0-clang.input b/Tests/RunCMake/ParseImplicitData/linux-Fortran-LFortran-0.55.0-clang.input new file mode 100644 index 0000000000..8e4e5dd5e5 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitData/linux-Fortran-LFortran-0.55.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=x86_64 +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.55.0 +CMAKE_Fortran_COMPILER_VERSION_INTERNAL= +Change Dir: '/tmp/ii/CMakeFiles/CMakeTmp' + +Run Build Command(s): /tmp/CMake/bin/cmake -E env VERBOSE=1 /usr/bin/gmake -f Makefile cmTC_1058c/fast +/usr/bin/gmake -f CMakeFiles/cmTC_1058c.dir/build.make CMakeFiles/cmTC_1058c.dir/build +gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp' +Building Fortran object CMakeFiles/cmTC_1058c.dir/CMakeFortranCompilerABI.F.o +/usr/bin/lfortran --cpp-infer --linker=clang -v -Wl,-v -c /tmp/CMake/Modules/CMakeFortranCompilerABI.F -o CMakeFiles/cmTC_1058c.dir/CMakeFortranCompilerABI.F.o +Linking Fortran executable cmTC_1058c +/tmp/CMake/bin/cmake -E cmake_link_script CMakeFiles/cmTC_1058c.dir/link.txt --verbose=1 +clang -o cmTC_1058c CMakeFiles/cmTC_1058c.dir/CMakeFortranCompilerABI.F.o -L"/usr/bin/../lib64" -Wl,-rpath,"/usr/bin/../lib64" -Wl,-v -llfortran_runtime -lm -v +clang version 21.1.1 (Fedora 21.1.1-1.fc43) +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/15 +Selected GCC installation: /usr/bin/../lib/gcc/x86_64-redhat-linux/15 +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_1058c /usr/bin/../lib/gcc/x86_64-redhat-linux/15/../../../../lib64/crt1.o /usr/bin/../lib/gcc/x86_64-redhat-linux/15/../../../../lib64/crti.o /usr/bin/../lib/gcc/x86_64-redhat-linux/15/crtbegin.o -L/usr/bin/../lib64 -L/usr/bin/../lib/clang/21/lib/x86_64-redhat-linux-gnu -L/usr/bin/../lib/gcc/x86_64-redhat-linux/15 -L/usr/bin/../lib/gcc/x86_64-redhat-linux/15/../../../../lib64 -L/lib/../lib64 -L/usr/lib64 -L/lib -L/usr/lib CMakeFiles/cmTC_1058c.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/15/crtend.o /usr/bin/../lib/gcc/x86_64-redhat-linux/15/../../../../lib64/crtn.o +GNU ld version 2.45-1.fc43 +/usr/bin/lfortran -v -Wl,-v --linker=clang CMakeFiles/cmTC_1058c.dir/CMakeFortranCompilerABI.F.o -o cmTC_1058c +gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp' diff --git a/Tests/RunCMake/ParseImplicitData/linux-Fortran-LFortran-0.55.0-gcc.input b/Tests/RunCMake/ParseImplicitData/linux-Fortran-LFortran-0.55.0-gcc.input new file mode 100644 index 0000000000..376ee076d1 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitData/linux-Fortran-LFortran-0.55.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=x86_64 +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.55.0 +CMAKE_Fortran_COMPILER_VERSION_INTERNAL= +Change Dir: '/tmp/ii/CMakeFiles/CMakeTmp' + +Run Build Command(s): /tmp/CMake/bin/cmake -E env VERBOSE=1 /usr/bin/gmake -f Makefile cmTC_e5d48/fast +/usr/bin/gmake -f CMakeFiles/cmTC_e5d48.dir/build.make CMakeFiles/cmTC_e5d48.dir/build +gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp' +Building Fortran object CMakeFiles/cmTC_e5d48.dir/CMakeFortranCompilerABI.F.o +/usr/bin/lfortran --cpp-infer --linker=gcc -v -Wl,-v -c /tmp/CMake/Modules/CMakeFortranCompilerABI.F -o CMakeFiles/cmTC_e5d48.dir/CMakeFortranCompilerABI.F.o +Linking Fortran executable cmTC_e5d48 +/tmp/CMake/bin/cmake -E cmake_link_script CMakeFiles/cmTC_e5d48.dir/link.txt --verbose=1 +gcc -o cmTC_e5d48 CMakeFiles/cmTC_e5d48.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/15/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,cobol,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-15.2.1-build/gcc-15.2.1-20250808/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 15.2.1 20250808 (Red Hat 15.2.1-1) (GCC) +COMPILER_PATH=/usr/libexec/gcc/x86_64-redhat-linux/15/:/usr/libexec/gcc/x86_64-redhat-linux/15/:/usr/libexec/gcc/x86_64-redhat-linux/:/usr/lib/gcc/x86_64-redhat-linux/15/:/usr/lib/gcc/x86_64-redhat-linux/ +LIBRARY_PATH=/usr/lib/gcc/x86_64-redhat-linux/15/:/usr/lib/gcc/x86_64-redhat-linux/15/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/usr/lib/gcc/x86_64-redhat-linux/15/../../../:/lib/:/usr/lib/ +COLLECT_GCC_OPTIONS='-o' 'cmTC_e5d48' '-L/usr/bin/../lib64' '-foffload-options=-l_GCC_m' '-v' '-mtune=generic' '-march=x86-64' '-dumpdir' 'cmTC_e5d48.' + /usr/libexec/gcc/x86_64-redhat-linux/15/collect2 -plugin /usr/libexec/gcc/x86_64-redhat-linux/15/liblto_plugin.so -plugin-opt=/usr/libexec/gcc/x86_64-redhat-linux/15/lto-wrapper -plugin-opt=-fresolution=/tmp/cc5Ml5eq.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_e5d48 /usr/lib/gcc/x86_64-redhat-linux/15/../../../../lib64/crt1.o /usr/lib/gcc/x86_64-redhat-linux/15/../../../../lib64/crti.o /usr/lib/gcc/x86_64-redhat-linux/15/crtbegin.o -L/usr/bin/../lib64 -L/usr/lib/gcc/x86_64-redhat-linux/15 -L/usr/lib/gcc/x86_64-redhat-linux/15/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-redhat-linux/15/../../.. -L/lib -L/usr/lib CMakeFiles/cmTC_e5d48.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/15/crtend.o /usr/lib/gcc/x86_64-redhat-linux/15/../../../../lib64/crtn.o +collect2 version 15.2.1 20250808 (Red Hat 15.2.1-1) +/usr/bin/ld -plugin /usr/libexec/gcc/x86_64-redhat-linux/15/liblto_plugin.so -plugin-opt=/usr/libexec/gcc/x86_64-redhat-linux/15/lto-wrapper -plugin-opt=-fresolution=/tmp/cc5Ml5eq.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_e5d48 /usr/lib/gcc/x86_64-redhat-linux/15/../../../../lib64/crt1.o /usr/lib/gcc/x86_64-redhat-linux/15/../../../../lib64/crti.o /usr/lib/gcc/x86_64-redhat-linux/15/crtbegin.o -L/usr/bin/../lib64 -L/usr/lib/gcc/x86_64-redhat-linux/15 -L/usr/lib/gcc/x86_64-redhat-linux/15/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-redhat-linux/15/../../.. -L/lib -L/usr/lib CMakeFiles/cmTC_e5d48.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/15/crtend.o /usr/lib/gcc/x86_64-redhat-linux/15/../../../../lib64/crtn.o +GNU ld version 2.45-1.fc43 +COLLECT_GCC_OPTIONS='-o' 'cmTC_e5d48' '-L/usr/bin/../lib64' '-foffload-options=-l_GCC_m' '-v' '-mtune=generic' '-march=x86-64' '-dumpdir' 'cmTC_e5d48.' +/usr/bin/lfortran -v -Wl,-v --linker=gcc CMakeFiles/cmTC_e5d48.dir/CMakeFortranCompilerABI.F.o -o cmTC_e5d48 +gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp' diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/ParseImplicitLinkInfo.cmake b/Tests/RunCMake/ParseImplicitLinkInfo/ParseImplicitLinkInfo.cmake index fef216df62..46d5c8ded8 100644 --- a/Tests/RunCMake/ParseImplicitLinkInfo/ParseImplicitLinkInfo.cmake +++ b/Tests/RunCMake/ParseImplicitLinkInfo/ParseImplicitLinkInfo.cmake @@ -48,6 +48,8 @@ set(targets linux-Fortran-LFortran-0.35.0-gcc linux-Fortran-LFortran-0.41.0-clang linux-Fortran-LFortran-0.41.0-gcc + linux-Fortran-LFortran-0.55.0-clang + linux-Fortran-LFortran-0.55.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.55.0-clang.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-Fortran-LFortran-0.55.0-clang.output new file mode 100644 index 0000000000..82438501df --- /dev/null +++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-Fortran-LFortran-0.55.0-clang.output @@ -0,0 +1,4 @@ +libs=lfortran_runtime;m;gcc;gcc_s;c;gcc;gcc_s +dirs=/usr/lib64;/usr/lib/clang/21/lib/x86_64-redhat-linux-gnu;/usr/lib/gcc/x86_64-redhat-linux/15;/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.55.0-gcc.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-Fortran-LFortran-0.55.0-gcc.output new file mode 100644 index 0000000000..c04e12baa0 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-Fortran-LFortran-0.55.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/15;/lib64;/usr/lib;/lib +library_arch= +linker_tool=/usr/bin/ld diff --git a/Tests/VSGNUFortran/subdir/fortran/CMakeLists.txt b/Tests/VSGNUFortran/subdir/fortran/CMakeLists.txt index 5689289b78..9080c24d61 100644 --- a/Tests/VSGNUFortran/subdir/fortran/CMakeLists.txt +++ b/Tests/VSGNUFortran/subdir/fortran/CMakeLists.txt @@ -26,7 +26,12 @@ target_link_libraries(sunq sunquad) endfunction() if(CMAKE_Fortran_COMPILER_ID STREQUAL "LFortran") - add_compile_options(--implicit-interface --generate-object-code) + if(CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL "0.55") + set(_LFORTRAN_SC_FLAG --separate-compilation) + else() + set(_LFORTRAN_SC_FLAG --generate-object-code) + endif() + add_compile_options(--implicit-interface ${_LFORTRAN_SC_FLAG}) endif() # check for the fortran c interface mangling