1 |
From: Alexander Miller <alex.miller@×××.de> |
2 |
|
3 |
A number of configure checks used by CMake and autoconf (and probably |
4 |
other build systems) relies on warning-free compiler runs. A combination |
5 |
of compiler and flags that always generates warnings can cause |
6 |
misconfiguration and/or build failures. |
7 |
|
8 |
Since commit ae9870d9f6b1394ede86176443770b36d7e60ac1, flags that |
9 |
generate warnings that could be suppressed with -Qunused-arguments |
10 |
are accepted anyway to avoid stripping all linker flags (#627474). |
11 |
But commit 28d6437fc7009002f98f28e8900e994109927726 added linker |
12 |
invocation for linker flags tests, so the workaround shouldn't be |
13 |
necessary any more. |
14 |
|
15 |
Drop the extra -Qunused-arguments check and reject all flags that |
16 |
generate warnings to avoid configuration issues. |
17 |
|
18 |
If it turns out that stripping these unused flags is still problematic, |
19 |
we could accept them and actually add -Qunused-arguments to the |
20 |
relevant *FLAGS to silence the warnings, but that would require |
21 |
bigger changes, so let's try the simpler and cleaner solution first. |
22 |
|
23 |
Bug: https://bugs.gentoo.org/627474 |
24 |
Bug: https://bugs.gentoo.org/714742 |
25 |
Bug: https://bugs.gentoo.org/862798 |
26 |
Signed-off-by: Alexander Miller <alex.miller@×××.de> |
27 |
Closes: https://github.com/gentoo/gentoo/pull/26773 |
28 |
Signed-off-by: Sam James <sam@g.o> |
29 |
--- |
30 |
eclass/flag-o-matic.eclass | 22 +++++++++++----------- |
31 |
1 file changed, 11 insertions(+), 11 deletions(-) |
32 |
|
33 |
diff --git a/eclass/flag-o-matic.eclass b/eclass/flag-o-matic.eclass |
34 |
index 7319326c7ad8..365741a6dddf 100644 |
35 |
--- a/eclass/flag-o-matic.eclass |
36 |
+++ b/eclass/flag-o-matic.eclass |
37 |
@@ -601,11 +601,20 @@ _test-flag-PROG() { |
38 |
# |
39 |
# We can add more selective detection of no-op flags via |
40 |
# '-Werror=ignored-optimization-argument' and similar error options |
41 |
- # similar to what we are doing with '-Qunused-arguments'. |
42 |
+ # or accept unused flags with '-Qunused-arguments' like we |
43 |
+ # used to for bug #627474. Since we now invoke the linker |
44 |
+ # for testing linker flags, unused argument warnings aren't |
45 |
+ # ignored; linker flags may no longer be accepted in CFLAGS. |
46 |
+ # |
47 |
+ # However, warnings emitted by a compiler for a clean source |
48 |
+ # can break feature detection by CMake or autoconf since |
49 |
+ # many checks use -Werror internally. See e.g. bug #714742. |
50 |
local cmdline=( |
51 |
"${comp[@]}" |
52 |
# Clang will warn about unknown gcc flags but exit 0. |
53 |
# Need -Werror to force it to exit non-zero. |
54 |
+ # |
55 |
+ # See also bug #712488 and bug #714742. |
56 |
-Werror |
57 |
"$@" |
58 |
# -x<lang> options need to go before first source file |
59 |
@@ -614,16 +623,7 @@ _test-flag-PROG() { |
60 |
"${test_in}" -o "${test_out}" |
61 |
) |
62 |
|
63 |
- if ! "${cmdline[@]}" &>/dev/null; then |
64 |
- # -Werror makes clang bail out on unused arguments as well; |
65 |
- # try to add -Qunused-arguments to work-around that |
66 |
- # other compilers don't support it but then, it's failure like |
67 |
- # any other. |
68 |
- # |
69 |
- # See also bug #712488 and bug #714742. |
70 |
- cmdline+=( -Qunused-arguments ) |
71 |
- "${cmdline[@]}" &>/dev/null |
72 |
- fi |
73 |
+ "${cmdline[@]}" &>/dev/null |
74 |
} |
75 |
|
76 |
# @FUNCTION: test-flag-CC |
77 |
-- |
78 |
2.37.2 |