package/musl: fix build for POWER10 and later
PATCH 1/1 package/musl: fix build for POWER10 and later
When targeting POWER10 or POWER11, gcc generates pc-relative code by default, and the resulting C functions do not preserve the TOC pointer. musl's powerpc64 assembly calls or tail-calls C functions assuming the TOC-based ABI (bl without a following nop in crt_arch.h, b __dlsym in dlsym.s, b __setjmp_toc in setjmp.s/sigsetjmp.s), so the linker cannot insert the needed TOC save/restore stubs and linking libc.so fails:
dlstart.c:(.text+0x24): call to `_dlstart_c' lacks nop, can't restore toc; (toc save/adjust stub)
ld: final link failed: bad value
Build musl with -mno-pcrel for POWER10 and POWER11, so musl itself is built as TOC-based code. Applications can still be built with pc-relative code and link against it.
The issue has been reported upstream [1], as musl does not accept AI-assisted patches.
This issue has been present since commit 3523e1ac79c1 ("arch/Config.in.powerpc: add Power10 CPU type"), which made it possible to build musl with -mcpu=power10 (and later power11, added by commit da1b45dd00fd ("arch/Config.in.powerpc: add Power11 CPU type")). It therefore affects 2026.08 and later, including 2026.08.x.
Fixes:
https://autobuild.buildroot.org/results/1342da7c9258a93eada96f92f53a643e316ce7f6
[1] https://www.openwall.com/lists/musl/2026/11/15/2
--- package/musl/musl.mk | 7 +++++++ 1 file changed, 7 insertions(+)
package/musl/musl.mk +7 -0
@@ -49,6 +49,13 @@ ifeq ($(BR2_ARM_INSTRUCTIONS_THUMB),y) MUSL_EXTRA_CFLAGS += -marm endif +# The powerpc64 assembly code assumes TOC-based C code, but gcc +# generates pc-relative code by default for POWER10 and later, which +# makes linking libc.so fail. +ifeq ($(BR2_powerpc_power10)$(BR2_powerpc_power11),y) +MUSL_EXTRA_CFLAGS += -mno-pcrel +endif + define MUSL_CONFIGURE_CMDS (cd $(@D); \ $(TARGET_CONFIGURE_OPTS) \
Signature · 6 lines
2.34.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Thomas Petazzoni via buildroot
AppliedQuoted 23 lines · Yegor Yefremov
When targeting POWER10 or POWER11, gcc generates pc-relative code by default, and the resulting C functions do not preserve the TOC pointer. musl's powerpc64 assembly calls or tail-calls C functions assuming the TOC-based ABI (bl without a following nop in
crt_arch.h, b__dlsymin dlsym.s, b__setjmp_tocinsetjmp.s/sigsetjmp.s), so the linker cannot insert the needed TOC save/restore stubs and linking libc.so fails:dlstart.c:(.text+0x24): call to `_dlstart_c' lacks nop, can't restore toc; (toc save/adjust stub)
ld: final link failed: bad valueBuild musl with -mno-pcrel for POWER10 and POWER11, so musl itself is built as TOC-based code. Applications can still be built with pc-relative code and link against it.
The issue has been reported upstream [1], as musl does not accept AI-assisted patches.
This issue has been present since commit
3523e1ac79c1("arch/Config.in.powerpc: add Power10 CPU type"), which made it possible to build musl with -mcpu=power10 (and later power11, added by commitda1b45dd00fd("arch/Config.in.powerpc: add Power11 CPU type")). It therefore affects 2026.08 and later, including 2026.08.x.
Quoted 4 lines
Fixes:
https://autobuild.buildroot.org/results/1342da7c9258a93eada96f92f53a643e316ce7f6
Funnily enough, I had already reported the issue to upstream musl:
https://www.openwall.com/lists/musl/2026/11/05/3
Quoted 3 lines
Fixes 3523e1ac79c15c5199a15589692e269191abd546 ("arch/Config.in.powerpc: add Power10 CPU type")Assisted-by Claude:claude-opus-5-5Signed-off-by Yegor Yefremov <[email protected]>
Applied to master, thanks!
Thomas
Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Raphaël Mélotte via buildroot
AppliedIn reply of:
Quoted 23 lines
When targeting POWER10 or POWER11, gcc generates pc-relative code by default, and the resulting C functions do not preserve the TOC pointer. musl's powerpc64 assembly calls or tail-calls C functions assuming the TOC-based ABI (bl without a following nop in
crt_arch.h, b__dlsymin dlsym.s, b__setjmp_tocinsetjmp.s/sigsetjmp.s), so the linker cannot insert the needed TOC save/restore stubs and linking libc.so fails:dlstart.c:(.text+0x24): call to `_dlstart_c' lacks nop, can't restore toc; (toc save/adjust stub)
ld: final link failed: bad valueBuild musl with -mno-pcrel for POWER10 and POWER11, so musl itself is built as TOC-based code. Applications can still be built with pc-relative code and link against it.
The issue has been reported upstream [1], as musl does not accept AI-assisted patches.
This issue has been present since commit
3523e1ac79c1("arch/Config.in.powerpc: add Power10 CPU type"), which made it possible to build musl with -mcpu=power10 (and later power11, added by commitda1b45dd00fd("arch/Config.in.powerpc: add Power11 CPU type")). It therefore affects 2026.08 and later, including 2026.08.x.
Quoted 8 lines
Fixes:
https://autobuild.buildroot.org/results/1342da7c9258a93eada96f92f53a643e316ce7f6[1] https://www.openwall.com/lists/musl/2026/11/15/2
Fixes 3523e1ac79c15c5199a15589692e269191abd546 ("arch/Config.in.powerpc: add Power10 CPU type")Assisted-by Claude:claude-opus-5-5Signed-off-by Yegor Yefremov <[email protected]>
Applied to 2026.08.x. Thanks
Quoted 12 lines
--- package/musl/musl.mk | 7 +++++++ 1 file changed, 7 insertions(+)package/musl/musl.mk +0
-0@@ -49,6 +49,13 @@ ifeq ($(BR2_ARM_INSTRUCTIONS_THUMB),y) MUSL_EXTRA_CFLAGS += -marm endif
package/musl/musl.mk ifeq ($(BR2_ARM_INSTRUCTIONS_THUMB),y) · line 61
Quoted 10 lines
package/musl/musl.mk +7
-0+# The powerpc64 assembly code assumes TOC-based C code, but gcc +# generates pc-relative code by default for POWER10 and later, which +# makes linking libc.so fail. +ifeq ($(BR2_powerpc_power10)$(BR2_powerpc_power11),y) +MUSL_EXTRA_CFLAGS += -mno-pcrel +endif + define MUSL_CONFIGURE_CMDS (cd $(@D); \ $(TARGET_CONFIGURE_OPTS) \
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot