Hey all, I'd like to add a new function to toolchain-funcs, which presents a consist interface to users of packages somehow relying on OpenMP. Currently, (most) ebuilds relying on OpenMP test with tc-has-openmp and if OpenMP is not available, do something, like print a message and die, just print a warning, or change some flags implicitly without warning. This new function, tc-check-openmp, checks for OpenMP, dies if it is non-functional, and tells the user how to rectify the situation. This is better than all the current solutions, which, for instance, do not take CC=clang into account. It also makes extending the messages easier for new compilers. In most cases, this should obviate the direct use of tc-has-openmp.
>From eaab3e443da8ee1970679b3d4016f12541d84344 Mon Sep 17 00:00:00 2001 From: David Seifert <s...@gentoo.org> Date: Wed, 12 Oct 2016 22:15:03 +0200 Subject: [PATCH] toolchain-funcs.eclass: Add tc-check-openmp() function --- eclass/toolchain-funcs.eclass | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain- funcs.eclass index 5bac36b..d8a28af 100644 --- a/eclass/toolchain-funcs.eclass +++ b/eclass/toolchain-funcs.eclass @@ -421,6 +421,25 @@ tc-has-openmp() { return ${ret} } +# @FUNCTION: tc-check-openmp +# @DESCRIPTION: +# Test for OpenMP support with the current compiler and error out with +# a clear error message, telling the user how to rectify the missing +# OpenMP support that has been requested by the ebuild. +tc-check-openmp() { + if ! tc-has-openmp; then + ewarn "Your current compiler does not support OpenMP" + + if tc-is-gcc; then + ewarn "Enable OpenMP support by building sys- devel/gcc with USE=\"openmp\"." + elif tc-is-clang; then + ewarn "OpenMP support in sys-devel/clang is provided by sys-libs/libomp." + fi + + die "Active compiler does not have required support for OpenMP" + fi +} + # @FUNCTION: tc-has-tls # @USAGE: [-s|-c|-l] [toolchain prefix] # @DESCRIPTION: -- 2.10.1