diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2024-04-25 15:43:21 -0700 |
---|---|---|
committer | Eli Schwartz <eschwartz93@gmail.com> | 2024-06-26 16:15:47 -0400 |
commit | f900b3270be6572a2f2aeb6c080eae37187a7459 (patch) | |
tree | aa550dbb68ebea36cf8af976240d4649732e4d75 | |
parent | 3cd2cee7756b462a4d5fb72373ebc7e4ced71e4f (diff) | |
download | meson-f900b3270be6572a2f2aeb6c080eae37187a7459.zip meson-f900b3270be6572a2f2aeb6c080eae37187a7459.tar.gz meson-f900b3270be6572a2f2aeb6c080eae37187a7459.tar.bz2 |
compilers|dependencies: Move Clang-CL specific logic out of OpenMP dep
And into the Clang-CL mixin.
-rw-r--r-- | mesonbuild/compilers/mixins/visualstudio.py | 7 | ||||
-rw-r--r-- | mesonbuild/dependencies/misc.py | 16 |
2 files changed, 13 insertions, 10 deletions
diff --git a/mesonbuild/compilers/mixins/visualstudio.py b/mesonbuild/compilers/mixins/visualstudio.py index abcedc7..907ea07 100644 --- a/mesonbuild/compilers/mixins/visualstudio.py +++ b/mesonbuild/compilers/mixins/visualstudio.py @@ -483,3 +483,10 @@ class ClangClCompiler(VisualStudioLikeCompiler): return converted else: return dep.get_compile_args() + + def openmp_link_flags(self, env: Environment) -> T.List[str]: + # see https://github.com/mesonbuild/meson/issues/5298 + libs = self.find_library('libomp', env, []) + if libs is None: + raise mesonlib.MesonBugException('Could not find libomp') + return super().openmp_link_flags(env) + libs diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py index f9a2e04..ffccd70 100644 --- a/mesonbuild/dependencies/misc.py +++ b/mesonbuild/dependencies/misc.py @@ -105,8 +105,12 @@ class OpenMPDependency(SystemDependency): return # Set these now so they're available for the following compiler checks - self.compile_args.extend(self.clib_compiler.openmp_flags(environment)) - self.link_args.extend(self.clib_compiler.openmp_link_flags(environment)) + try: + self.compile_args.extend(self.clib_compiler.openmp_flags(environment)) + self.link_args.extend(self.clib_compiler.openmp_link_flags(environment)) + except mesonlib.MesonException as e: + mlog.warning('OpenMP support not available because:', str(e), fatal=False) + return try: openmp_date = self.clib_compiler.get_define( @@ -125,14 +129,6 @@ class OpenMPDependency(SystemDependency): mlog.debug('This can be caused by flags such as gcc\'s `-fdirectives-only`, which affect preprocessor behavior.') return - if self.clib_compiler.get_id() == 'clang-cl': - # this is necessary for clang-cl, see https://github.com/mesonbuild/meson/issues/5298 - clangcl_openmp_link_args = self.clib_compiler.find_library("libomp", self.env, []) - if not clangcl_openmp_link_args: - mlog.log(mlog.yellow('WARNING:'), 'OpenMP found but libomp for clang-cl missing.') - return - self.link_args.extend(clangcl_openmp_link_args) - # Flang has omp_lib.h header_names = ('omp.h', 'omp_lib.h') for name in header_names: |