1 |
Hey all, |
2 |
I'd like to add a new function to toolchain-funcs, which presents a |
3 |
consist interface to users of packages somehow relying on OpenMP. |
4 |
Currently, (most) ebuilds relying on OpenMP test with tc-has-openmp and |
5 |
if OpenMP is not available, do something, like print a message and die, |
6 |
just print a warning, or change some flags implicitly without warning. |
7 |
This new function, tc-check-openmp, checks for OpenMP, dies if it is |
8 |
non-functional, and tells the user how to rectify the situation. This |
9 |
is better than all the current solutions, which, for instance, do not |
10 |
take CC=clang into account. It also makes extending the messages easier |
11 |
for new compilers. In most cases, this should obviate the direct use of |
12 |
tc-has-openmp. |
13 |
|
14 |
|
15 |
From eaab3e443da8ee1970679b3d4016f12541d84344 Mon Sep 17 00:00:00 2001 |
16 |
From: David Seifert <soap@g.o> |
17 |
Date: Wed, 12 Oct 2016 22:15:03 +0200 |
18 |
Subject: [PATCH] toolchain-funcs.eclass: Add tc-check-openmp() function |
19 |
|
20 |
--- |
21 |
eclass/toolchain-funcs.eclass | 19 +++++++++++++++++++ |
22 |
1 file changed, 19 insertions(+) |
23 |
|
24 |
diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain- |
25 |
funcs.eclass |
26 |
index 5bac36b..d8a28af 100644 |
27 |
--- a/eclass/toolchain-funcs.eclass |
28 |
+++ b/eclass/toolchain-funcs.eclass |
29 |
@@ -421,6 +421,25 @@ tc-has-openmp() { |
30 |
return ${ret} |
31 |
} |
32 |
|
33 |
+# @FUNCTION: tc-check-openmp |
34 |
+# @DESCRIPTION: |
35 |
+# Test for OpenMP support with the current compiler and error out with |
36 |
+# a clear error message, telling the user how to rectify the missing |
37 |
+# OpenMP support that has been requested by the ebuild. |
38 |
+tc-check-openmp() { |
39 |
+ if ! tc-has-openmp; then |
40 |
+ ewarn "Your current compiler does not support OpenMP" |
41 |
+ |
42 |
+ if tc-is-gcc; then |
43 |
+ ewarn "Enable OpenMP support by building sys- |
44 |
devel/gcc with USE=\"openmp\"." |
45 |
+ elif tc-is-clang; then |
46 |
+ ewarn "OpenMP support in sys-devel/clang is |
47 |
provided by sys-libs/libomp." |
48 |
+ fi |
49 |
+ |
50 |
+ die "Active compiler does not have required support |
51 |
for OpenMP" |
52 |
+ fi |
53 |
+} |
54 |
+ |
55 |
# @FUNCTION: tc-has-tls |
56 |
# @USAGE: [-s|-c|-l] [toolchain prefix] |
57 |
# @DESCRIPTION: |
58 |
-- |
59 |
2.10.1 |