From: Emil Velikov Date: Wed, 9 Oct 2024 15:26:25 +0000 (+0100) Subject: testsuite: fix gcc/libasan.so load order X-Git-Tag: v34~229 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b81b4d62d53fd74f3849bbb621f2f06324ae90ab;p=thirdparty%2Fkmod.git testsuite: fix gcc/libasan.so load order Currently we silence the ordering warning from libasan, via the environment: ASAN_OPTIONS=verify_asan_link_order=0... Instead we should be LD_PRELOAD-ing the library, since otherwise we might end with miss-matched symbols - one coming from libasan, with the counter part from the system library. Plus LD_PRELOAD is the only way to make the clang sanitizers work... That I have found. Although that's coming with a later patch. v2: - handle when the file is a script Signed-off-by: Emil Velikov Link: https://github.com/kmod-project/kmod/pull/179 Signed-off-by: Lucas De Marchi --- diff --git a/scripts/test-wrapper.sh b/scripts/test-wrapper.sh index 78b48324..073446f1 100755 --- a/scripts/test-wrapper.sh +++ b/scripts/test-wrapper.sh @@ -3,8 +3,14 @@ set -euo pipefail if [[ ${ASAN_OPTIONS-} || ${UBSAN_OPTIONS-} || ${MSAN_OPTIONS-} ]]; then - ASAN_OPTIONS=verify_asan_link_order=0:halt_on_error=1:abort_on_error=1:print_summary=1 - export ASAN_OPTIONS + LD_PRELOAD=$(gcc -print-file-name=libasan.so) + # In some cases, like in Fedora, the file is a script which cannot be + # preloaded. Attempt to extract the details from within. + if grep -q INPUT "$LD_PRELOAD"; then + input=$(sed -r -n "s/INPUT \( (.*) \)/\1/p" "$LD_PRELOAD") + test -f "$input" && LD_PRELOAD="$input" + fi + export LD_PRELOAD fi exec "$@"