From 37bade6f8760a4e443a8daddbcf6acd4e84b5eab Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Thu, 14 May 2020 09:41:12 +0530 Subject: gfortran: Fix has_header implementation with GCC 10 __has_include is not accepted as a pre-processor directive in Fortran code since GCC 10. Closes https://github.com/mesonbuild/meson/issues/7017 --- mesonbuild/compilers/fortran.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'mesonbuild/compilers/fortran.py') diff --git a/mesonbuild/compilers/fortran.py b/mesonbuild/compilers/fortran.py index 01283a1..c155b5b 100644 --- a/mesonbuild/compilers/fortran.py +++ b/mesonbuild/compilers/fortran.py @@ -214,6 +214,18 @@ class GnuFortranCompiler(GnuCompiler, FortranCompiler): def language_stdlib_only_link_flags(self) -> T.List[str]: return ['-lgfortran', '-lm'] + def has_header(self, hname, prefix, env, *, extra_args=None, dependencies=None, disable_cache=False): + ''' + Derived from mixins/clike.py:has_header, but without C-style usage of + __has_include which breaks with GCC-Fortran 10: + https://github.com/mesonbuild/meson/issues/7017 + ''' + fargs = {'prefix': prefix, 'header': hname} + code = '{prefix}\n#include <{header}>' + return self.compiles(code.format(**fargs), env, extra_args=extra_args, + dependencies=dependencies, mode='preprocess', disable_cache=disable_cache) + + class ElbrusFortranCompiler(GnuFortranCompiler, ElbrusCompiler): def __init__(self, exelist, version, for_machine: MachineChoice, is_cross, info: 'MachineInfo', exe_wrapper=None, -- cgit v1.1 From 9dc3ca2c1c9fbb47e731551c6432df144f725261 Mon Sep 17 00:00:00 2001 From: Yevhenii Kolesnikov Date: Thu, 21 May 2020 18:58:47 +0300 Subject: compilers: add fetching of define list for clang Simmilar to gcc, the list of pre-processor defines can be fetched with `-dM -E` option. The way cpu_family is determined on linux relies on this list. Fixes incorrect value of cpu_family on linux, when crosscompiling: ``` CC="clang -m32" meson ./build ``` Signed-off-by: Yevhenii Kolesnikov Co-authored-by: Dylan Baker --- mesonbuild/compilers/fortran.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mesonbuild/compilers/fortran.py') diff --git a/mesonbuild/compilers/fortran.py b/mesonbuild/compilers/fortran.py index c155b5b..af83c0e56 100644 --- a/mesonbuild/compilers/fortran.py +++ b/mesonbuild/compilers/fortran.py @@ -424,7 +424,7 @@ class FlangFortranCompiler(ClangCompiler, FortranCompiler): **kwargs): FortranCompiler.__init__(self, exelist, version, for_machine, is_cross, info, exe_wrapper, **kwargs) - ClangCompiler.__init__(self) + ClangCompiler.__init__(self, []) self.id = 'flang' default_warn_args = ['-Minform=inform'] self.warn_args = {'0': [], -- cgit v1.1