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

* Re: [gentoo-dev] [PATCH] toolchain-funcs.eclass: Add tc-check-openmp() function
  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
  0 siblings, 2 replies; 4+ messages in thread
From: Michael Orlitzky @ 2016-10-13 20:40 UTC (permalink / raw
  To: gentoo-dev

On 10/13/2016 04:35 PM, David Seifert wrote:
> +		ewarn "Your current compiler does not support OpenMP"
> +
> +		...
> +
> +		die "Active compiler does not have required support

Hey, a message that isn't about comrel. Since you're going to die(),
isn't eerror more accurate than ewarn?




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

* Re: [gentoo-dev] [PATCH] toolchain-funcs.eclass: Add tc-check-openmp() function
  2016-10-13 20:40 ` Michael Orlitzky
@ 2016-10-13 21:32   ` M. J. Everitt
  2016-10-22  9:30   ` David Seifert
  1 sibling, 0 replies; 4+ messages in thread
From: M. J. Everitt @ 2016-10-13 21:32 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 456 bytes --]

On 13/10/16 21:40, Michael Orlitzky wrote:
> On 10/13/2016 04:35 PM, David Seifert wrote:
>> +		ewarn "Your current compiler does not support OpenMP"
>> +
>> +		...
>> +
>> +		die "Active compiler does not have required support
> Hey, a message that isn't about comrel. Since you're going to die(),
> isn't eerror more accurate than ewarn?
>
>
>
You're looking at the wrong ML ... this is -dev not -project ... :P Fix
your mail filters! :P


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 901 bytes --]

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

* Re: [gentoo-dev] [PATCH] toolchain-funcs.eclass: Add tc-check-openmp() function
  2016-10-13 20:40 ` Michael Orlitzky
  2016-10-13 21:32   ` M. J. Everitt
@ 2016-10-22  9:30   ` David Seifert
  1 sibling, 0 replies; 4+ messages in thread
From: David Seifert @ 2016-10-22  9:30 UTC (permalink / raw
  To: gentoo-dev

On Do, 2016-10-13 at 16:40 -0400, Michael Orlitzky wrote:
> On 10/13/2016 04:35 PM, David Seifert wrote:
> > 
> > +		ewarn "Your current compiler does not support
> > OpenMP"
> > +
> > +		...
> > +
> > +		die "Active compiler does not have required
> > support
> 
> Hey, a message that isn't about comrel. Since you're going to die(),
> isn't eerror more accurate than ewarn?
> 
> 
> 

Merged, with ewarn replaced by eerror as requested. Please use this
function in future if you need to assert a working OpenMP toolchain,
and not check for OpenMP yourself and print some self-built error
message (think of the clang users!).


^ permalink raw reply	[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