Gentoo Archives: gentoo-commits

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