From 0ccb181514cda5245ed031b210a2d97282bc1ff0 Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Sat, 25 Apr 2026 21:28:22 -0400 Subject: [PATCH] [compiler-rt] Use asm .set only for Hexagon (#194160) Two incompatible assembler syntaxes exist for symbol assignment: ``` sym = val -- accepted by most GNU assembler targets; rejected by Hexagon, which interprets it as a mnemonic .set sym, val -- accepted by Hexagon; rejected by Alpha, which reserves .set for assembler mode flags ``` Switch all to `sym = val`, and opt out Hexagon to `.set sym`. Fixes: dbb03f8f606e ("[compiler-rt] Replace assignment w/.set directive (#107667)") --------- Co-authored-by: Vitaly Buka --- .../sanitizer_redefine_builtins.h | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_redefine_builtins.h b/compiler-rt/lib/sanitizer_common/sanitizer_redefine_builtins.h index 7d8891117657..6a7d1dc79a52 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_redefine_builtins.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_redefine_builtins.h @@ -17,11 +17,23 @@ // The asm hack only works with GCC and Clang. # if !defined(_WIN32) && !defined(_AIX) && !defined(__APPLE__) -asm(R"( - .set memcpy, __sanitizer_internal_memcpy - .set memmove, __sanitizer_internal_memmove - .set memset, __sanitizer_internal_memset - )"); +# if defined(__hexagon__) + +# define SANITIZER_REDEFINE_BUILTIN_ASM(name) \ + asm(".set " #name ", __sanitizer_internal_" #name) + +# else + +# define SANITIZER_REDEFINE_BUILTIN_ASM(name) \ + asm(#name " = __sanitizer_internal_" #name) + +# endif + +SANITIZER_REDEFINE_BUILTIN_ASM(memcpy); +SANITIZER_REDEFINE_BUILTIN_ASM(memmove); +SANITIZER_REDEFINE_BUILTIN_ASM(memset); + +# undef SANITIZER_REDEFINE_BUILTIN_ASM # if defined(__cplusplus) && \ !defined(SANITIZER_COMMON_REDEFINE_BUILTINS_IN_STD)