aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers
diff options
context:
space:
mode:
Diffstat (limited to 'mesonbuild/compilers')
-rw-r--r--mesonbuild/compilers/c.py5
-rw-r--r--mesonbuild/compilers/compilers.py21
-rw-r--r--mesonbuild/compilers/fortran.py19
3 files changed, 45 insertions, 0 deletions
diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py
index a6bd0af..0e474e7 100644
--- a/mesonbuild/compilers/c.py
+++ b/mesonbuild/compilers/c.py
@@ -296,6 +296,8 @@ class CCompiler(Compiler):
args += d.get_compile_args()
if d.need_threads():
args += self.thread_flags(env)
+ elif d.need_openmp():
+ args += self.openmp_flags()
if mode == 'link':
# Add link flags needed to find dependencies
args += d.get_link_args()
@@ -1091,6 +1093,9 @@ class VisualStudioCCompiler(CCompiler):
def build_rpath_args(self, build_dir, from_dir, rpath_paths, build_rpath, install_rpath):
return []
+ def openmp_flags(self):
+ return ['/openmp']
+
# FIXME, no idea what these should be.
def thread_flags(self, env):
return []
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index 99e9164..37326d8 100644
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -937,6 +937,9 @@ class Compiler:
def thread_flags(self, env):
return []
+ def openmp_flags(self):
+ raise EnvironmentException('Language %s does not support OpenMP flags.' % self.get_display_language())
+
GCC_STANDARD = 0
GCC_OSX = 1
@@ -1152,6 +1155,9 @@ class GnuCompiler:
def get_default_include_dirs(self):
return gnulike_default_include_dirs(self.exelist, self.language)
+ def openmp_flags(self):
+ return ['-fopenmp']
+
class ElbrusCompiler(GnuCompiler):
# Elbrus compiler is nearly like GCC, but does not support
@@ -1270,6 +1276,15 @@ class ClangCompiler:
def get_default_include_dirs(self):
return gnulike_default_include_dirs(self.exelist, self.language)
+ def openmp_flags(self):
+ if version_compare(self.version, '>=3.8.0'):
+ return ['-fopenmp']
+ elif version_compare(self.version, '>=3.7.0'):
+ return ['-fopenmp=libomp']
+ else:
+ # Shouldn't work, but it'll be checked explicitly in the OpenMP dependency.
+ return []
+
# Tested on linux for ICC 14.0.3, 15.0.6, 16.0.4, 17.0.1
class IntelCompiler:
@@ -1332,6 +1347,12 @@ class IntelCompiler:
def get_default_include_dirs(self):
return gnulike_default_include_dirs(self.exelist, self.language)
+ def openmp_flags(self):
+ if version_compare(self.version, '>=15.0.0'):
+ return ['-qopenmp']
+ else:
+ return ['-openmp']
+
class ArmCompiler:
# Functionality that is common to all ARM family compilers.
diff --git a/mesonbuild/compilers/fortran.py b/mesonbuild/compilers/fortran.py
index 5bb3ec9..9d3240f 100644
--- a/mesonbuild/compilers/fortran.py
+++ b/mesonbuild/compilers/fortran.py
@@ -180,6 +180,9 @@ class GnuFortranCompiler(FortranCompiler):
"""
return ['-Wl,--out-implib=' + implibname]
+ def openmp_flags(self):
+ return ['-fopenmp']
+
class ElbrusFortranCompiler(GnuFortranCompiler, ElbrusCompiler):
def __init__(self, exelist, version, gcc_type, is_cross, exe_wrapper=None, defines=None, **kwargs):
@@ -231,6 +234,9 @@ class SunFortranCompiler(FortranCompiler):
def get_module_outdir_args(self, path):
return ['-moddir=' + path]
+ def openmp_flags(self):
+ return ['-xopenmp']
+
class IntelFortranCompiler(IntelCompiler, FortranCompiler):
std_warn_args = ['-warn', 'all']
@@ -263,6 +269,10 @@ class PathScaleFortranCompiler(FortranCompiler):
def get_std_warn_args(self, level):
return PathScaleFortranCompiler.std_warn_args
+ def openmp_flags(self):
+ return ['-mp']
+
+
class PGIFortranCompiler(FortranCompiler):
std_warn_args = ['-Minform=inform']
@@ -282,6 +292,9 @@ class PGIFortranCompiler(FortranCompiler):
def get_no_warn_args(self):
return ['-silent']
+ def openmp_flags(self):
+ return ['-fopenmp']
+
class Open64FortranCompiler(FortranCompiler):
std_warn_args = ['-fullwarn']
@@ -296,6 +309,9 @@ class Open64FortranCompiler(FortranCompiler):
def get_warn_args(self, level):
return Open64FortranCompiler.std_warn_args
+ def openmp_flags(self):
+ return ['-mp']
+
class NAGFortranCompiler(FortranCompiler):
std_warn_args = []
@@ -309,3 +325,6 @@ class NAGFortranCompiler(FortranCompiler):
def get_warn_args(self, level):
return NAGFortranCompiler.std_warn_args
+
+ def openmp_flags(self):
+ return ['-openmp']