Hi Xi, thanks for pointing this out. I'd definitely say that the
https://clang.llvm.org/docs/ThreadSanitizer.html documentation is outdated.
According to
https://github.com/google/sanitizers/wiki/ThreadSanitizerCppManual#supported-platforms
TSAN is supported on Mips64. Furthermore, there are actual code segments (in
compiler-rt/lib/tsan/rtl/tsan_platforms.h, for example) related to Mips64.
I didn't add the 64-bit target check, however. Here is the updated version of
the patch.
gcc/ChangeLog:
* config/mips/mips.cc (mips_option_override): Enable
asyncronous unwind tables with both ASAN and TSAN.
---
gcc/config/mips/mips.cc | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/gcc/config/mips/mips.cc b/gcc/config/mips/mips.cc
index e64928f4113..2dce4007678 100644
--- a/gcc/config/mips/mips.cc
+++ b/gcc/config/mips/mips.cc
@@ -20115,10 +20115,16 @@ mips_option_override (void)
target_flags |= MASK_64BIT;
}
- /* -fsanitize=address needs to turn on -fasynchronous-unwind-tables in
- order for tracebacks to be complete but not if any
- -fasynchronous-unwind-table were already specified. */
- if (flag_sanitize & SANITIZE_USER_ADDRESS
+ /* -fsanitize=address, and -fsanitize=thread need to turn
+ on -fasynchronous-unwind-tables in order for tracebacks
+ to be complete but not if any -fasynchronous-unwind-table
+ were already specified. */
+ /* FIXME: HWSAN is currently only available on AArch64,
+ but could also utilize -fasynchronous-unwind-tables.
+ FIXME: We would also like to check if -ffreestanding is passed in.
+ However, it is only available in C-ish frontends. */
+ if (((flag_sanitize & SANITIZE_USER_ADDRESS)
+ || (TARGET_64BIT && (flag_sanitize & SANITIZE_THREAD)))
&& !global_options_set.x_flag_asynchronous_unwind_tables)
flag_asynchronous_unwind_tables = 1;
---
________________________________
From: Xi Ruoyao <[email protected]>
Sent: Saturday, May 28, 2022 12:30 PM
To: Dimitrije Milosevic <[email protected]>;
[email protected] <[email protected]>
Cc: Djordje Todorovic <[email protected]>
Subject: Re: [PATCH] Mips: Enable asynchronous unwind tables with both ASAN and
TSAN
On Thu, 2022-05-26 at 14:18 +0000, Dimitrije Milosevic wrote:
> Enable asynchronous unwind tables with both ASAN and TSAN for correct
> back-trace.
> LLVM currently enables asynchronous unwind tables for: ASAN, HWSAN, TSAN,
> MSAN, and DFSAN.
> HWSAN is currently available only on AArch64, while MSAN and DFSAN are not
> available at all.
> Also, LLVM checks is '-ffreestanding' is not passed in. '-ffreestanding' is
> only available in C-family frontends, hence why no such check is included.
> TODO: Not sure if any tests should be added.
According to https://clang.llvm.org/docs/ThreadSanitizer.html, TSAN is
not supported on MIPS. Is this doc outdated?
--
Xi Ruoyao <[email protected]>
School of Aerospace Science and Technology, Xidian University