Add conditional component inclusion facility

Add a conditional execution facility: if a function support_xxx exists
and returns false then component_xxx is not executed (except when the
command line lists an explicit set of components to execute).

Use this facility for the 64-bit-specific or amd64-specific components.
This commit is contained in:
Gilles Peskine 2019-01-08 23:33:45 +01:00
parent 7120f77889
commit 3fbdd21ca5

View file

@ -119,12 +119,23 @@ pre_initialize_variables () {
# Parse the script with sed, because in sh there is no way to list # Parse the script with sed, because in sh there is no way to list
# defined functions. # defined functions.
ALL_COMPONENTS=$(sed -n 's/^ *component_\([0-9A-Z_a-z]*\) *().*/\1/p' <"$0") ALL_COMPONENTS=$(sed -n 's/^ *component_\([0-9A-Z_a-z]*\) *().*/\1/p' <"$0")
# Exclude components that are not supported on this platform.
SUPPORTED_COMPONENTS=
for component in $ALL_COMPONENTS; do
case $(type "support_$component" 2>&1) in
*' function'*)
if ! support_$component; then continue; fi;;
esac
SUPPORTED_COMPONENTS="$SUPPORTED_COMPONENTS $component"
done
} }
# Test whether $1 is excluded via $COMPONENTS (a space-separated list of # Test whether $1 is excluded via the command line.
# wildcard patterns).
is_component_excluded() is_component_excluded()
{ {
# Is $1 excluded via $COMPONENTS (a space-separated list of wildcard
# patterns)?
set -f set -f
for pattern in $COMPONENTS; do for pattern in $COMPONENTS; do
set +f set +f
@ -299,7 +310,7 @@ pre_parse_command_line () {
if [ $ALL_EXCEPT -ne 0 ]; then if [ $ALL_EXCEPT -ne 0 ]; then
RUN_COMPONENTS= RUN_COMPONENTS=
for component in $ALL_COMPONENTS; do for component in $SUPPORTED_COMPONENTS; do
if ! is_component_excluded "$component"; then if ! is_component_excluded "$component"; then
RUN_COMPONENTS="$RUN_COMPONENTS $component" RUN_COMPONENTS="$RUN_COMPONENTS $component"
fi fi
@ -738,38 +749,49 @@ component_test_make_shared () {
make SHARED=1 all check make SHARED=1 all check
} }
case $(uname -m) in component_test_m32_o0 () {
amd64|x86_64) # Build once with -O0, to compile out the i386 specific inline assembly
component_test_m32_o0 () { msg "build: i386, make, gcc -O0 (ASan build)" # ~ 30s
# Build once with -O0, to compile out the i386 specific inline assembly scripts/config.pl full
msg "build: i386, make, gcc -O0 (ASan build)" # ~ 30s make CC=gcc CFLAGS='-O0 -Werror -Wall -Wextra -m32 -fsanitize=address'
scripts/config.pl full
make CC=gcc CFLAGS='-O0 -Werror -Wall -Wextra -m32 -fsanitize=address'
msg "test: i386, make, gcc -O0 (ASan build)" msg "test: i386, make, gcc -O0 (ASan build)"
make test make test
} }
support_test_m32_o0 () {
case $(uname -m) in
*64*) true;;
*) false;;
esac
}
component_test_m32_o1 () { component_test_m32_o1 () {
# Build again with -O1, to compile in the i386 specific inline assembly # Build again with -O1, to compile in the i386 specific inline assembly
msg "build: i386, make, gcc -O1 (ASan build)" # ~ 30s msg "build: i386, make, gcc -O1 (ASan build)" # ~ 30s
scripts/config.pl full scripts/config.pl full
make CC=gcc CFLAGS='-O1 -Werror -Wall -Wextra -m32 -fsanitize=address' make CC=gcc CFLAGS='-O1 -Werror -Wall -Wextra -m32 -fsanitize=address'
msg "test: i386, make, gcc -O1 (ASan build)" msg "test: i386, make, gcc -O1 (ASan build)"
make test make test
} }
support_test_m32_o1 () {
support_test_m32_o0 "$@"
}
component_test_mx32 () { component_test_mx32 () {
msg "build: 64-bit ILP32, make, gcc" # ~ 30s msg "build: 64-bit ILP32, make, gcc" # ~ 30s
scripts/config.pl full scripts/config.pl full
make CC=gcc CFLAGS='-Werror -Wall -Wextra -mx32' make CC=gcc CFLAGS='-Werror -Wall -Wextra -mx32'
msg "test: 64-bit ILP32, make, gcc" msg "test: 64-bit ILP32, make, gcc"
make test make test
} }
;; support_test_mx32 () {
esac case $(uname -m) in
amd64|x86_64) true;;
*) false;;
esac
}
component_test_have_int32 () { component_test_have_int32 () {
msg "build: gcc, force 32-bit bignum limbs" msg "build: gcc, force 32-bit bignum limbs"