blob: ae39485425afa3a0dab643f2fa91e25901399c17 [file] [log] [blame]
# Check for important gcc warning
gcc_warn_check() {
local f
# Evaluate misc gcc warnings
if [[ -n ${PORTAGE_LOG_FILE} && -r ${PORTAGE_LOG_FILE} ]] ; then
# In debug mode, this variable definition and corresponding grep calls
# will produce false positives if they're shown in the trace.
local reset_debug=0
if [[ ${-/x/} != $- ]] ; then
set +x
reset_debug=1
fi
local m msgs=(
": warning: dereferencing type-punned pointer will break strict-aliasing rules"
": warning: dereferencing pointer .* does break strict-aliasing rules"
": warning: implicit declaration of function"
": warning: incompatible implicit declaration of built-in function"
": warning: is used uninitialized in this function" # we'll ignore "may" and "might"
": warning: comparisons like X<=Y<=Z do not have their mathematical meaning"
": warning: null argument where non-null required"
": warning: array subscript is below array bounds"
": warning: array subscript is above array bounds"
": warning: attempt to free a non-heap object"
": warning: .* called with .*bigger.* than .* destination buffer"
": warning: call to .* will always overflow destination buffer"
": warning: assuming pointer wraparound does not occur when comparing"
": warning: hex escape sequence out of range"
": warning: [^ ]*-hand operand of comma .*has no effect"
": warning: converting to non-pointer type .* from NULL"
": warning: NULL used in arithmetic"
": warning: passing NULL to non-pointer argument"
": warning: the address of [^ ]* will always evaluate as"
": warning: the address of [^ ]* will never be NULL"
": warning: too few arguments for format"
": warning: reference to local variable .* returned"
": warning: returning reference to temporary"
": warning: function returns address of local variable"
": warning: .*\\[-Wsizeof-pointer-memaccess\\]"
": warning: .*\\[-Waggressive-loop-optimizations\\]"
# this may be valid code :/
#": warning: multi-character character constant"
# need to check these two ...
#": warning: assuming signed overflow does not occur when"
#": warning: comparison with string literal results in unspecified behav"
# yacc/lex likes to trigger this one
#": warning: extra tokens at end of .* directive"
# only gcc itself triggers this ?
#": warning: .*noreturn.* function does return"
# these throw false positives when 0 is used instead of NULL
#": warning: missing sentinel in function call"
#": warning: not enough variable arguments to fit a sentinel"
)
local abort="no"
local i=0
local grep_cmd=grep
[[ $PORTAGE_LOG_FILE = *.gz ]] && grep_cmd=zgrep
while [[ -n ${msgs[${i}]} ]] ; do
m=${msgs[$((i++))]}
# force C locale to work around slow unicode locales #160234
f=$(LC_ALL=C $grep_cmd "${m}" "${PORTAGE_LOG_FILE}")
if [[ -n ${f} ]] ; then
abort="yes"
# for now, don't make this fatal (see bug #337031)
#case "$m" in
# ": warning: call to .* will always overflow destination buffer") always_overflow=yes ;;
#esac
if [[ $always_overflow = yes ]] ; then
eerror
eerror "QA Notice: Package triggers severe warnings which indicate that it"
eerror " may exhibit random runtime failures."
eerror
eerror "${f}"
eerror
eerror " Please file a bug about this at http://bugs.gentoo.org/"
eerror " with the maintaining herd of the package."
eerror
else
__vecho -ne '\n'
eqawarn "QA Notice: Package triggers severe warnings which indicate that it"
eqawarn " may exhibit random runtime failures."
eqawarn "${f}"
__vecho -ne '\n'
fi
fi
done
local cat_cmd=cat
[[ $PORTAGE_LOG_FILE = *.gz ]] && cat_cmd=zcat
[[ $reset_debug = 1 ]] && set -x
# Use safe cwd, avoiding unsafe import for bug #469338.
f=$(cd "${PORTAGE_PYM_PATH}" ; $cat_cmd "${PORTAGE_LOG_FILE}" | \
"${PORTAGE_PYTHON:-/usr/bin/python}" "$PORTAGE_BIN_PATH"/check-implicit-pointer-usage.py || die "check-implicit-pointer-usage.py failed")
if [[ -n ${f} ]] ; then
# In the future this will be a forced "die". In preparation,
# increase the log level from "qa" to "eerror" so that people
# are aware this is a problem that must be fixed asap.
# just warn on 32bit hosts but bail on 64bit hosts
case ${CHOST} in
alpha*|hppa64*|ia64*|powerpc64*|mips64*|sparc64*|sparcv9*|x86_64*) gentoo_bug=yes ;;
esac
abort=yes
if [[ $gentoo_bug = yes ]] ; then
eerror
eerror "QA Notice: Package triggers severe warnings which indicate that it"
eerror " will almost certainly crash on 64bit architectures."
eerror
eerror "${f}"
eerror
eerror " Please file a bug about this at http://bugs.gentoo.org/"
eerror " with the maintaining herd of the package."
eerror
else
__vecho -ne '\n'
eqawarn "QA Notice: Package triggers severe warnings which indicate that it"
eqawarn " will almost certainly crash on 64bit architectures."
eqawarn "${f}"
__vecho -ne '\n'
fi
fi
if [[ ${abort} == "yes" ]] ; then
if [[ $gentoo_bug = yes || $always_overflow = yes ]] ; then
die "install aborted due to severe warnings shown above"
else
echo "Please do not file a Gentoo bug and instead" \
"report the above QA issues directly to the upstream" \
"developers of this software." | fmt -w 70 | \
while read -r line ; do eqawarn "${line}" ; done
eqawarn "Homepage: ${HOMEPAGE}"
has stricter ${FEATURES} && \
die "install aborted due to severe warnings shown above"
fi
fi
fi
}
gcc_warn_check
: # guarantee successful exit
# vim:ft=sh