Skip to content

Commit

Permalink
openmp: add a warning for non-native linking
Browse files Browse the repository at this point in the history
  • Loading branch information
valgur committed Jul 9, 2024
1 parent 7bcb49d commit 8719eef
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion recipes/openmp/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,19 @@ def package_id(self):
self.info.clear()

def validate(self):
if self._openmp_flags() is None:
if self.options.provider == "native" and self._openmp_flags() is None:
raise ConanInvalidConfiguration(
f"{self.settings.compiler} is not supported by this recipe. Contributions are welcome!"
)

if self.options.provider == "llvm":
if self.settings.compiler not in ["clang", "apple-clang"] and not is_msvc(self):
# More info: https://cpufun.substack.com/p/is-mixing-openmp-runtimes-safe
self.output.warning(
"Warning: Using a non-native OpenMP implementation can be bug-prone. "
"Make sure you avoid accidental linking against the native implementation through external libraries."
)

def _openmp_flags(self):
# Based on https://github.com/Kitware/CMake/blob/v3.28.1/Modules/FindOpenMP.cmake#L104-L135
if self.settings.compiler == "clang":
Expand Down

0 comments on commit 8719eef

Please sign in to comment.