fix ubsan for `test_libnimbus_lc` (#5258)
Pass `-fsanitize=undefined` flag when compiling `test_libnimbus_lc` when building in ubsan mode.
This commit is contained in:
parent
6d24e73f8d
commit
c26e8132fc
|
@ -106,6 +106,7 @@ jobs:
|
|||
# Stack usage test and UBSAN on recent enough gcc:
|
||||
if [[ '${{ runner.os }}' == 'Linux' && '${{ matrix.target.cpu }}' == 'amd64' ]]; then
|
||||
if [[ '${{ github.sha }}' =~ ^7 ]]; then
|
||||
export WITH_UBSAN=1 >> $GITHUB_ENV
|
||||
export NIMFLAGS="${NIMFLAGS} -d:limitStackUsage --passC:-fsanitize=undefined --passL:-fsanitize=undefined"
|
||||
else
|
||||
export NIMFLAGS="${NIMFLAGS} -d:limitStackUsage"
|
||||
|
|
17
Makefile
17
Makefile
|
@ -756,18 +756,29 @@ libnimbus_lc.a: | build deps
|
|||
echo -e $(BUILD_END_MSG) "build/$@"
|
||||
|
||||
# `-Wno-maybe-uninitialized` in Linux: https://github.com/nim-lang/Nim/issues/22246
|
||||
# `-fsanitize=undefined` in Windows: https://github.com/msys2/MINGW-packages/issues/3163
|
||||
test_libnimbus_lc: libnimbus_lc.a
|
||||
+ echo -e $(BUILD_MSG) "build/$@" && \
|
||||
set -x && \
|
||||
EXTRA_FLAGS=() && \
|
||||
case "$$(uname)" in \
|
||||
Darwin) \
|
||||
clang -D__DIR__="\"beacon_chain/libnimbus_lc\"" --std=c17 -Weverything -Werror -Wno-declaration-after-statement -Wno-nullability-extension -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -o build/test_libnimbus_lc beacon_chain/libnimbus_lc/test_libnimbus_lc.c build/libnimbus_lc.a -framework Security; \
|
||||
if (( $${WITH_UBSAN:-0} )); then \
|
||||
EXTRA_FLAGS+=('-fsanitize=undefined'); \
|
||||
fi; \
|
||||
clang -D__DIR__="\"beacon_chain/libnimbus_lc\"" --std=c17 -Weverything -Werror -Wno-declaration-after-statement -Wno-nullability-extension -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -o build/test_libnimbus_lc beacon_chain/libnimbus_lc/test_libnimbus_lc.c build/libnimbus_lc.a -framework Security "$${EXTRA_FLAGS[@]}"; \
|
||||
;; \
|
||||
MINGW64_*) \
|
||||
gcc -D__DIR__="\"beacon_chain/libnimbus_lc\"" --std=c17 -Wall -Wextra -pedantic -Werror -pedantic-errors -flto -o build/test_libnimbus_lc -D_CRT_SECURE_NO_WARNINGS beacon_chain/libnimbus_lc/test_libnimbus_lc.c build/libnimbus_lc.a; \
|
||||
if (( $${WITH_UBSAN:-0} )); then \
|
||||
echo "MINGW cannot find -lubsan." && exit 1; \
|
||||
fi; \
|
||||
gcc -D__DIR__="\"beacon_chain/libnimbus_lc\"" --std=c17 -Wall -Wextra -pedantic -Werror -pedantic-errors -flto -o build/test_libnimbus_lc -D_CRT_SECURE_NO_WARNINGS beacon_chain/libnimbus_lc/test_libnimbus_lc.c build/libnimbus_lc.a "$${EXTRA_FLAGS[@]}"; \
|
||||
;; \
|
||||
*) \
|
||||
gcc -D__DIR__="\"beacon_chain/libnimbus_lc\"" --std=c17 -Wall -Wextra -pedantic -Werror -pedantic-errors -Wno-maybe-uninitialized -flto -o build/test_libnimbus_lc beacon_chain/libnimbus_lc/test_libnimbus_lc.c build/libnimbus_lc.a; \
|
||||
if (( $${WITH_UBSAN:-0} )); then \
|
||||
EXTRA_FLAGS+=('-fsanitize=undefined'); \
|
||||
fi; \
|
||||
gcc -D__DIR__="\"beacon_chain/libnimbus_lc\"" --std=c17 -Wall -Wextra -pedantic -Werror -pedantic-errors -Wno-maybe-uninitialized -flto -o build/test_libnimbus_lc beacon_chain/libnimbus_lc/test_libnimbus_lc.c build/libnimbus_lc.a "$${EXTRA_FLAGS[@]}"; \
|
||||
;; \
|
||||
esac && \
|
||||
echo -e $(BUILD_END_MSG) "build/$@"
|
||||
|
|
Loading…
Reference in New Issue