From 3b8d2eab8ef7066cf0d9cd67c838ba1b03c68773 Mon Sep 17 00:00:00 2001 From: Auke Kok Date: Thu, 19 Sep 2024 14:48:20 -0700 Subject: [PATCH] Sparse fix for epel 0.6.4 sparse - redefines We should rely on sparse from epel to do automated sparse checking and not a git tag. But the 0.6.4 build currently fails on sparse/gcc redefines. This magic Awk from Zach script processes sparse and gcc internal defines and leaves the one intact that sparse doesn't have. Signed-off-by: Auke Kok --- utils/sparse.sh | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/utils/sparse.sh b/utils/sparse.sh index 93791617..94590e44 100755 --- a/utils/sparse.sh +++ b/utils/sparse.sh @@ -37,10 +37,23 @@ search=$(gcc -print-search-dirs | awk '($1 == "install:"){print "-I" $2}') # # We're trying to use sparse against glibc headers which go wild trying to # use internal compiler macros to test features. We copy gcc's and give -# them to sparse. But not __SIZE_TYPE__ 'cause sparse defines that one. +# them to sparse, but not the ones that sparse already has. # -defines=".sparse.gcc-defines.h" -gcc -dM -E -x c - < /dev/null | grep -v __SIZE_TYPE__ > $defines +defines=".sparse.gcc-defines.$$.h" +awk ' + # save defines from gcc + ( FNR == NR ) { lines[$2]=$0 } + + # delete defines that sparse also has + ( FNR < NR ) { delete lines[$2] } + + # dump remaining lines unique to gcc + END { + for (a in lines) { + print lines[a] + } + } +' <(gcc -dM -E -x c - < /dev/null) <(sparse -dM -E -x c - < /dev/null) > $defines include="-include $defines" # @@ -54,6 +67,9 @@ else fi sparse $m64 $include $search/include "$@" 2>&1 | egrep -v "($RE)" | tee .sparse.output + +rm -f $defines + if [ -s .sparse.output ]; then exit 1 else