meson/meson-gcc10.patch

37 lines
1.6 KiB
Diff

From 92102a911d3af9c69d33a386cc32f150bc14ba18 Mon Sep 17 00:00:00 2001
From: Nirbheek Chauhan <nirbheek@centricular.com>
Date: Thu, 14 May 2020 09:41:12 +0530
Subject: [PATCH] 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(+)
Index: meson-0.54.1/mesonbuild/compilers/fortran.py
===================================================================
--- meson-0.54.1.orig/mesonbuild/compilers/fortran.py
+++ meson-0.54.1/mesonbuild/compilers/fortran.py
@@ -208,6 +208,18 @@ class GnuFortranCompiler(GnuCompiler, Fo
def language_stdlib_only_link_flags(self):
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,