From b40c1af900df5e199fab63c1486f7d17b46386b4 Mon Sep 17 00:00:00 2001 From: "Michael Hirsch, Ph.D" Date: Wed, 16 Jan 2019 12:26:47 -0500 Subject: [PATCH 1/4] Flang Fortran compiler added. --- docs/markdown/Reference-tables.md | 1 + mesonbuild/compilers/__init__.py | 2 ++ mesonbuild/compilers/compilers.py | 23 +++++++++++++++++++++++ mesonbuild/compilers/fortran.py | 7 +++++++ mesonbuild/environment.py | 4 ++++ 5 files changed, 37 insertions(+) diff --git a/docs/markdown/Reference-tables.md b/docs/markdown/Reference-tables.md index 9688bf8d0..a6289df3c 100644 --- a/docs/markdown/Reference-tables.md +++ b/docs/markdown/Reference-tables.md @@ -13,6 +13,7 @@ These are return values of the `get_id` (Compiler family) and | clang | The Clang compiler | gcc | | clang-cl | The Clang compiler (MSVC compatible driver) | msvc | | dmd | D lang reference compiler | | +| flang | Flang Fortran compiler | | | g95 | The G95 Fortran compiler | | | gcc | The GNU Compiler Collection | gcc | | intel | Intel compiler | msvc on windows, otherwise gcc | diff --git a/mesonbuild/compilers/__init__.py b/mesonbuild/compilers/__init__.py index b5b2475dd..b4807c6ef 100644 --- a/mesonbuild/compilers/__init__.py +++ b/mesonbuild/compilers/__init__.py @@ -62,6 +62,7 @@ __all__ = [ 'GnuDCompiler', 'GnuFortranCompiler', 'ElbrusFortranCompiler', + 'FlangFortranCompiler', 'GnuObjCCompiler', 'GnuObjCPPCompiler', 'IntelCompiler', @@ -153,6 +154,7 @@ from .fortran import ( G95FortranCompiler, GnuFortranCompiler, ElbrusFortranCompiler, + FlangFortranCompiler, IntelFortranCompiler, NAGFortranCompiler, Open64FortranCompiler, diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index 34c0e3b30..1e86978b4 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -1311,6 +1311,8 @@ class CompilerType(enum.Enum): PGI_STANDARD = 50 + FLANG_STANDARD = 60 + @property def is_standard_compiler(self): return self.name in ('GCC_STANDARD', 'CLANG_STANDARD', 'ICC_STANDARD') @@ -1619,6 +1621,27 @@ class PGICompiler: def openmp_flags(self): return ['-fopenmp'] + +class FlangCompiler: + def __init__(self, compiler_type): + self.id = 'flang' + self.compiler_type = compiler_type + + default_warn_args = ['-Minform=inform'] + self.warn_args = {'1': default_warn_args, + '2': default_warn_args, + '3': default_warn_args} + + def get_module_incdir_args(self): + return ('-module', ) + + def get_no_warn_args(self): + return ['-silent'] + + def openmp_flags(self): + return ['-fopenmp'] + + class ElbrusCompiler(GnuCompiler): # Elbrus compiler is nearly like GCC, but does not support # PCH, LTO, sanitizers and color output as of version 1.21.x. diff --git a/mesonbuild/compilers/fortran.py b/mesonbuild/compilers/fortran.py index 2eb4c71b5..911df46cc 100644 --- a/mesonbuild/compilers/fortran.py +++ b/mesonbuild/compilers/fortran.py @@ -22,6 +22,7 @@ from .compilers import ( clike_debug_args, Compiler, GnuCompiler, + FlangCompiler, ElbrusCompiler, IntelCompiler, PGICompiler @@ -382,6 +383,12 @@ class PGIFortranCompiler(FortranCompiler): return val +class FlangFortranCompiler(FortranCompiler): + def __init__(self, exelist, version, is_cross, exe_wrapper=None, **kwags): + FortranCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwags) + FlangCompiler.__init__(self, CompilerType.FLANG_STANDARD) + + class Open64FortranCompiler(FortranCompiler): def __init__(self, exelist, version, is_cross, exe_wrapper=None, **kwags): FortranCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwags) diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index 0e748514e..4f5115f73 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -44,6 +44,7 @@ from .compilers import ( ClangObjCPPCompiler, ClangClCCompiler, ClangClCPPCompiler, + FlangFortranCompiler, G95FortranCompiler, GnuCCompiler, GnuCPPCompiler, @@ -782,6 +783,9 @@ class Environment: if 'PGI Compilers' in out: return PGIFortranCompiler(compiler, version, is_cross, exe_wrap, full_version=full_version) + if 'flang' in out or 'clang' in out: + return FlangFortranCompiler(compiler, version, is_cross, exe_wrap, full_version=full_version) + if 'Open64 Compiler Suite' in err: return Open64FortranCompiler(compiler, version, is_cross, exe_wrap, full_version=full_version) From 9a318d3d5a99f6b4d507ff1062f4085f6af86ab8 Mon Sep 17 00:00:00 2001 From: "Michael Hirsch, Ph.D" Date: Wed, 16 Jan 2019 13:56:43 -0500 Subject: [PATCH 2/4] better handle link args: PGI and Flang correct flang, pgi options --- mesonbuild/compilers/compilers.py | 10 ++++++++-- mesonbuild/compilers/fortran.py | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index 1e86978b4..a6585543d 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -1619,7 +1619,10 @@ class PGICompiler: return ['-silent'] def openmp_flags(self): - return ['-fopenmp'] + return ['-mp'] + + def get_allow_undefined_link_args(self): + return [] class FlangCompiler: @@ -1639,7 +1642,10 @@ class FlangCompiler: return ['-silent'] def openmp_flags(self): - return ['-fopenmp'] + return ['-mp'] + + def get_allow_undefined_link_args(self): + return [] class ElbrusCompiler(GnuCompiler): diff --git a/mesonbuild/compilers/fortran.py b/mesonbuild/compilers/fortran.py index 911df46cc..3387ddaa2 100644 --- a/mesonbuild/compilers/fortran.py +++ b/mesonbuild/compilers/fortran.py @@ -371,7 +371,7 @@ class PathScaleFortranCompiler(FortranCompiler): return ['-mp'] -class PGIFortranCompiler(FortranCompiler): +class PGIFortranCompiler(PGICompiler, FortranCompiler): def __init__(self, exelist, version, is_cross, exe_wrapper=None, **kwags): FortranCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwags) PGICompiler.__init__(self, CompilerType.PGI_STANDARD) @@ -383,7 +383,7 @@ class PGIFortranCompiler(FortranCompiler): return val -class FlangFortranCompiler(FortranCompiler): +class FlangFortranCompiler(FlangCompiler, FortranCompiler): def __init__(self, exelist, version, is_cross, exe_wrapper=None, **kwags): FortranCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwags) FlangCompiler.__init__(self, CompilerType.FLANG_STANDARD) From 9bb21be59bd66ef907cfed5a31269de6f2448a2a Mon Sep 17 00:00:00 2001 From: "Michael Hirsch, Ph.D" Date: Wed, 16 Jan 2019 14:15:36 -0500 Subject: [PATCH 3/4] FlangFortranCompiler inherit ClangCompiler --- mesonbuild/compilers/compilers.py | 25 ------------------------- mesonbuild/compilers/fortran.py | 11 ++++++++--- 2 files changed, 8 insertions(+), 28 deletions(-) diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index a6585543d..758b1c3ab 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -1311,8 +1311,6 @@ class CompilerType(enum.Enum): PGI_STANDARD = 50 - FLANG_STANDARD = 60 - @property def is_standard_compiler(self): return self.name in ('GCC_STANDARD', 'CLANG_STANDARD', 'ICC_STANDARD') @@ -1625,29 +1623,6 @@ class PGICompiler: return [] -class FlangCompiler: - def __init__(self, compiler_type): - self.id = 'flang' - self.compiler_type = compiler_type - - default_warn_args = ['-Minform=inform'] - self.warn_args = {'1': default_warn_args, - '2': default_warn_args, - '3': default_warn_args} - - def get_module_incdir_args(self): - return ('-module', ) - - def get_no_warn_args(self): - return ['-silent'] - - def openmp_flags(self): - return ['-mp'] - - def get_allow_undefined_link_args(self): - return [] - - class ElbrusCompiler(GnuCompiler): # Elbrus compiler is nearly like GCC, but does not support # PCH, LTO, sanitizers and color output as of version 1.21.x. diff --git a/mesonbuild/compilers/fortran.py b/mesonbuild/compilers/fortran.py index 3387ddaa2..57d1dd900 100644 --- a/mesonbuild/compilers/fortran.py +++ b/mesonbuild/compilers/fortran.py @@ -22,7 +22,7 @@ from .compilers import ( clike_debug_args, Compiler, GnuCompiler, - FlangCompiler, + ClangCompiler, ElbrusCompiler, IntelCompiler, PGICompiler @@ -383,10 +383,15 @@ class PGIFortranCompiler(PGICompiler, FortranCompiler): return val -class FlangFortranCompiler(FlangCompiler, FortranCompiler): +class FlangFortranCompiler(ClangCompiler, FortranCompiler): def __init__(self, exelist, version, is_cross, exe_wrapper=None, **kwags): FortranCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwags) - FlangCompiler.__init__(self, CompilerType.FLANG_STANDARD) + ClangCompiler.__init__(self, CompilerType.CLANG_STANDARD) + self.id = 'flang' + default_warn_args = ['-Minform=inform'] + self.warn_args = {'1': default_warn_args, + '2': default_warn_args, + '3': default_warn_args} class Open64FortranCompiler(FortranCompiler): From 5c00751515ac36ac6edbd7e8890f221f791feafb Mon Sep 17 00:00:00 2001 From: "Michael Hirsch, Ph.D" Date: Thu, 17 Jan 2019 15:12:02 -0500 Subject: [PATCH 4/4] doc --- docs/markdown/snippets/flang_fortran_compiler.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 docs/markdown/snippets/flang_fortran_compiler.md diff --git a/docs/markdown/snippets/flang_fortran_compiler.md b/docs/markdown/snippets/flang_fortran_compiler.md new file mode 100644 index 000000000..d34d6cb94 --- /dev/null +++ b/docs/markdown/snippets/flang_fortran_compiler.md @@ -0,0 +1,3 @@ +## added the Flang compiler +[Flang](https://github.com/flang-compiler/flang/releases) Fortran compiler support was added. +As with other Fortran compilers, flang is specified using `FC=flang meson ..` or similar.