compilers: pass Environment to openmp_flags

This will be needed by the Apple compiler
pull/13356/head
Dylan Baker 7 months ago committed by Eli Schwartz
parent dbfd3e8c41
commit 87681980bc
  1. 8
      mesonbuild/compilers/compilers.py
  2. 8
      mesonbuild/compilers/fortran.py
  3. 2
      mesonbuild/compilers/mixins/clang.py
  4. 4
      mesonbuild/compilers/mixins/elbrus.py
  5. 4
      mesonbuild/compilers/mixins/gnu.py
  6. 7
      mesonbuild/compilers/mixins/intel.py
  7. 2
      mesonbuild/compilers/mixins/pgi.py
  8. 4
      mesonbuild/compilers/mixins/visualstudio.py
  9. 10
      mesonbuild/dependencies/misc.py
  10. 2
      mesonbuild/linkers/linkers.py

@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2012-2022 The Meson development team
# Copyright © 2023 Intel Corporation
# Copyright © 2023-2024 Intel Corporation
from __future__ import annotations
@ -936,11 +936,11 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta):
def thread_link_flags(self, env: 'Environment') -> T.List[str]:
return self.linker.thread_flags(env)
def openmp_flags(self) -> T.List[str]:
def openmp_flags(self, env: Environment) -> T.List[str]:
raise EnvironmentException('Language %s does not support OpenMP flags.' % self.get_display_language())
def openmp_link_flags(self) -> T.List[str]:
return self.openmp_flags()
def openmp_link_flags(self, env: Environment) -> T.List[str]:
return self.openmp_flags(env)
def language_stdlib_only_link_flags(self, env: 'Environment') -> T.List[str]:
return []

@ -256,7 +256,7 @@ class SunFortranCompiler(FortranCompiler):
def get_module_outdir_args(self, path: str) -> T.List[str]:
return ['-moddir=' + path]
def openmp_flags(self) -> T.List[str]:
def openmp_flags(self, env: Environment) -> T.List[str]:
return ['-xopenmp']
@ -381,7 +381,7 @@ class PathScaleFortranCompiler(FortranCompiler):
'3': default_warn_args,
'everything': default_warn_args}
def openmp_flags(self) -> T.List[str]:
def openmp_flags(self, env: Environment) -> T.List[str]:
return ['-mp']
@ -482,7 +482,7 @@ class Open64FortranCompiler(FortranCompiler):
'3': default_warn_args,
'everything': default_warn_args}
def openmp_flags(self) -> T.List[str]:
def openmp_flags(self, env: Environment) -> T.List[str]:
return ['-mp']
@ -525,5 +525,5 @@ class NAGFortranCompiler(FortranCompiler):
def get_std_exe_link_args(self) -> T.List[str]:
return self.get_always_args()
def openmp_flags(self) -> T.List[str]:
def openmp_flags(self, env: Environment) -> T.List[str]:
return ['-openmp']

@ -123,7 +123,7 @@ class ClangCompiler(GnuLikeCompiler):
return super().has_function(funcname, prefix, env, extra_args=extra_args,
dependencies=dependencies)
def openmp_flags(self) -> T.List[str]:
def openmp_flags(self, env: Environment) -> T.List[str]:
if mesonlib.version_compare(self.version, '>=3.8.0'):
return ['-fopenmp']
elif mesonlib.version_compare(self.version, '>=3.7.0'):

@ -1,5 +1,5 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright © 2023 Intel Corporation
# Copyright © 2023-2024 Intel Corporation
from __future__ import annotations
@ -89,5 +89,5 @@ class ElbrusCompiler(GnuLikeCompiler):
args.append('-std=' + std)
return args
def openmp_flags(self) -> T.List[str]:
def openmp_flags(self, env: Environment) -> T.List[str]:
return ['-fopenmp']

@ -402,7 +402,7 @@ class GnuLikeCompiler(Compiler, metaclass=abc.ABCMeta):
return gnulike_default_include_dirs(tuple(self.get_exelist(ccache=False)), self.language).copy()
@abc.abstractmethod
def openmp_flags(self) -> T.List[str]:
def openmp_flags(self, env: Environment) -> T.List[str]:
pass
def gnu_symbol_visibility_args(self, vistype: str) -> T.List[str]:
@ -585,7 +585,7 @@ class GnuCompiler(GnuLikeCompiler):
def get_pch_suffix(self) -> str:
return 'gch'
def openmp_flags(self) -> T.List[str]:
def openmp_flags(self, env: Environment) -> T.List[str]:
return ['-fopenmp']
def has_arguments(self, args: T.List[str], env: 'Environment', code: str,

@ -19,6 +19,9 @@ from ..compilers import CompileCheckMode
from .gnu import GnuLikeCompiler
from .visualstudio import VisualStudioLikeCompiler
if T.TYPE_CHECKING:
from ...environment import Environment
# XXX: avoid circular dependencies
# TODO: this belongs in a posix compiler class
# NOTE: the default Intel optimization is -O2, unlike GNU which defaults to -O0.
@ -78,7 +81,7 @@ class IntelGnuLikeCompiler(GnuLikeCompiler):
def get_pch_name(self, name: str) -> str:
return os.path.basename(name) + '.' + self.get_pch_suffix()
def openmp_flags(self) -> T.List[str]:
def openmp_flags(self, env: Environment) -> T.List[str]:
if mesonlib.version_compare(self.version, '>=15.0.0'):
return ['-qopenmp']
else:
@ -154,7 +157,7 @@ class IntelVisualStudioLikeCompiler(VisualStudioLikeCompiler):
version = int(v1 + v2)
return self._calculate_toolset_version(version)
def openmp_flags(self) -> T.List[str]:
def openmp_flags(self, env: Environment) -> T.List[str]:
return ['/Qopenmp']
def get_debug_args(self, is_debug: bool) -> T.List[str]:

@ -51,7 +51,7 @@ class PGICompiler(Compiler):
return ['-fPIC']
return []
def openmp_flags(self) -> T.List[str]:
def openmp_flags(self, env: Environment) -> T.List[str]:
return ['-mp']
def get_optimization_args(self, optimization_level: str) -> T.List[str]:

@ -204,10 +204,10 @@ class VisualStudioLikeCompiler(Compiler, metaclass=abc.ABCMeta):
objname = os.path.splitext(source)[0] + '.obj'
return objname, ['/Yc' + header, '/Fp' + pchname, '/Fo' + objname]
def openmp_flags(self) -> T.List[str]:
def openmp_flags(self, env: Environment) -> T.List[str]:
return ['/openmp']
def openmp_link_flags(self) -> T.List[str]:
def openmp_link_flags(self, env: Environment) -> T.List[str]:
return []
# FIXME, no idea what these should be.

@ -95,18 +95,18 @@ class OpenMPDependency(SystemDependency):
# No macro defined for OpenMP, but OpenMP 3.1 is supported.
self.version = '3.1'
self.is_found = True
self.compile_args = self.link_args = self.clib_compiler.openmp_flags()
self.compile_args = self.link_args = self.clib_compiler.openmp_flags(environment)
return
if self.clib_compiler.get_id() == 'pgi':
# through at least PGI 19.4, there is no macro defined for OpenMP, but OpenMP 3.1 is supported.
self.version = '3.1'
self.is_found = True
self.compile_args = self.link_args = self.clib_compiler.openmp_flags()
self.compile_args = self.link_args = self.clib_compiler.openmp_flags(environment)
return
try:
openmp_date = self.clib_compiler.get_define(
'_OPENMP', '', self.env, self.clib_compiler.openmp_flags(), [self], disable_cache=True)[0]
'_OPENMP', '', self.env, self.clib_compiler.openmp_flags(environment), [self], disable_cache=True)[0]
except mesonlib.EnvironmentException as e:
mlog.debug('OpenMP support not available in the compiler')
mlog.debug(e)
@ -134,8 +134,8 @@ class OpenMPDependency(SystemDependency):
for name in header_names:
if self.clib_compiler.has_header(name, '', self.env, dependencies=[self], disable_cache=True)[0]:
self.is_found = True
self.compile_args.extend(self.clib_compiler.openmp_flags())
self.link_args.extend(self.clib_compiler.openmp_link_flags())
self.compile_args.extend(self.clib_compiler.openmp_flags(environment))
self.link_args.extend(self.clib_compiler.openmp_link_flags(environment))
break
if not self.is_found:
mlog.log(mlog.yellow('WARNING:'), 'OpenMP found but omp.h missing.')

@ -62,7 +62,7 @@ class StaticLinker:
def thread_link_flags(self, env: 'Environment') -> T.List[str]:
return []
def openmp_flags(self) -> T.List[str]:
def openmp_flags(self, env: Environment) -> T.List[str]:
return []
def get_option_link_args(self, options: 'KeyedOptionDictType') -> T.List[str]:

Loading…
Cancel
Save