From: Thomas Petazzoni via buildroot <buildroot@buildroot.org>
To: Yegor Yefremov <yegorslists@googlemail.com>
Cc: buildroot@buildroot.org
Subject: Re: [Buildroot] [PATCH v2] package/valgrind: fix build with a libgcc built without optimization
Date: Thu, 22 Oct 2026 11:32:18 +0200 [thread overview]
Message-ID: <atnYHB0ChkKie60F@windsurf> (raw)
In-Reply-To: <20261022075734.2659243-1-yegorslists@googlemail.com>
On Thu, Oct 22, 2026 at 09:57:34AM +0200, Yegor Yefremov via buildroot wrote:
> The 64 bit division helpers of libgcc (__divdi3 and friends) are
> compiled with -fexceptions -fnon-call-exceptions. Buildroot passes
> TARGET_CFLAGS to gcc through CFLAGS_FOR_TARGET, so with BR2_OPTIMIZE_0
> libgcc itself is built with -O0. GCC then keeps the (empty) exception
> landing pads in those objects, which therefore reference
> _Unwind_Resume() and __gcc_personality_v0(), normally provided by
> libgcc_eh.a. Valgrind links its tools with -nodefaultlibs, so that
> library is not available and the link fails on 32 bit targets:
>
> ld: libgcc.a(_divdi3.o): in function `__divdi3':
> libgcc2.c:1226: undefined reference to `_Unwind_Resume'
> ld: libgcc.a(_divdi3.o):(.data.rel.local.DW.ref.__gcc_personality_v0[DW.ref.__gcc_personality_v0]+0x0):
> undefined reference to `__gcc_personality_v0'
> collect2: error: ld returned 1 exit status
> make[4]: *** [Makefile:1180: memcheck-x86-linux] Error 1
>
> Backport the upstream commit providing dummy definitions of both
> symbols in libgcc-sup-<platform>.a, which is linked after -lgcc, so
> toolchains providing the real symbols are unaffected. They can never be
> reached, as Valgrind's core is plain C and never raises an exception.
>
> This issue has been present since commit 0fe633cdff66 ("gcc: explicitly
> use C{XX}FLAGS_FOR_TARGET instead of --enable-target-optspace"), which
> started building the gcc target libraries with TARGET_CFLAGS, and thus
> with -O0 when BR2_OPTIMIZE_0 is enabled, instead of -Os. This is not a
> gcc regression: both gcc 11 and gcc 15 emit these landing pads at -O0.
> It therefore affects 2015.08 and later, including 2025.02.x and
> 2026.02.x.
>
> Fixes:
> https://autobuild.buildroot.org/results/4a58c34308095e4d8ae91e0a779c94123ee497f6
>
> Fixes: 0fe633cdff66febadc50bab3e0af4b3be53811c8 ("gcc: explicitly use C{XX}FLAGS_FOR_TARGET instead of --enable-target-optspace")
> Assisted-by: Claude:claude-opus-5-5
> Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Applied to master, thanks!
Best regards,
Thomas Petazzoni
--
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
prev parent reply other threads:[~2026-10-22 9:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-22 10:53 [Buildroot] [PATCH] package/valgrind: fix build with a libgcc built without optimization Yegor Yefremov via buildroot
2026-10-22 7:57 ` [Buildroot] [PATCH v2] " Yegor Yefremov via buildroot
2026-10-22 9:32 ` Thomas Petazzoni via buildroot [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=atnYHB0ChkKie60F@windsurf \
--to=buildroot@buildroot.org \
--cc=thomas.petazzoni@bootlin.com \
--cc=yegorslists@googlemail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox