From fd3ebeff3b7c4a71ad5897000b74c40d8833c90c Mon Sep 17 00:00:00 2001 From: Federico Perini Date: Wed, 5 Jun 2024 13:54:39 +0200 Subject: [PATCH 01/10] ci: ubuntu-latest -> ubuntu-24.04 --- .github/workflows/CI.yml | 8 ++++---- .github/workflows/meta.yml | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 16025d299a..de8f3d18bb 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -21,10 +21,10 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-11, windows-latest] - gcc_v: [10,11,12] # Version of GFortran we want to use. + os: [ubuntu-24.04, macos-11, windows-latest] + gcc_v: [10,11,12,13] # Version of GFortran we want to use. include: - - os: ubuntu-latest + - os: ubuntu-24.04 os-arch: linux-x86_64 release-flags: --flag '--static -g -fbacktrace -O3' @@ -264,7 +264,7 @@ jobs: upload-artifacts: if: ${{ github.event_name == 'release' && contains(github.ref, 'v') || github.event_name == 'push' }} - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 needs: - build - make-installer diff --git a/.github/workflows/meta.yml b/.github/workflows/meta.yml index 773978caea..4b476be6f7 100644 --- a/.github/workflows/meta.yml +++ b/.github/workflows/meta.yml @@ -29,11 +29,11 @@ jobs: fail-fast: false matrix: include: - - os: ubuntu-latest + - os: ubuntu-24.04 mpi: intel - - os: ubuntu-latest + - os: ubuntu-24.04 mpi: openmpi - - os: ubuntu-latest + - os: ubuntu-24.04 mpi: mpich - os: macos-12 mpi: openmpi From b1ba0ab6943d6d62966da025fd35c0aeb4256d32 Mon Sep 17 00:00:00 2001 From: Federico Perini Date: Sun, 16 Jun 2024 10:25:29 -0500 Subject: [PATCH 02/10] implement `check_fortran_source_runs` --- src/fpm_compiler.F90 | 61 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/src/fpm_compiler.F90 b/src/fpm_compiler.F90 index f173267659..18ef679b60 100644 --- a/src/fpm_compiler.F90 +++ b/src/fpm_compiler.F90 @@ -119,6 +119,8 @@ module fpm_compiler procedure :: serializable_is_same => compiler_is_same procedure :: dump_to_toml => compiler_dump procedure :: load_from_toml => compiler_load + !> Fortran feature support + procedure :: check_fortran_source_runs !> Return compiler name procedure :: name => compiler_name @@ -1017,6 +1019,8 @@ subroutine new_compiler(self, fc, cc, cxx, echo, verbose) logical, intent(in) :: echo !> Verbose mode: dump compiler output logical, intent(in) :: verbose + + logical :: quad self%id = get_compiler_id(fc) @@ -1034,6 +1038,14 @@ subroutine new_compiler(self, fc, cc, cxx, echo, verbose) else call get_default_cxx_compiler(self%fc, self%cxx) end if + + + quad = has_quad_precision(self) + + print *, 'has quad=',quad + + stop 'temporary: new compiler' + end subroutine new_compiler @@ -1424,6 +1436,53 @@ pure function compiler_name(self) result(name) end select end function compiler_name - +!> Run a single-source Fortran program using the current compiler +!> Compile a Fortran object +logical function check_fortran_source_runs(self, input) result(success) + !> Instance of the compiler object + class(compiler_t), intent(in) :: self + !> Program Source + character(len=*), intent(in) :: input + + integer :: stat,unit + character(:), allocatable :: source,object,logf,exe + + success = .false. + + !> Create temporary source file + exe = get_temp_filename() + source = exe//'.f90' + object = exe//'.o' + logf = exe//'.log' + open(newunit=unit, file=source, action='readwrite', iostat=stat) + if (stat/=0) return + + !> Write contents + write(unit,*) input + close(unit) + + !> Compile and link program + call self%compile_fortran(source, object, self%get_default_flags(release=.false.), logf, stat) + if (stat==0) & + call self%link(exe, self%get_default_flags(release=.false.)//" "//object, logf, stat) + + !> Run and retrieve exit code + if (stat==0) & + call run(exe,echo=.false., exitstat=stat) + + !> Successful exit on 0 exit code + success = stat==0 + + !> Delete files + open(newunit=unit, file=source, action='readwrite', iostat=stat) + close(unit,status='delete') + open(newunit=unit, file=object, action='readwrite', iostat=stat) + close(unit,status='delete') + open(newunit=unit, file=logf, action='readwrite', iostat=stat) + close(unit,status='delete') + open(newunit=unit, file=exe, action='readwrite', iostat=stat) + close(unit,status='delete') + +end function check_fortran_source_runs end module fpm_compiler From c29c016ed58543e1abbdf178ac6225334a13ac4d Mon Sep 17 00:00:00 2001 From: Federico Perini Date: Sun, 16 Jun 2024 10:37:53 -0500 Subject: [PATCH 03/10] cleanup --- src/fpm_compiler.F90 | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/fpm_compiler.F90 b/src/fpm_compiler.F90 index 18ef679b60..b41ace1f15 100644 --- a/src/fpm_compiler.F90 +++ b/src/fpm_compiler.F90 @@ -1038,14 +1038,7 @@ subroutine new_compiler(self, fc, cc, cxx, echo, verbose) else call get_default_cxx_compiler(self%fc, self%cxx) end if - - - quad = has_quad_precision(self) - - print *, 'has quad=',quad - - stop 'temporary: new compiler' - + end subroutine new_compiler From 5a7006269570cdbf9762dd8b34a0879a61075c40 Mon Sep 17 00:00:00 2001 From: Federico Perini Date: Sun, 16 Jun 2024 10:38:00 -0500 Subject: [PATCH 04/10] implement compiler test suite --- test/fpm_test/main.f90 | 2 ++ test/fpm_test/test_compiler.f90 | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 test/fpm_test/test_compiler.f90 diff --git a/test/fpm_test/main.f90 b/test/fpm_test/main.f90 index be97e4d70f..6466e3054b 100644 --- a/test/fpm_test/main.f90 +++ b/test/fpm_test/main.f90 @@ -3,6 +3,7 @@ program fpm_testing use, intrinsic :: iso_fortran_env, only : error_unit use testsuite, only : run_testsuite, new_testsuite, testsuite_t, select_suite, run_selected use test_toml, only : collect_toml + use test_compiler, only : collect_compiler use test_manifest, only : collect_manifest use test_filesystem, only : collect_filesystem use test_source_parsing, only : collect_source_parsing @@ -24,6 +25,7 @@ program fpm_testing suite = [ & & new_testsuite("fpm_toml", collect_toml), & + & new_testsuite("fpm_compiler", collect_compiler), & & new_testsuite("fpm_manifest", collect_manifest), & & new_testsuite("fpm_filesystem", collect_filesystem), & & new_testsuite("fpm_source_parsing", collect_source_parsing), & diff --git a/test/fpm_test/test_compiler.f90 b/test/fpm_test/test_compiler.f90 new file mode 100644 index 0000000000..3f8deaa0d9 --- /dev/null +++ b/test/fpm_test/test_compiler.f90 @@ -0,0 +1,33 @@ +!> Define tests for the `fpm_compiler` module +module test_compiler + use testsuite, only : new_unittest, unittest_t, error_t, test_failed, & + & check_string + use fpm_environment, only : OS_WINDOWS, OS_LINUX + use fpm_compiler , only : compiler_t + implicit none + private + + public :: collect_compiler + + +contains + + !> Collect all exported unit tests + subroutine collect_compiler(testsuite) + !> Collection of tests + type(unittest_t), allocatable, intent(out) :: testsuite(:) + + testsuite = [ & + & new_unittest("check-fortran-source-runs", test_check_fortran_source_runs)] + + end subroutine collect_compiler + + subroutine test_check_fortran_source_runs(error) + !> Error handling + type(error_t), allocatable, intent(out) :: error + + + end subroutine test_check_fortran_source_runs + + +end module test_compiler From f1f0efe72fb2e3ff788a653cf08532c9be5f2c72 Mon Sep 17 00:00:00 2001 From: Federico Perini Date: Sun, 16 Jun 2024 10:52:33 -0500 Subject: [PATCH 05/10] hello world test --- src/fpm_command_line.f90 | 3 ++- test/fpm_test/main.f90 | 6 +++--- test/fpm_test/test_compiler.f90 | 27 +++++++++++++++++++++++++-- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/fpm_command_line.f90 b/src/fpm_command_line.f90 index 6035130eb4..b5655437ec 100644 --- a/src/fpm_command_line.f90 +++ b/src/fpm_command_line.f90 @@ -52,7 +52,8 @@ module fpm_command_line fpm_update_settings, & fpm_clean_settings, & fpm_publish_settings, & - get_command_line_settings + get_command_line_settings, & + get_fpm_env type, abstract :: fpm_cmd_settings character(len=:), allocatable :: working_dir diff --git a/test/fpm_test/main.f90 b/test/fpm_test/main.f90 index 6466e3054b..d272761f93 100644 --- a/test/fpm_test/main.f90 +++ b/test/fpm_test/main.f90 @@ -24,8 +24,7 @@ program fpm_testing stat = 0 suite = [ & - & new_testsuite("fpm_toml", collect_toml), & - & new_testsuite("fpm_compiler", collect_compiler), & + & new_testsuite("fpm_toml", collect_toml), & & new_testsuite("fpm_manifest", collect_manifest), & & new_testsuite("fpm_filesystem", collect_filesystem), & & new_testsuite("fpm_source_parsing", collect_source_parsing), & @@ -35,7 +34,8 @@ program fpm_testing & new_testsuite("fpm_installer", collect_installer), & & new_testsuite("fpm_versioning", collect_versioning), & & new_testsuite("fpm_settings", collect_settings), & - & new_testsuite("fpm_os", collect_os) & + & new_testsuite("fpm_os", collect_os), & + & new_testsuite("fpm_compiler", collect_compiler) & & ] call get_argument(1, suite_name) diff --git a/test/fpm_test/test_compiler.f90 b/test/fpm_test/test_compiler.f90 index 3f8deaa0d9..02c0d87b23 100644 --- a/test/fpm_test/test_compiler.f90 +++ b/test/fpm_test/test_compiler.f90 @@ -3,7 +3,8 @@ module test_compiler use testsuite, only : new_unittest, unittest_t, error_t, test_failed, & & check_string use fpm_environment, only : OS_WINDOWS, OS_LINUX - use fpm_compiler , only : compiler_t + use fpm_compiler , only : compiler_t, new_compiler + use fpm_command_line, only: get_fpm_env implicit none private @@ -25,7 +26,29 @@ end subroutine collect_compiler subroutine test_check_fortran_source_runs(error) !> Error handling type(error_t), allocatable, intent(out) :: error - + + character(:), allocatable :: fc,cc,cxx + + + type(compiler_t) :: compiler + + !> Get default compiler + fc = get_fpm_env("FC", default="gfortran") + cc = get_fpm_env("CC", default=" ") + cxx = get_fpm_env("CXX", default=" ") + + call new_compiler(compiler, fc, cc, cxx, echo=.false., verbose=.false.) + + if (compiler%is_unknown()) then + call test_failed(error, "Cannot initialize Fortran compiler") + return + end if + + !> Test fortran-source runs + if (.not.compiler%check_fortran_source_runs("print *, 'Hello world!'; end")) then + call test_failed(error, "Cannot run Fortran hello world") + return + end if end subroutine test_check_fortran_source_runs From b6af95f9120fd0393c5a071e50ea59f25f8dbff8 Mon Sep 17 00:00:00 2001 From: Federico Perini Date: Sun, 16 Jun 2024 13:15:17 -0500 Subject: [PATCH 06/10] redirect output to log --- src/fpm_compiler.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fpm_compiler.F90 b/src/fpm_compiler.F90 index b41ace1f15..bd38c01228 100644 --- a/src/fpm_compiler.F90 +++ b/src/fpm_compiler.F90 @@ -1461,7 +1461,7 @@ logical function check_fortran_source_runs(self, input) result(success) !> Run and retrieve exit code if (stat==0) & - call run(exe,echo=.false., exitstat=stat) + call run(exe,echo=.false., exitstat=stat, verbose=.false., redirect=logf) !> Successful exit on 0 exit code success = stat==0 From 07f8e016b2034a35d49c317e9dffb4b839dfcb98 Mon Sep 17 00:00:00 2001 From: Federico Perini Date: Sun, 16 Jun 2024 13:20:16 -0500 Subject: [PATCH 07/10] `qp`, `xdp` support detection --- src/fpm_compiler.F90 | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/fpm_compiler.F90 b/src/fpm_compiler.F90 index bd38c01228..3bd4a3968b 100644 --- a/src/fpm_compiler.F90 +++ b/src/fpm_compiler.F90 @@ -121,6 +121,8 @@ module fpm_compiler procedure :: load_from_toml => compiler_load !> Fortran feature support procedure :: check_fortran_source_runs + procedure :: with_xdp + procedure :: with_qp !> Return compiler name procedure :: name => compiler_name @@ -1478,4 +1480,20 @@ logical function check_fortran_source_runs(self, input) result(success) end function check_fortran_source_runs +!> Check if the current compiler supports 128-bit real precision +logical function with_qp(self) + !> Instance of the compiler object + class(compiler_t), intent(in) :: self + with_qp = self%check_fortran_source_runs & + ('if (selected_real_kind(33) == -1) stop 1; end') +end function with_qp + +!> Check if the current compiler supports 80-bit "extended" real precision +logical function with_xdp(self) + !> Instance of the compiler object + class(compiler_t), intent(in) :: self + with_xdp = self%check_fortran_source_runs & + ('if (any(selected_real_kind(18) == [-1, selected_real_kind(33)])) stop 1; end') +end function with_xdp + end module fpm_compiler From 36d180aa1d44e699e36f45629a35affd25b76f33 Mon Sep 17 00:00:00 2001 From: Federico Perini Date: Sun, 16 Jun 2024 13:34:34 -0500 Subject: [PATCH 08/10] Revert "ci: ubuntu-latest -> ubuntu-24.04" This reverts commit fd3ebeff3b7c4a71ad5897000b74c40d8833c90c. --- .github/workflows/CI.yml | 8 ++++---- .github/workflows/meta.yml | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index de8f3d18bb..16025d299a 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -21,10 +21,10 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-24.04, macos-11, windows-latest] - gcc_v: [10,11,12,13] # Version of GFortran we want to use. + os: [ubuntu-latest, macos-11, windows-latest] + gcc_v: [10,11,12] # Version of GFortran we want to use. include: - - os: ubuntu-24.04 + - os: ubuntu-latest os-arch: linux-x86_64 release-flags: --flag '--static -g -fbacktrace -O3' @@ -264,7 +264,7 @@ jobs: upload-artifacts: if: ${{ github.event_name == 'release' && contains(github.ref, 'v') || github.event_name == 'push' }} - runs-on: ubuntu-24.04 + runs-on: ubuntu-latest needs: - build - make-installer diff --git a/.github/workflows/meta.yml b/.github/workflows/meta.yml index 4b476be6f7..773978caea 100644 --- a/.github/workflows/meta.yml +++ b/.github/workflows/meta.yml @@ -29,11 +29,11 @@ jobs: fail-fast: false matrix: include: - - os: ubuntu-24.04 + - os: ubuntu-latest mpi: intel - - os: ubuntu-24.04 + - os: ubuntu-latest mpi: openmpi - - os: ubuntu-24.04 + - os: ubuntu-latest mpi: mpich - os: macos-12 mpi: openmpi From 49c67ae13678440f07cae1dad2efcf664ae54aa1 Mon Sep 17 00:00:00 2001 From: Federico Perini Date: Sun, 16 Jun 2024 13:39:24 -0500 Subject: [PATCH 09/10] cleanup --- src/fpm_compiler.F90 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/fpm_compiler.F90 b/src/fpm_compiler.F90 index 3bd4a3968b..7baa90baff 100644 --- a/src/fpm_compiler.F90 +++ b/src/fpm_compiler.F90 @@ -1021,8 +1021,6 @@ subroutine new_compiler(self, fc, cc, cxx, echo, verbose) logical, intent(in) :: echo !> Verbose mode: dump compiler output logical, intent(in) :: verbose - - logical :: quad self%id = get_compiler_id(fc) @@ -1040,7 +1038,7 @@ subroutine new_compiler(self, fc, cc, cxx, echo, verbose) else call get_default_cxx_compiler(self%fc, self%cxx) end if - + end subroutine new_compiler From c60802c79d3d4f1201650b5aaba6009a73ce53bb Mon Sep 17 00:00:00 2001 From: Federico Perini Date: Tue, 25 Jun 2024 11:18:15 +0200 Subject: [PATCH 10/10] `install.sh`: always bootstrap with 0.8.0 --- install.sh | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/install.sh b/install.sh index 4243ba6266..ca03cf4679 100755 --- a/install.sh +++ b/install.sh @@ -71,14 +71,9 @@ if [ $? -ne 0 ]; then exit 2 fi -LATEST_RELEASE=$(get_latest_release "fortran-lang/fpm" "$FETCH") - -# Fallback to a latest known release if network timeout -if [ -z "$LATEST_RELEASE" ]; then - LATEST_RELEASE="0.8.0" -fi - -SOURCE_URL="https://github.com/fortran-lang/fpm/releases/download/v${LATEST_RELEASE}/fpm-${LATEST_RELEASE}.F90" +# Use 0.8.0 too bootstrap +BOOTSTRAP_RELEASE="0.8.0" +SOURCE_URL="https://github.com/fortran-lang/fpm/releases/download/v${BOOTSTRAP_RELEASE}/fpm-${BOOTSTRAP_RELEASE}.F90" BOOTSTRAP_DIR="build/bootstrap" if [ -z ${FC+x} ]; then