diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2023-11-19 11:41:26 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2023-11-19 11:41:26 +0100 |
| commit | 8059d63339b49d37af894f861956de4b89429bee (patch) | |
| tree | b004abfb3145d883f4be559723e00134164bab43 | |
| parent | 6ef99181273f6d8b3a3e08ce43ac3497ff71a0c0 (diff) | |
| download | nissy-core-8059d63339b49d37af894f861956de4b89429bee.tar.gz nissy-core-8059d63339b49d37af894f861956de4b89429bee.zip | |
Improved sanitizer detection
| -rwxr-xr-x | configure.sh | 10 | ||||
| -rwxr-xr-x | test/test.sh | 12 |
2 files changed, 13 insertions, 9 deletions
diff --git a/configure.sh b/configure.sh index b9779c2..e4a142d 100755 --- a/configure.sh +++ b/configure.sh | |||
| @@ -1,8 +1,9 @@ | |||
| 1 | #!/bin/sh | 1 | #!/bin/sh |
| 2 | 2 | ||
| 3 | detect() { cc -march=native -dM -E - < /dev/null | grep "$1"; } | 3 | detectarch() { cc -march=native -dM -E - </dev/null | grep "$1"; } |
| 4 | detectsan() { cc -fsanitize=$1 -dM -E -x c - </dev/null | grep "SANITIZE"; } | ||
| 4 | 5 | ||
| 5 | [ -n "$(detect __AVX2__)" ] && detected="AVX2" | 6 | [ -n "$(detectarch __AVX2__)" ] && detected="AVX2" |
| 6 | 7 | ||
| 7 | TYPE=${TYPE-"$detected"} | 8 | TYPE=${TYPE-"$detected"} |
| 8 | 9 | ||
| @@ -11,7 +12,10 @@ echo "Using CUBE_$TYPE" | |||
| 11 | STD="-std=c99" | 12 | STD="-std=c99" |
| 12 | WFLAGS="-pedantic -Wall -Wextra -Wno-unused-parameter -Wno-unused-function" | 13 | WFLAGS="-pedantic -Wall -Wextra -Wno-unused-parameter -Wno-unused-function" |
| 13 | [ "$TYPE" = "AVX2" ] && AVX="-mavx2" | 14 | [ "$TYPE" = "AVX2" ] && AVX="-mavx2" |
| 14 | [ "$(uname)" = "Linux" ] && SAN="-fsanitize=address -fsanitize=undefined" | 15 | |
| 16 | [ -n "$(detectsan address)" ] && ADDR="-fsanitize=address" | ||
| 17 | [ -n "$(detectsan undefined)" ] && UNDEF="-fsanitize=undefined" | ||
| 18 | SAN="$ADDR $UNDEF" | ||
| 15 | 19 | ||
| 16 | CFLAGS="$STD $WFLAGS $AVX -O3" | 20 | CFLAGS="$STD $WFLAGS $AVX -O3" |
| 17 | DBGFLAGS="$STD $WFLAGS $AVX -g3 -DDEBUG" | 21 | DBGFLAGS="$STD $WFLAGS $AVX -g3 -DDEBUG" |
diff --git a/test/test.sh b/test/test.sh index 68b87aa..3adee3a 100755 --- a/test/test.sh +++ b/test/test.sh | |||
| @@ -1,15 +1,15 @@ | |||
| 1 | #!/bin/sh | 1 | #!/bin/sh |
| 2 | 2 | ||
| 3 | detectsan() { cc -fsanitize=$1 -dM -E -x c - </dev/null | grep "SANITIZE"; } | ||
| 4 | |||
| 3 | re="${TEST:-$@}" | 5 | re="${TEST:-$@}" |
| 4 | 6 | ||
| 5 | CC="cc -DDEBUG -std=c99 -pedantic -Wall -Wextra \ | 7 | CC="cc -DDEBUG -std=c99 -pedantic -Wall -Wextra \ |
| 6 | -Wno-unused-parameter -Wno-unused-function -g3 -D$CUBETYPE" | 8 | -Wno-unused-parameter -Wno-unused-function -g3 -D$CUBETYPE" |
| 7 | if [ "$CUBETYPE" = "CUBE_AVX2" ]; then | 9 | |
| 8 | CC="$CC -mavx2" | 10 | [ "$CUBETYPE" = "CUBE_AVX2" ] && CC="$CC -mavx2" |
| 9 | fi | 11 | [ -n "$(detectsan address)" ] && CC="$CC -fsanitize=address" |
| 10 | if [ "$(uname)" != "OpenBSD" ]; then | 12 | [ -n "$(detectsan undefined)" ] && CC="$CC -fsanitize=undefined" |
| 11 | CC="$CC -fsanitize=address -fsanitize=undefined" | ||
| 12 | fi | ||
| 13 | 13 | ||
| 14 | TESTBIN="test/run" | 14 | TESTBIN="test/run" |
| 15 | TESTOUT="test/last.out" | 15 | TESTOUT="test/last.out" |
