<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/72970>72970</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Interceptors no longer build on SPARC/Solaris with Solaris as
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          jakubjelinek
      </td>
    </tr>
</table>

<pre>
    As mentioned in https://gcc.gnu.org/PR112563, the new DECLARE_WRAPPER macro added in 37445e96d867f4266993085e821fbd4c4d8fa401 and ammended in
85d3873a45f9977f868723a221ebcb35100cac22 doesn't work on SPARC/Solaris with Solaris as.
While clang and GNU as when used from GCC seems to be forgiving on most architectures and allow both
%function and @function (with the latter not being allowed on ARM/AArch64 I believe because @ is assembler comment start there), Solaris as doesn't allow the %function form.
builtins/functions.h has a proper
#if defined(__arm__) || defined(__aarch64__)
#define SYMBOL_IS_FUNC(name) .type name,%function
#else
#define SYMBOL_IS_FUNC(name) .type name,@function
#endif
but obviously that is for *.S files, not meant for inline assembly.

So, I'd like to propose:

diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_asm.h b/compiler-rt/lib/sanitizer_common/sanitizer_asm.h
index 3c9bbdc9678b..bbb18cfbdf15 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_asm.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_asm.h
@@ -62,7 +62,11 @@
 
 #if !defined(__APPLE__)
 # define ASM_HIDDEN(symbol) .hidden symbol
-# define ASM_TYPE_FUNCTION(symbol) .type symbol, %function
+# if defined(__arm__) || defined(__aarch64__)
+#  define ASM_TYPE_FUNCTION(symbol) .type symbol, %function
+# else
+#  define ASM_TYPE_FUNCTION(symbol) .type symbol, @function
+# endif
 # define ASM_SIZE(symbol) .size symbol, .-symbol
 # define ASM_SYMBOL(symbol) symbol
 # define ASM_SYMBOL_INTERCEPTOR(symbol) symbol
diff --git a/compiler-rt/lib/interception/interception.h b/compiler-rt/lib/interception/interception.h
index 069f73d276f3..9d8b60b2eef5 100644
--- a/compiler-rt/lib/interception/interception.h
+++ b/compiler-rt/lib/interception/interception.h
@@ -185,6 +185,11 @@ const interpose_substitution substitution_##func_name[]             \
 # else
 #   define __ASM_WEAK_WRAPPER(func) ".weak " #func "\n"
 # endif  // SANITIZER_FREEBSD || SANITIZER_NETBSD
+#  if defined(__arm__) || defined(__aarch64__)
+#   define ASM_TYPE_FUNCTION_STR "%function"
+# else
+#   define ASM_TYPE_FUNCTION_STR "@function"
+#  endif
 // Keep trampoline implementation in sync with sanitizer_common/sanitizer_asm.h
 #  define DECLARE_WRAPPER(ret_type, func, ...)                                 \
      extern "C" ret_type func(__VA_ARGS__);                                    \
@@ -196,7 +201,8 @@ const interpose_substitution substitution_##func_name[]             \
 __ASM_WEAK_WRAPPER(func) \
        ".set " #func ", " SANITIZER_STRINGIFY(TRAMPOLINE(func)) "\n"           \
        ".globl " SANITIZER_STRINGIFY(TRAMPOLINE(func)) "\n"                    \
- ".type  " SANITIZER_STRINGIFY(TRAMPOLINE(func)) ", %function\n" \
+       ".type  " SANITIZER_STRINGIFY(TRAMPOLINE(func)) ", " \
+         ASM_TYPE_FUNCTION_STR "\n" \
        SANITIZER_STRINGIFY(TRAMPOLINE(func)) ":\n"                             \
 SANITIZER_STRINGIFY(CFI_STARTPROC) "\n" \
        SANITIZER_STRINGIFY(ASM_TAIL_CALL) " __interceptor_" \

(because unfortunately SANITIZER_STRINGIFY(ASM_TYPE_FUNCTION(TRAMPOLINE(func))) doesn't work).
@melver 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0WF1z4rgS_TXipQuXLX8_8GAcmEttJkMBe6dmX1yy3QZNbIuyRLLZX39LMgTDTD7uZJZKxRaSTrdO95FaMCn5tkWcEH9K_JsRO6id6Cbf2f0h_441b_F-lIvyaZJIaLBVXLRYAm9hp9ReEjchdE7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