aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOskari Pirhonen <xxc3ncoredxx@gmail.com>2023-01-31 22:32:20 -0600
committerSam James <sam@gentoo.org>2023-02-26 20:22:42 +0000
commitdc1e8d7b9ad8f7253fa14e068547b63b14c829b7 (patch)
tree149ede2dc793e8ce7ea9868115d5a95d67ef15dc
parentNEWS: update (diff)
downloadportage-dc1e8d7b.tar.gz
portage-dc1e8d7b.tar.bz2
portage-dc1e8d7b.zip
install-qa-check.d/90config-impl-decl: check config log for warnings
Check for -Wimplicit-function-declaration in: - config.log - CMakeError.log - meson-log.txt and log the config log, line number, and function name on-screen and in qa.log under the tag 'config.log-impl-decl'. In ebuilds, use the `QA_CONFIG_IMPL_DECL_SKIP` array to skip false positives. Closes: https://bugs.gentoo.org/892651 Signed-off-by: Oskari Pirhonen <xxc3ncoredxx@gmail.com> Signed-off-by: Sam James <sam@gentoo.org>
-rw-r--r--bin/install-qa-check.d/90config-impl-decl87
1 files changed, 87 insertions, 0 deletions
diff --git a/bin/install-qa-check.d/90config-impl-decl b/bin/install-qa-check.d/90config-impl-decl
new file mode 100644
index 000000000..2fb8307ea
--- /dev/null
+++ b/bin/install-qa-check.d/90config-impl-decl
@@ -0,0 +1,87 @@
+# Check for implicit function declaration warnings in configure logs
+#
+# ebuilds should set the QA_CONFIG_IMPL_DECL_SKIP array to skip known false
+# positives.
+#
+# Some examples of logs to look for:
+# bash: work/bash-5.1/config.log
+# ^--- easy
+# python: work/Python-3.10.9/config.log
+# ^--- easy
+# gcc: work/build/config.log
+# ^--- can be out-of-tree
+# clang: work/x/y/clang-abi_x86_64.amd64/CMakeFiles/CMakeError.log
+# ^--- can be non-autotools (and very deep)
+# systemd-utils: work/systemd-stable-251.10-abi_x86_64.amd64/meson-logs/meson-log.txt
+# ^--- can be non-autotools
+#
+# Adapted from macports portconfigure.tcl with love.
+#
+# See also: bug 892651
+
+find_log_targets() {
+ local log_targets=(
+ 'config.log'
+ 'CMakeError.log'
+ 'meson-log.txt'
+ )
+ local find_args=()
+ local log
+
+ # Find config logs. Assume the dirs can have spaces in them, even though
+ # that is hella evil and goes against good filesystem manners!
+ for log in "${log_targets[@]}"; do
+ find_args+=( '-name' "${log}" '-o' )
+ done
+ unset -v 'find_args[-1]'
+ printf '%s\0' "${WORKDIR}" |
+ find -files0-from - -type f \( "${find_args[@]}" \) -print0
+}
+
+config_impl_decl_check() {
+ local files=()
+ local lines=()
+ local funcs=()
+ local l
+ local entry
+ local line
+ local func
+ local re=" function '([[:print:]]+)'"
+
+ # Iterate over every log file found and check for '-Wimplicit-function-declaration'
+ while IFS= read -rd '' l; do
+ while IFS= read -ru3 entry; do
+ # Strip ANSI codes (color and erase in line have been seen at least)
+ entry="$(printf '%s\n' "${entry}" | sed -E -e $'s/\033\[[0-9;]*[A-Za-z]//g')"
+
+ line="${entry%%:*}"
+ # This conditional should always be true unless compiler warnings
+ # get drastically changed
+ if [[ ${entry} =~ ${re} ]]; then
+ func="${BASH_REMATCH[1]}"
+ fi
+
+ has "${func}" "${QA_CONFIG_IMPL_DECL_SKIP[@]}" && continue
+
+ files+=( "${l}" )
+ lines+=( "${line}" )
+ funcs+=( "${func}" )
+ # Using -I to ignore binary files is a GNU extension for grep
+ done 3< <(grep -nEI -e '-Wimplicit-function-declaration' "${l}")
+ done < <(find_log_targets)
+
+ # Drop out early if no impl decls found (all the arrays are the same size)
+ [[ ${#files[@]} -eq 0 ]] && return
+
+ eqawarn 'Found the following implicit function declarations in configure logs:'
+ for l in "${!files[@]}"; do
+ eqawarn " ${files[l]}:${lines[l]} - ${funcs[l]}"
+ eqatag 'config.log-impl-decl' "line=${lines[l]}" "func=${funcs[l]}" "${files[l]}"
+ done
+ eqawarn 'Check that no features were accidentally disabled.'
+}
+
+config_impl_decl_check
+: # guarantee successful exit
+
+# vim:ft=sh noexpandtab: