Bug 504222 - coregrind/vg_preloaded.c fails to compile with clang on arm
Summary: coregrind/vg_preloaded.c fails to compile with clang on arm
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (other bugs)
Version First Reported In: 3.25 GIT
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Paul Floyd
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-05-14 16:39 UTC by Khem Raj
Modified: 2025-05-29 19:33 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
proposed fix. (1.01 KB, application/mbox)
2025-05-14 16:39 UTC, Khem Raj
Details

Note You need to log in before you can comment on or make changes to this bug.
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>