fix openmp dependency for clang-cl

- see https://github.com/mesonbuild/meson/issues/5298
pull/12750/head
Peter Urban 11 months ago committed by Eli Schwartz
parent 95cc34b342
commit bd3f1b2e0e
  1. 14
      mesonbuild/dependencies/misc.py
  2. 4
      test cases/common/184 openmp/meson.build

@ -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.')

@ -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.')

Loading…
Cancel
Save