[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: dbb03f8f60 ("[compiler-rt] Replace assignment w/.set directive
(#107667)")

---------

Co-authored-by: Vitaly Buka <vitalybuka@google.com>
This commit is contained in:
Matt Turner
2026-04-25 21:28:22 -04:00
committed by GitHub
parent b614c152de
commit 0ccb181514

View File

@@ -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)