Skip to content

Commit 8659c64

Browse files
committed
BLD: fortran: only use -std=legacy for gfortran
Support in other compilers for this flag is quite patchy, leading to build errors and requiring workarounds in distros - see for example: - scipy#19447 - mesonbuild/meson#12306 - https://github.com/conda-forge/scipy-feedstock/blob/1a8ff378bebd3f0b0bc6a2d1662a77d194ac59a1/recipe/bld.bat#L25 - https://github.com/spack/spack/blob/73316c3e286d548b22dc65667810e4631479c3ea/var/spack/repos/builtin/packages/py-scipy/package.py#L235-L238 Compilers that do not support it include at least Flang and AOCC (the AMD Fortran compiler). This should be fixed upstream in Meson by not passing the flag for compilers that don't support it, and then we can revert this change. But for now it's very useful to avoid bothering users of these compilers with having to override that flag manually. This does give the following warning with `gfortran` now, but that can't be helped unfortunately: ``` WARNING: Consider using the built-in option for language standard version instead of using "-std=legacy". ```
1 parent 4ffe88d commit 8659c64

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

meson.build

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ project(
99
'b_ndebug=if-release',
1010
'c_std=c17',
1111
'cpp_std=c++17',
12-
'fortran_std=legacy',
1312
'blas=openblas',
1413
'lapack=openblas'
1514
],
@@ -80,6 +79,13 @@ endif
8079
# Adding at project level causes many spurious -lgfortran flags.
8180
add_languages('fortran', native: false)
8281
ff = meson.get_compiler('fortran')
82+
if ff.get_id() == 'gcc'
83+
# -std=legacy is not supported by all Fortran compilers, but very useful with
84+
# gfortran since it avoids a ton of warnings that we don't care about.
85+
# Needs fixing in Meson, see https://github.com/mesonbuild/meson/issues/11633.
86+
add_project_arguments('-std=legacy', language: 'fortran')
87+
endif
88+
8389
if ff.has_argument('-Wno-conversion')
8490
add_project_arguments('-Wno-conversion', language: 'fortran')
8591
endif

0 commit comments

Comments
 (0)