Bug 504222

Summary: coregrind/vg_preloaded.c fails to compile with clang on arm
Product: [Developer tools] valgrind Reporter: Khem Raj <raj.khem>
Component: generalAssignee: Paul Floyd <pjfloyd>
Status: RESOLVED FIXED    
Severity: normal CC: pjfloyd
Priority: NOR    
Version First Reported In: 3.25 GIT   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: proposed fix.

Description Khem Raj 2025-05-14 16:39:27 UTC
Created attachment 181298 [details]
proposed fix.

When using clang compiler to cross compile for arm architecture, it fails to build due to syntax differences in pushsection directive between clang and gcc. Ending in clang complains

<inline asm>:1:41: error: expected '%<type>' or "<type>" 

The simple fix is to use '%' instead of '@' for type specifier. which works on both gcc and clang

Attaching a fix
Comment 1 Paul Floyd 2025-05-14 18:00:27 UTC
What OS, clang version and CPU is this with?
Comment 2 Khem Raj 2025-05-15 01:54:13 UTC
(In reply to Paul Floyd from comment #1)
> What OS, clang version and CPU is this with?

This is Yocto, Clang-20 and cross compiling for ARM32 bit Qemu target.
Comment 3 Paul Floyd 2025-05-15 06:35:27 UTC
I can reproduce this with Raspberry Pi OS and clang-14

The combination of arm and clang isn't well supported. I also get lots of errors building the regression tests with that combination.
Comment 4 Paul Floyd 2025-05-29 19:33:42 UTC
There are still lots of problems (at least with clang-16 and Raspberry Pi OS based on Debian bookworm), especially building testcases.

commit 2fa8581c4974db57de80de915d16ce299eb9aa84 (HEAD -> master, origin/master, origin/HEAD)
Author: Khem Raj <raj.khem@gmail.com>
Date:   Wed May 14 09:29:33 2025 -0700

    Use portable syntax for pushsection directive in inline assembly
    
    '@' does not work with clang inline assembler, but '%' works with both
    gcc and clang. Therefore use '%' to make it more portable
    
    Fixes
    <inline asm>:1:41: error: expected '%<type>' or "<type>"
    
    Signed-off-by: Khem Raj <raj.khem@gmail.com>