]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Further fix up effective-target 'no_fsanitize_address' check
authorThomas Schwinge <tschwinge@baylibre.com>
Thu, 19 Feb 2026 10:29:42 +0000 (11:29 +0100)
committerThomas Schwinge <tschwinge@baylibre.com>
Thu, 19 Feb 2026 11:53:39 +0000 (12:53 +0100)
That got added with commit r11-4762-g65e82636bcdb72a878c2e53943e71b15dd9fb22d
"PR target/96307: Fix KASAN option checking", and already fixed up in
commit r12-3723-g6e6bf4cd21af39a7923bae007517ab43a4c3b36a
"Fix no_fsanitize_address effective target", but I just realized that on, for
example, standard x86_64-pc-linux-gnu, I'm unexpectedly seeing test cases
UNSUPPORTED, due to the effective-target 'no_fsanitize_address' check failing
with:

    Executing on host: [...]/build-gcc/gcc/xgcc -B[...]/build-gcc/gcc/  fsanitize_address3454287.c    -fdiagnostics-plain-output  -fsanitize=address -Wno-complain-wrong-lang  -lm  -o fsanitize_address3454287.exe    (timeout = 300)
    spawn [...]
    /usr/bin/ld: cannot find libasan_preinit.o: No such file or directory
    /usr/bin/ld: cannot find -lasan: No such file or directory
    collect2: error: ld returned 1 exit status
    compiler exited with status 1

Notice no setup for paths to build-tree libsanitizer.  Need to use a proper
'asan.exp' file with 'asan_init'/'asan_finish' calls to set up linker paths,
etc. -- however, all test cases using effective-target 'no_fsanitize_address'
are compilation test cases, so let's just reflect that in the effective-target
'no_fsanitize_address' check.  With that, I then get the desired:

    -UNSUPPORTED: gcc.dg/pr91441.c
    +PASS: gcc.dg/pr91441.c (test for excess errors)

    -UNSUPPORTED: gcc.dg/pr96260.c
    +PASS: gcc.dg/pr96260.c (test for excess errors)

    -UNSUPPORTED: gcc.dg/pr96307.c
    +PASS: gcc.dg/pr96307.c (test for excess errors)

    -UNSUPPORTED: gcc.dg/uninit-pr93100.c
    +PASS: gcc.dg/uninit-pr93100.c  (test for warnings, line 16)
    +PASS: gcc.dg/uninit-pr93100.c  (test for warnings, line 26)
    +PASS: gcc.dg/uninit-pr93100.c  (test for warnings, line 38)
    +PASS: gcc.dg/uninit-pr93100.c  (test for warnings, line 48)
    +PASS: gcc.dg/uninit-pr93100.c  (test for warnings, line 61)
    +PASS: gcc.dg/uninit-pr93100.c  (test for warnings, line 71)
    +PASS: gcc.dg/uninit-pr93100.c (test for excess errors)

    -UNSUPPORTED: g++.dg/warn/uninit-pr93100.C  -std=gnu++20
    +PASS: g++.dg/warn/uninit-pr93100.C  -std=gnu++20  (test for warnings, line 13)
    +PASS: g++.dg/warn/uninit-pr93100.C  -std=gnu++20  (test for warnings, line 20)
    +PASS: g++.dg/warn/uninit-pr93100.C  -std=gnu++20  (test for warnings, line 31)
    +PASS: g++.dg/warn/uninit-pr93100.C  -std=gnu++20  (test for warnings, line 38)
    +PASS: g++.dg/warn/uninit-pr93100.C  -std=gnu++20  (test for warnings, line 49)
    +PASS: g++.dg/warn/uninit-pr93100.C  -std=gnu++20  (test for warnings, line 56)
    +PASS: g++.dg/warn/uninit-pr93100.C  -std=gnu++20 (test for excess errors)
    [Etc.]

    -UNSUPPORTED: g++.dg/warn/uninit-pr95825-1.C  -std=gnu++20
    +PASS: g++.dg/warn/uninit-pr95825-1.C  -std=gnu++20  (test for bogus messages, line 17)
    +PASS: g++.dg/warn/uninit-pr95825-1.C  -std=gnu++20 (test for excess errors)
    [Etc.]

    -UNSUPPORTED: gnat.dg/asan1.adb
    +PASS: gnat.dg/asan1.adb (test for excess errors)

..., while these remain UNSUPPORTED for targets that don't support
'-fsanitize=address'.

gcc/testsuite/
* lib/target-supports.exp
(check_effective_target_no_fsanitize_address): Check 'assembly'
instead of 'executable'.

gcc/testsuite/lib/target-supports.exp

index ba91c95b348fd3079978ca2ac07b50d8e0de08b1..855bdbcf55ad28db0152789fbbebbb3e819df4ba 100644 (file)
@@ -14144,10 +14144,13 @@ proc check_effective_target_movdir { } {
     } "-mmovdiri -mmovdir64b" ]
 }
 
-# Return 1 if the target does not support address sanitizer, 0 otherwise
+# Return 1 if the target does not support address sanitizer, 0 otherwise.
+# Note that this is usable only for compilation test cases.  (Otherwise, use a
+# proper 'asan.exp' file with 'asan_init'/'asan_finish' calls to set up linker
+# paths, etc.)
 
 proc check_effective_target_no_fsanitize_address {} {
-    if ![check_no_compiler_messages fsanitize_address executable {
+    if ![check_no_compiler_messages fsanitize_address assembly {
        int main (void) { return 0; }
     } "-fsanitize=address" ] {
        return 1;