diff options
author | Brad King <brad.king@kitware.com> | 2024-07-24 14:02:39 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2024-07-24 14:02:54 (GMT) |
commit | 4c35a71ae9ebe92efe22a7b70688aae2a055148b (patch) | |
tree | 71f7b0d78db265a632b22016669d47eca400566f | |
parent | 077691942a778516e6d88051d8f5d691ee037b33 (diff) | |
parent | aff38fed4f491b4e48346e322ddc9b1980a2244f (diff) | |
download | CMake-4c35a71ae9ebe92efe22a7b70688aae2a055148b.zip CMake-4c35a71ae9ebe92efe22a7b70688aae2a055148b.tar.gz CMake-4c35a71ae9ebe92efe22a7b70688aae2a055148b.tar.bz2 |
Merge topic 'lfortran'
aff38fed4f ci: Add nightly jobs for LFortran on Fedora
a0def56402 ci: Add lfortran to Fedora base image
98d0f918ba LFortran: Add support for this compiler
c6f81bdacf Tests/RunCMake: Pass Fortran compiler id into more tests
fa1b748389 Tests/RunCMake/DependencyGraph: Specify Fortran function return type
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: scivision <michael@scivision.dev>
Acked-by: Matthew Thompson <fortran@gmail.com>
Merge-request: !9188
25 files changed, 129 insertions, 8 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d52beda..85ef4e7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -234,6 +234,26 @@ t:fedora39-hip-radeon: variables: CMAKE_CI_JOB_NIGHTLY: "true" +t:fedora40-makefiles-lfortran: + extends: + - .fedora40_makefiles_lfortran + - .cmake_test_linux_release + - .linux_x86_64_tags + - .run_dependent + - .needs_centos7_x86_64 + variables: + CMAKE_CI_JOB_NIGHTLY: "true" + +t:fedora40-ninja-lfortran: + extends: + - .fedora40_ninja_lfortran + - .cmake_test_linux_release + - .linux_x86_64_tags + - .run_dependent + - .needs_centos7_x86_64 + variables: + CMAKE_CI_JOB_NIGHTLY: "true" + t:fedora40-ninja-clang: extends: - .fedora40_ninja_clang diff --git a/.gitlab/ci/configure_fedora40_common_lfortran.cmake b/.gitlab/ci/configure_fedora40_common_lfortran.cmake new file mode 100644 index 0000000..48469e2 --- /dev/null +++ b/.gitlab/ci/configure_fedora40_common_lfortran.cmake @@ -0,0 +1,5 @@ +set(CMAKE_Fortran_COMPILER "/usr/bin/lfortran" CACHE FILEPATH "") +set(CMAKE_Fortran_COMPILER_ID "LFortran" CACHE STRING "") +set(CMAKE_Fortran_COMPILER_SUPPORTS_F90 "1" CACHE BOOL "") + +include("${CMAKE_CURRENT_LIST_DIR}/configure_external_test.cmake") diff --git a/.gitlab/ci/configure_fedora40_makefiles_lfortran.cmake b/.gitlab/ci/configure_fedora40_makefiles_lfortran.cmake new file mode 100644 index 0000000..d626d4d --- /dev/null +++ b/.gitlab/ci/configure_fedora40_makefiles_lfortran.cmake @@ -0,0 +1 @@ +include("${CMAKE_CURRENT_LIST_DIR}/configure_fedora40_common_lfortran.cmake") diff --git a/.gitlab/ci/configure_fedora40_ninja_lfortran.cmake b/.gitlab/ci/configure_fedora40_ninja_lfortran.cmake new file mode 100644 index 0000000..d626d4d --- /dev/null +++ b/.gitlab/ci/configure_fedora40_ninja_lfortran.cmake @@ -0,0 +1 @@ +include("${CMAKE_CURRENT_LIST_DIR}/configure_fedora40_common_lfortran.cmake") diff --git a/.gitlab/ci/docker/fedora40/deps_packages.lst b/.gitlab/ci/docker/fedora40/deps_packages.lst index c7bad7c..9fc0a5c 100644 --- a/.gitlab/ci/docker/fedora40/deps_packages.lst +++ b/.gitlab/ci/docker/fedora40/deps_packages.lst @@ -13,6 +13,7 @@ compiler-rt flang gcc-c++ git-core +lfortran llvm-devel make diff --git a/.gitlab/ci/env_fedora40_common_lfortran.sh b/.gitlab/ci/env_fedora40_common_lfortran.sh new file mode 100644 index 0000000..499369c --- /dev/null +++ b/.gitlab/ci/env_fedora40_common_lfortran.sh @@ -0,0 +1 @@ +export FC=/usr/bin/lfortran diff --git a/.gitlab/ci/env_fedora40_makefiles_lfortran.sh b/.gitlab/ci/env_fedora40_makefiles_lfortran.sh new file mode 100644 index 0000000..15fbf3e --- /dev/null +++ b/.gitlab/ci/env_fedora40_makefiles_lfortran.sh @@ -0,0 +1 @@ +. .gitlab/ci/env_fedora40_common_lfortran.sh diff --git a/.gitlab/ci/env_fedora40_ninja_lfortran.sh b/.gitlab/ci/env_fedora40_ninja_lfortran.sh new file mode 100644 index 0000000..15fbf3e --- /dev/null +++ b/.gitlab/ci/env_fedora40_ninja_lfortran.sh @@ -0,0 +1 @@ +. .gitlab/ci/env_fedora40_common_lfortran.sh diff --git a/.gitlab/os-linux.yml b/.gitlab/os-linux.yml index f9fd6c2..11d703a 100644 --- a/.gitlab/os-linux.yml +++ b/.gitlab/os-linux.yml @@ -69,7 +69,7 @@ ### Fedora .fedora40: - image: "kitware/cmake:ci-fedora40-x86_64-2024-04-24" + image: "kitware/cmake:ci-fedora40-x86_64-2024-07-23" variables: GIT_CLONE_PATH: "$CI_BUILDS_DIR/cmake ci/long file name for testing purposes" @@ -234,6 +234,25 @@ CMAKE_CONFIGURATION: fedora40_makefiles_clang CMAKE_GENERATOR: "Unix Makefiles" +.fedora40_makefiles_lfortran: + extends: .fedora40 + + variables: + # FIXME(lfortran): -rpath flags with spaces not forwarded + GIT_CLONE_PATH: "$CI_BUILDS_DIR/cmake-ci" + CMAKE_CONFIGURATION: fedora40_makefiles_lfortran + CMAKE_GENERATOR: "Unix Makefiles" + CTEST_LABELS: "Fortran" + +.fedora40_ninja_lfortran: + extends: .fedora40 + + variables: + # FIXME(lfortran): -rpath flags with spaces not forwarded + GIT_CLONE_PATH: "$CI_BUILDS_DIR/cmake-ci" + CMAKE_CONFIGURATION: fedora40_ninja_lfortran + CTEST_LABELS: "Fortran" + .fedora40_ninja_clang: extends: .fedora40 diff --git a/Help/release/dev/lfortran.rst b/Help/release/dev/lfortran.rst new file mode 100644 index 0000000..e63835e --- /dev/null +++ b/Help/release/dev/lfortran.rst @@ -0,0 +1,5 @@ +lfortran +-------- + +* The LFortran compiler is now supported with + :variable:`compiler id <CMAKE_<LANG>_COMPILER_ID>` ``LFortran``. diff --git a/Help/variable/CMAKE_LANG_COMPILER_ID.rst b/Help/variable/CMAKE_LANG_COMPILER_ID.rst index b1e2687..72cd832 100644 --- a/Help/variable/CMAKE_LANG_COMPILER_ID.rst +++ b/Help/variable/CMAKE_LANG_COMPILER_ID.rst @@ -32,6 +32,7 @@ Value Name ``Intel`` Intel Classic Compiler ``IntelLLVM`` `Intel LLVM-Based Compiler`_ ``LCC`` MCST Elbrus C/C++/Fortran Compiler +``LFortran`` LFortran Fortran Compiler ``MSVC`` `Microsoft Visual Studio`_ ``NVHPC`` `NVIDIA HPC Compiler`_ ``NVIDIA`` `NVIDIA CUDA Compiler`_ diff --git a/Modules/CMakeDetermineFortranCompiler.cmake b/Modules/CMakeDetermineFortranCompiler.cmake index 613b0c4..f051163 100644 --- a/Modules/CMakeDetermineFortranCompiler.cmake +++ b/Modules/CMakeDetermineFortranCompiler.cmake @@ -60,6 +60,7 @@ else() # ifx: Intel Fortran LLVM-based compiler # ifort: Intel Classic Fortran compiler # nagfor: NAG Fortran compiler + # lfortran: LFortran Fortran Compiler # # GNU is last to be searched, # so if you paid for a compiler it is picked by default. @@ -108,6 +109,9 @@ else() # Intel on windows does not preprocess by default. "-fpp" + + # LFortran does not preprocess by default. + "--cpp-infer" ) endif() diff --git a/Modules/CMakeFortranCompilerId.F.in b/Modules/CMakeFortranCompilerId.F.in index a040073..d97bd68 100644 --- a/Modules/CMakeFortranCompilerId.F.in +++ b/Modules/CMakeFortranCompilerId.F.in @@ -179,6 +179,11 @@ # elif defined(__FRT_version__) PRINT *, 'INFO:compiler_version['//__FRT_version__//']' # endif +#elif defined(__LFORTRAN__) + PRINT *, 'INFO:compiler[LFortran]' +#define COMPILER_VERSION_MAJOR DEC(__LFORTRAN_MAJOR__) +#define COMPILER_VERSION_MINOR DEC(__LFORTRAN_MINOR__) +#define COMPILER_VERSION_PATCH DEC(__LFORTRAN_PATCHLEVEL__) #else PRINT *, 'INFO:compiler[]' #endif diff --git a/Modules/Compiler/LFortran-Fortran.cmake b/Modules/Compiler/LFortran-Fortran.cmake new file mode 100644 index 0000000..4180730 --- /dev/null +++ b/Modules/Compiler/LFortran-Fortran.cmake @@ -0,0 +1,14 @@ +string(APPEND CMAKE_Fortran_FLAGS_DEBUG_INIT " -g") +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_FORMAT_FIXED_FLAG "--fixed-form") +set(CMAKE_Fortran_LINKER_WRAPPER_FLAG "-Wl,") +set(CMAKE_Fortran_COMPILE_OPTIONS_PREPROCESS_ON "--cpp") +set(CMAKE_Fortran_COMPILE_OPTIONS_PREPROCESS_OFF "--no-cpp") +set(CMAKE_Fortran_PREPROCESS_SOURCE "<CMAKE_Fortran_COMPILER> --cpp <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") +set(CMAKE_Fortran_COMPILE_OBJECT "<CMAKE_Fortran_COMPILER> --cpp-infer <DEFINES> <INCLUDES> <FLAGS> --generate-object-code -c <SOURCE> -o <OBJECT>") +set(CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS "--shared") +set(CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS "-Wl,-export-dynamic") diff --git a/Modules/FortranCInterface/CMakeLists.txt b/Modules/FortranCInterface/CMakeLists.txt index 2e8e14f..56a045c 100644 --- a/Modules/FortranCInterface/CMakeLists.txt +++ b/Modules/FortranCInterface/CMakeLists.txt @@ -100,6 +100,10 @@ target_link_libraries(symbols PUBLIC myfort) # the C compiler produces PIC even if it is not its default. set_property(TARGET symbols PROPERTY POSITION_INDEPENDENT_CODE 1) +if(CMAKE_Fortran_COMPILER_ID STREQUAL "LFortran") + add_compile_options(--implicit-interface) +endif() + # Require symbols through Fortran. add_executable(FortranCInterface main.F call_sub.f ${call_mod}) target_link_libraries(FortranCInterface PUBLIC symbols) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 69f48f5..0ff2cdc 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -3335,7 +3335,10 @@ if(BUILD_TESTING) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Fortran") set_property(TEST Fortran APPEND PROPERTY LABELS "Fortran") - if(CMAKE_Fortran_COMPILER_SUPPORTS_F90) + if(CMAKE_Fortran_COMPILER_SUPPORTS_F90 + # FIXME(lfortran): The compiler fails on the test's modules. + AND NOT CMAKE_Fortran_COMPILER_ID STREQUAL "LFortran" + ) add_test(FortranModules ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/FortranModules" diff --git a/Tests/Fortran/CMakeLists.txt b/Tests/Fortran/CMakeLists.txt index 41d3b4e..71f9413 100644 --- a/Tests/Fortran/CMakeLists.txt +++ b/Tests/Fortran/CMakeLists.txt @@ -37,6 +37,10 @@ if(WIN32 AND NOT CYGWIN) endif() endif() +if(CMAKE_Fortran_COMPILER_ID STREQUAL "LFortran") + add_compile_options(--implicit-interface) +endif() + add_library(hello STATIC hello.f) add_library(world ${_SHARED} world.f ${world_def}) add_executable(testf testf.f) diff --git a/Tests/FortranOnly/CMakeLists.txt b/Tests/FortranOnly/CMakeLists.txt index 73312a0..e4a5019 100644 --- a/Tests/FortranOnly/CMakeLists.txt +++ b/Tests/FortranOnly/CMakeLists.txt @@ -7,6 +7,10 @@ if("${CMAKE_Fortran_COMPILER_ID};${CMAKE_Fortran_SIMULATE_ID}" MATCHES "^Intel(L string(APPEND CMAKE_Fortran_FLAGS_RELWITHDEBINFO " -Z7") endif() +if(CMAKE_Fortran_COMPILER_ID STREQUAL "LFortran") + add_compile_options(--implicit-interface) +endif() + # create a library with hello and world functions add_library(FortranOnlylib hello.f world.f) set_property(TARGET FortranOnlylib PROPERTY Fortran_FORMAT FIXED) diff --git a/Tests/Module/CheckIPOSupported-Fortran/CMakeLists.txt b/Tests/Module/CheckIPOSupported-Fortran/CMakeLists.txt index 3872b56..eea8981 100644 --- a/Tests/Module/CheckIPOSupported-Fortran/CMakeLists.txt +++ b/Tests/Module/CheckIPOSupported-Fortran/CMakeLists.txt @@ -3,6 +3,10 @@ project(CheckIPOSupported-Fortran LANGUAGES Fortran) cmake_policy(SET CMP0069 NEW) +if(CMAKE_Fortran_COMPILER_ID STREQUAL "LFortran") + add_compile_options(--implicit-interface) +endif() + include(CheckIPOSupported) check_ipo_supported(RESULT ipo_supported OUTPUT ipo_output) if(ipo_supported) diff --git a/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake index a5f9622..d5be807 100644 --- a/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake +++ b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake @@ -68,7 +68,10 @@ if(NOT RunCMake_GENERATOR STREQUAL "Xcode") unset(run_BuildDepends_skip_step_2) endif() -if(CMake_TEST_Fortran) +if(CMake_TEST_Fortran + # FIXME(lfortran): The compiler fails on the test's includes. + AND NOT CMAKE_Fortran_COMPILER_ID STREQUAL "LFortran" + ) run_BuildDepends(FortranInclude) endif() diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index ddd48cb..a595960 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -217,7 +217,10 @@ if(CMAKE_GENERATOR MATCHES "Ninja") -DCMAKE_SHARED_LIBRARY_PREFIX=${CMAKE_SHARED_LIBRARY_PREFIX} -DCMAKE_SHARED_LIBRARY_SUFFIX=${CMAKE_SHARED_LIBRARY_SUFFIX}) if(CMAKE_Fortran_COMPILER) - list(APPEND Ninja_ARGS -DTEST_Fortran=1) + list(APPEND Ninja_ARGS + -DCMake_TEST_Fortran=1 + -DCMAKE_Fortran_COMPILER_ID=${CMAKE_Fortran_COMPILER_ID} + ) endif() if(ninja_test_with_qt_version) list(APPEND Ninja_ARGS @@ -333,7 +336,10 @@ if(NOT DEFINED CMake_TEST_BuildDepends_GNU_AS endif() if(CMAKE_Fortran_COMPILER) - list(APPEND BuildDepends_ARGS -DCMake_TEST_Fortran=1) + list(APPEND BuildDepends_ARGS + -DCMake_TEST_Fortran=1 + -DCMAKE_Fortran_COMPILER_ID=${CMAKE_Fortran_COMPILER_ID} + ) endif() add_RunCMake_test(BuildDepends @@ -684,7 +690,13 @@ if(CMake_TEST_CUDA) set_property(TEST RunCMake.CUDA_architectures APPEND PROPERTY LABELS "CUDA") endif() -add_RunCMake_test(DependencyGraph -DCMAKE_Fortran_COMPILER=${CMAKE_Fortran_COMPILER}) +if(CMAKE_Fortran_COMPILER) + list(APPEND DependencyGraph_ARGS + -DCMake_TEST_Fortran=1 + -DCMAKE_Fortran_COMPILER_ID=${CMAKE_Fortran_COMPILER_ID} + ) + endif() +add_RunCMake_test(DependencyGraph) set_property(TEST RunCMake.DependencyGraph APPEND PROPERTY LABELS "Fortran") # Add C++ Module tests. diff --git a/Tests/RunCMake/DependencyGraph/RunCMakeTest.cmake b/Tests/RunCMake/DependencyGraph/RunCMakeTest.cmake index f7959dc..1981fce 100644 --- a/Tests/RunCMake/DependencyGraph/RunCMakeTest.cmake +++ b/Tests/RunCMake/DependencyGraph/RunCMakeTest.cmake @@ -60,7 +60,7 @@ run_cmake(Property) run_optimize_test(OptimizeShared SharedTop) run_optimize_test(OptimizeStatic StaticTop) -if(CMAKE_Fortran_COMPILER) +if(CMake_TEST_Fortran) run_optimize_test(OptimizeFortran FortranTop) endif() diff --git a/Tests/RunCMake/DependencyGraph/mylib.f90 b/Tests/RunCMake/DependencyGraph/mylib.f90 index 104768f..d3fac72 100644 --- a/Tests/RunCMake/DependencyGraph/mylib.f90 +++ b/Tests/RunCMake/DependencyGraph/mylib.f90 @@ -1,3 +1,4 @@ function mylib_fortran() + integer :: mylib_fortran mylib_fortran = 42 end function mylib_fortran diff --git a/Tests/RunCMake/Ninja/RunCMakeTest.cmake b/Tests/RunCMake/Ninja/RunCMakeTest.cmake index 8b24c16..d1f99b2 100644 --- a/Tests/RunCMake/Ninja/RunCMakeTest.cmake +++ b/Tests/RunCMake/Ninja/RunCMakeTest.cmake @@ -108,7 +108,10 @@ run_cmake(JobPoolUsesTerminal) run_cmake(RspFileC) run_cmake(RspFileCXX) -if(TEST_Fortran) +if(CMake_TEST_Fortran + # FIXME(lfortran): The compiler does not support response files. + AND NOT CMAKE_Fortran_COMPILER_ID STREQUAL "LFortran" + ) run_cmake(RspFileFortran) endif() diff --git a/Tests/VSGNUFortran/subdir/fortran/CMakeLists.txt b/Tests/VSGNUFortran/subdir/fortran/CMakeLists.txt index 8918d98..f8c2a25 100644 --- a/Tests/VSGNUFortran/subdir/fortran/CMakeLists.txt +++ b/Tests/VSGNUFortran/subdir/fortran/CMakeLists.txt @@ -25,6 +25,10 @@ target_link_libraries(sunq sunquad) set(${result} "${RESULT}" PARENT_SCOPE) endfunction() +if(CMAKE_Fortran_COMPILER_ID STREQUAL "LFortran") + add_compile_options(--implicit-interface) +endif() + # check for the fortran c interface mangling include(FortranCInterface) FortranCInterface_HEADER(HelloWorldFCMangle.h |