Bug 509103

Summary: tests/arm64/bug484935.c doesn't build if CFLAGS contain "-O2 -flto -ffat-lto-objects"
Product: [Developer tools] valgrind Reporter: Romain Geissler <romain.geissler>
Component: generalAssignee: Julian Seward <jseward>
Status: RESOLVED FIXED    
Severity: normal CC: mark
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Other   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: proposed patch (git format-patch format)

Description Romain Geissler 2025-09-04 12:12:51 UTC
Created attachment 184706 [details]
proposed patch (git format-patch format)

Hi,

This is a small bug report about a valgrind test case. We do build our software stack (including valgring) in a special way, we enable at top level the use of fat LTO objects, to be able to choose if we later build with or without LTO our own libraries depending on the open sources librairies we build. When doing that with valgrind, we have hit the issue describe in this gcc bug report: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121719 Basically compiling on ARM the test case tests/arm64/bug484935.c with CLAGS containing "-O2 -flto -ffat-lto-objects" with gcc on Linux results in having this assembler error:

/tmp/ccfnh7KQ.s: Assembler messages:
/tmp/ccfnh7KQ.s:175: Error: symbol `loop' is already defined

It's reproducible with clang as well, on Compiler explorer. See this reproducer for gcc: https://godbolt.org/z/7d9MEfdh3

We applied the fix suggested by Jakub Jelinek in the gcc bug, and it fixed our issue. I guess it's fine applying to upstream valgrind too. I will attach the patch to this bug report.

Cheers,
Romain
Comment 1 Mark Wielaard 2025-09-04 13:49:21 UTC
Thanks, looks good. Updated NEWS and pushed as:

commit fc9bb3a0e4c1325b0ff428cddacea0947e945c67
Author: Romain Geissler <romain.geissler@amadeus.com>
Date:   Thu Sep 4 12:10:12 2025 +0000

    Fix compilation of tests/arm64/bug484935.c when using fat LTO.
    
    See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121719
    
    Fix this error:
    /tmp/ccfnh7KQ.s: Assembler messages:
    /tmp/ccfnh7KQ.s:175: Error: symbol `loop' is already defined