summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Urban <peter.urban@ugent.be>2024-01-10 00:32:29 +0100
committerEli Schwartz <eschwartz93@gmail.com>2024-01-17 16:35:27 -0500
commitbd3f1b2e0e70ef16dfa4f441686003212440a09b (patch)
tree4a1114bbf81b00443bcc4c1e6fb8edc78a7bba96
parent95cc34b3420b0ba7ece35408b2b5cb688ac2ffbc (diff)
downloadmeson-bd3f1b2e0e70ef16dfa4f441686003212440a09b.tar.gz
fix openmp dependency for clang-cl
- see https://github.com/mesonbuild/meson/issues/5298
-rw-r--r--mesonbuild/dependencies/misc.py14
-rw-r--r--test cases/common/184 openmp/meson.build4
2 files changed, 14 insertions, 4 deletions
diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py
index bec1466e9..b255813b6 100644
--- a/mesonbuild/dependencies/misc.py
+++ b/mesonbuild/dependencies/misc.py
@@ -103,6 +103,7 @@ class OpenMPDependency(SystemDependency):
self.is_found = True
self.compile_args = self.link_args = self.clib_compiler.openmp_flags()
return
+
try:
openmp_date = self.clib_compiler.get_define(
'_OPENMP', '', self.env, self.clib_compiler.openmp_flags(), [self], disable_cache=True)[0]
@@ -119,13 +120,22 @@ class OpenMPDependency(SystemDependency):
if openmp_date == '_OPENMP':
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:
if self.clib_compiler.has_header(name, '', self.env, dependencies=[self], disable_cache=True)[0]:
self.is_found = True
- self.compile_args = self.clib_compiler.openmp_flags()
- self.link_args = self.clib_compiler.openmp_link_flags()
+ self.compile_args.extend(self.clib_compiler.openmp_flags())
+ self.link_args.extend(self.clib_compiler.openmp_link_flags())
break
if not self.is_found:
mlog.log(mlog.yellow('WARNING:'), 'OpenMP found but omp.h missing.')
diff --git a/test cases/common/184 openmp/meson.build b/test cases/common/184 openmp/meson.build
index a1154c22c..4cbe80616 100644
--- a/test cases/common/184 openmp/meson.build
+++ b/test cases/common/184 openmp/meson.build
@@ -10,8 +10,8 @@ endif
if cc.get_id() == 'msvc' and cc.version().version_compare('<17')
error('MESON_SKIP_TEST msvc is too old to support OpenMP.')
endif
-if cc.get_id() == 'clang-cl'
- error('MESON_SKIP_TEST clang-cl does not support OpenMP.')
+if cc.get_id() == 'clang-cl' and cc.version().version_compare('<10.0.0')
+ error('MESON_SKIP_TEST clang-cl is too old to support OpenMP.')
endif
if cc.get_id() == 'clang' and host_machine.system() == 'windows'
error('MESON_SKIP_TEST Windows clang does not support OpenMP.')