diff options
author | Aidan MacDonald <amachronic@protonmail.com> | 2022-04-17 16:33:39 +0100 |
---|---|---|
committer | Aidan MacDonald <amachronic@protonmail.com> | 2022-04-17 11:37:34 -0400 |
commit | c6df8cc4f7cdbff2bf86d40be3ee1e9daae6c9b6 (patch) | |
tree | eeabe1d673ede2b14bf0227578f73c2a3628f2d5 | |
parent | 6f5af8e53cd19bdc57481703179ebe498873e014 (diff) | |
download | rockbox-c6df8cc4f7cdbff2bf86d40be3ee1e9daae6c9b6.tar.gz rockbox-c6df8cc4f7cdbff2bf86d40be3ee1e9daae6c9b6.zip |
configure: Add support for compiling the simulator with UBSan
By passing --with-ubsan to tools/configure, you can now build the
simulator with UBSan to catch undefined behavior at runtime.
Change-Id: I054cd46ca59587dd544efbd7bdf6d27a040a4891
-rwxr-xr-x | tools/configure | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tools/configure b/tools/configure index ac657e38c9..12b45bf890 100755 --- a/tools/configure +++ b/tools/configure | |||
@@ -270,6 +270,12 @@ simcc () { | |||
270 | LDOPTS="$LDOPTS -fsanitize=address -lasan" | 270 | LDOPTS="$LDOPTS -fsanitize=address -lasan" |
271 | fi | 271 | fi |
272 | 272 | ||
273 | if [ "$ARG_UBSAN" = "1" ] ; then | ||
274 | echo "Using UBSan" | ||
275 | GCCOPTS="$GCCOPTS -fsanitize=undefined -fPIC" | ||
276 | LDOPTS="$LDOPTS -fsanitize=undefined" | ||
277 | fi | ||
278 | |||
273 | # Some linux setups like to warn about unused results. They are correct, | 279 | # Some linux setups like to warn about unused results. They are correct, |
274 | # but cleaning this up is a lot of work. | 280 | # but cleaning this up is a lot of work. |
275 | GCCOPTS="$GCCOPTS -Wno-unused-result" | 281 | GCCOPTS="$GCCOPTS -Wno-unused-result" |
@@ -479,6 +485,9 @@ EOF | |||
479 | if [ "$ARG_ADDR_SAN" = "1" ] ; then | 485 | if [ "$ARG_ADDR_SAN" = "1" ] ; then |
480 | ARG_THREAD_SUPPORT=1 | 486 | ARG_THREAD_SUPPORT=1 |
481 | fi | 487 | fi |
488 | if [ "$ARG_UBSAN" = "1" ] ; then | ||
489 | ARG_THREAD_SUPPORT=1 | ||
490 | fi | ||
482 | 491 | ||
483 | thread_support= | 492 | thread_support= |
484 | if [ -z "$ARG_THREAD_SUPPORT" ] || [ "$ARG_THREAD_SUPPORT" = "0" ]; then | 493 | if [ -z "$ARG_THREAD_SUPPORT" ] || [ "$ARG_THREAD_SUPPORT" = "0" ]; then |
@@ -1429,6 +1438,7 @@ ARG_PREFIX="$PREFIX" | |||
1429 | ARG_THREAD_SUPPORT= | 1438 | ARG_THREAD_SUPPORT= |
1430 | ARG_32BIT= | 1439 | ARG_32BIT= |
1431 | ARG_ADDR_SAN= | 1440 | ARG_ADDR_SAN= |
1441 | ARG_UBSAN= | ||
1432 | err= | 1442 | err= |
1433 | for arg in "$@"; do | 1443 | for arg in "$@"; do |
1434 | case "$arg" in | 1444 | case "$arg" in |
@@ -1452,6 +1462,7 @@ for arg in "$@"; do | |||
1452 | --no-sdl-threads) | 1462 | --no-sdl-threads) |
1453 | ARG_THREAD_SUPPORT=0;; | 1463 | ARG_THREAD_SUPPORT=0;; |
1454 | --with-address-sanitizer) ARG_ADDR_SAN=1;; | 1464 | --with-address-sanitizer) ARG_ADDR_SAN=1;; |
1465 | --with-ubsan) ARG_UBSAN=1;; | ||
1455 | --prefix=*) ARG_PREFIX=`echo "$arg" | cut -d = -f 2`;; | 1466 | --prefix=*) ARG_PREFIX=`echo "$arg" | cut -d = -f 2`;; |
1456 | --compiler-prefix=*) ARG_COMPILER_PREFIX=`echo "$arg" | cut -d = -f 2`;; | 1467 | --compiler-prefix=*) ARG_COMPILER_PREFIX=`echo "$arg" | cut -d = -f 2`;; |
1457 | --help) help;; | 1468 | --help) help;; |