public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH] toolchain-funcs.eclass: Add tc-check-openmp() function
@ 2016-10-13 20:35 David Seifert
  2016-10-13 20:40 ` Michael Orlitzky
  0 siblings, 1 reply; 4+ messages in thread
From: David Seifert @ 2016-10-13 20:35 UTC (permalink / raw
  To: gentoo-dev

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 <soap@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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-10-22  9:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-13 20:35 [gentoo-dev] [PATCH] toolchain-funcs.eclass: Add tc-check-openmp() function David Seifert
2016-10-13 20:40 ` Michael Orlitzky
2016-10-13 21:32   ` M. J. Everitt
2016-10-22  9:30   ` David Seifert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox