1 |
commit: dc1e8d7b9ad8f7253fa14e068547b63b14c829b7 |
2 |
Author: Oskari Pirhonen <xxc3ncoredxx <AT> gmail <DOT> com> |
3 |
AuthorDate: Wed Feb 1 04:32:20 2023 +0000 |
4 |
Commit: Sam James <sam <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Feb 26 20:22:42 2023 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=dc1e8d7b |
7 |
|
8 |
install-qa-check.d/90config-impl-decl: check config log for warnings |
9 |
|
10 |
Check for -Wimplicit-function-declaration in: |
11 |
|
12 |
- config.log |
13 |
- CMakeError.log |
14 |
- meson-log.txt |
15 |
|
16 |
and log the config log, line number, and function name on-screen and in |
17 |
qa.log under the tag 'config.log-impl-decl'. In ebuilds, use the |
18 |
`QA_CONFIG_IMPL_DECL_SKIP` array to skip false positives. |
19 |
|
20 |
Closes: https://bugs.gentoo.org/892651 |
21 |
Signed-off-by: Oskari Pirhonen <xxc3ncoredxx <AT> gmail.com> |
22 |
Signed-off-by: Sam James <sam <AT> gentoo.org> |
23 |
|
24 |
bin/install-qa-check.d/90config-impl-decl | 87 +++++++++++++++++++++++++++++++ |
25 |
1 file changed, 87 insertions(+) |
26 |
|
27 |
diff --git a/bin/install-qa-check.d/90config-impl-decl b/bin/install-qa-check.d/90config-impl-decl |
28 |
new file mode 100644 |
29 |
index 000000000..2fb8307ea |
30 |
--- /dev/null |
31 |
+++ b/bin/install-qa-check.d/90config-impl-decl |
32 |
@@ -0,0 +1,87 @@ |
33 |
+# Check for implicit function declaration warnings in configure logs |
34 |
+# |
35 |
+# ebuilds should set the QA_CONFIG_IMPL_DECL_SKIP array to skip known false |
36 |
+# positives. |
37 |
+# |
38 |
+# Some examples of logs to look for: |
39 |
+# bash: work/bash-5.1/config.log |
40 |
+# ^--- easy |
41 |
+# python: work/Python-3.10.9/config.log |
42 |
+# ^--- easy |
43 |
+# gcc: work/build/config.log |
44 |
+# ^--- can be out-of-tree |
45 |
+# clang: work/x/y/clang-abi_x86_64.amd64/CMakeFiles/CMakeError.log |
46 |
+# ^--- can be non-autotools (and very deep) |
47 |
+# systemd-utils: work/systemd-stable-251.10-abi_x86_64.amd64/meson-logs/meson-log.txt |
48 |
+# ^--- can be non-autotools |
49 |
+# |
50 |
+# Adapted from macports portconfigure.tcl with love. |
51 |
+# |
52 |
+# See also: bug 892651 |
53 |
+ |
54 |
+find_log_targets() { |
55 |
+ local log_targets=( |
56 |
+ 'config.log' |
57 |
+ 'CMakeError.log' |
58 |
+ 'meson-log.txt' |
59 |
+ ) |
60 |
+ local find_args=() |
61 |
+ local log |
62 |
+ |
63 |
+ # Find config logs. Assume the dirs can have spaces in them, even though |
64 |
+ # that is hella evil and goes against good filesystem manners! |
65 |
+ for log in "${log_targets[@]}"; do |
66 |
+ find_args+=( '-name' "${log}" '-o' ) |
67 |
+ done |
68 |
+ unset -v 'find_args[-1]' |
69 |
+ printf '%s\0' "${WORKDIR}" | |
70 |
+ find -files0-from - -type f \( "${find_args[@]}" \) -print0 |
71 |
+} |
72 |
+ |
73 |
+config_impl_decl_check() { |
74 |
+ local files=() |
75 |
+ local lines=() |
76 |
+ local funcs=() |
77 |
+ local l |
78 |
+ local entry |
79 |
+ local line |
80 |
+ local func |
81 |
+ local re=" function '([[:print:]]+)'" |
82 |
+ |
83 |
+ # Iterate over every log file found and check for '-Wimplicit-function-declaration' |
84 |
+ while IFS= read -rd '' l; do |
85 |
+ while IFS= read -ru3 entry; do |
86 |
+ # Strip ANSI codes (color and erase in line have been seen at least) |
87 |
+ entry="$(printf '%s\n' "${entry}" | sed -E -e $'s/\033\[[0-9;]*[A-Za-z]//g')" |
88 |
+ |
89 |
+ line="${entry%%:*}" |
90 |
+ # This conditional should always be true unless compiler warnings |
91 |
+ # get drastically changed |
92 |
+ if [[ ${entry} =~ ${re} ]]; then |
93 |
+ func="${BASH_REMATCH[1]}" |
94 |
+ fi |
95 |
+ |
96 |
+ has "${func}" "${QA_CONFIG_IMPL_DECL_SKIP[@]}" && continue |
97 |
+ |
98 |
+ files+=( "${l}" ) |
99 |
+ lines+=( "${line}" ) |
100 |
+ funcs+=( "${func}" ) |
101 |
+ # Using -I to ignore binary files is a GNU extension for grep |
102 |
+ done 3< <(grep -nEI -e '-Wimplicit-function-declaration' "${l}") |
103 |
+ done < <(find_log_targets) |
104 |
+ |
105 |
+ # Drop out early if no impl decls found (all the arrays are the same size) |
106 |
+ [[ ${#files[@]} -eq 0 ]] && return |
107 |
+ |
108 |
+ eqawarn 'Found the following implicit function declarations in configure logs:' |
109 |
+ for l in "${!files[@]}"; do |
110 |
+ eqawarn " ${files[l]}:${lines[l]} - ${funcs[l]}" |
111 |
+ eqatag 'config.log-impl-decl' "line=${lines[l]}" "func=${funcs[l]}" "${files[l]}" |
112 |
+ done |
113 |
+ eqawarn 'Check that no features were accidentally disabled.' |
114 |
+} |
115 |
+ |
116 |
+config_impl_decl_check |
117 |
+: # guarantee successful exit |
118 |
+ |
119 |
+# vim:ft=sh noexpandtab: |