Bug 509103 - tests/arm64/bug484935.c doesn't build if CFLAGS contain "-O2 -flto -ffat-lto-objects"
Summary: tests/arm64/bug484935.c doesn't build if CFLAGS contain "-O2 -flto -ffat-lto-...
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (other bugs)
Version First Reported In: unspecified
Platform: Other Other
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-09-04 12:12 UTC by Romain Geissler
Modified: 2025-09-04 13:49 UTC (History)
1 user (show)

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


Attachments
proposed patch (git format-patch format) (1020 bytes, patch)
2025-09-04 12:12 UTC, Romain Geissler
Details

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