Skip to content

Commit

Permalink
buildsys: test in CI that we use config.h correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin committed Oct 19, 2021
1 parent 3ae6f9f commit 2ad278d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
23 changes: 23 additions & 0 deletions dev/audit-config-h.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/sh
#
# This script verifies that we are not accidentally using config.h from one of
# our header files.
set -e

# First scan config.h to obtain a list of all symbols it might define. From
# this is subtracts a list of "known OK" symbols. The symbols and there reason
# for being on this list are:
# - `HAVE_FUNC_ATTRIBUTE_`*: these are only used for optimizations; also, our
# headers try hard to define them on the fly (at least in GCC and clang)
# - `HAVE___BUILTIN_MUL_OVERFLOW`: same as above
# - `SIZEOF_VOID_P`: provided for backwards compatibility in a few packages,
# and actually (re-)defined in `common.h`
# - `SPARC`: only appears in a comment
PATTERN=$(egrep '(#define|#undef)' build/config.h | sed -E -e 's;(#define|/\* #undef) ([^ ]+) .*$;\2;' | egrep -v 'HAVE_FUNC_ATTRIBUTE_|HAVE___BUILTIN_MUL_OVERFLOW|SIZEOF_VOID_P|SPARC' | tr '\n' '|')
PATTERN=${PATTERN%?} # remove trailing "|"

# Next use `git grep` to search all kernel header files for occurrences of any
# of the symbols in the pattern we just created. We negate the exit code: grep
# exits with exit code 0 if there were hits, and with exit code 1 if there
# were no hits. For our purposes, we want the reverse: no hits is "good".
! git grep -n -P ${PATTERN} :src/*.h
3 changes: 3 additions & 0 deletions dev/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ GAPInput
# test: running `make` a second time should produce no output
test -z "$(make)"

# audit config.h
$SRCDIR/dev/audit-config-h.sh

# test: touching all source files does *not* trigger a rebuild if we make
# a target that doesn't depend on sources. We verify this by replacing the source
# code with garbage
Expand Down

0 comments on commit 2ad278d

Please sign in to comment.