* [Buildroot] [PATCH] package: fix builds with $(PKG)_FLAT_STACKSIZE
@ 2026-08-17 18:17 Fengwei Tan
2026-08-20 19:20 ` Thomas Petazzoni via buildroot
0 siblings, 1 reply; 6+ messages in thread
From: Fengwei Tan @ 2026-08-17 18:17 UTC (permalink / raw)
To: buildroot; +Cc: Fengwei Tan
When a package defines $(PKG)_FLAT_STACKSIZE, ELF2FLT_FLAGS contains
-Wl,-elf2flt="-r -s<stack-size>". The embedded quotes are needed to
keep both elf2flt options in single linker argument.
However, many package Makefiles wrap $(TARGET_CFLAGS) in double quotes,
for example:
CFLAGS="$(TARGET_CFLAGS)"
After expansion, the embedded quote terminates the outer CFLAGS quote.
As a result, the shell interprets "-s<stack-size> ..." as a command
instead of passing it to the compiler.
Pass -r and -s<stack-size> in separate -Wl arguments instead. This
avoids embedded quotes; GCC forwards both -elf2flt options to
ld-elf2flt, which collects them before invoking elf2flt.
Signed-off-by: Fengwei Tan <tfx2001@outlook.com>
---
package/Makefile.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package/Makefile.in b/package/Makefile.in
index eac28b3a96..229206d393 100644
--- a/package/Makefile.in
+++ b/package/Makefile.in
@@ -218,7 +218,7 @@ ifeq ($(BR2_riscv),y)
TARGET_CFLAGS += -fPIC
endif
ELF2FLT_FLAGS = $(if $($(PKG)_FLAT_STACKSIZE),\
- -Wl$(comma)-elf2flt="-r -s$($(PKG)_FLAT_STACKSIZE)",\
+ -Wl$(comma)-elf2flt=-r -Wl$(comma)-elf2flt=-s$($(PKG)_FLAT_STACKSIZE),\
-Wl$(comma)-elf2flt=-r)
TARGET_CFLAGS += $(ELF2FLT_FLAGS)
TARGET_CXXFLAGS += $(ELF2FLT_FLAGS)
--
2.43.0
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [Buildroot] [PATCH] package: fix builds with $(PKG)_FLAT_STACKSIZE
2026-08-17 18:17 [Buildroot] [PATCH] package: fix builds with $(PKG)_FLAT_STACKSIZE Fengwei Tan
@ 2026-08-20 19:20 ` Thomas Petazzoni via buildroot
2026-08-21 17:26 ` Fengwei Tan
0 siblings, 1 reply; 6+ messages in thread
From: Thomas Petazzoni via buildroot @ 2026-08-20 19:20 UTC (permalink / raw)
To: Fengwei Tan; +Cc: buildroot
Hello!
On Tue, Aug 18, 2026 at 02:17:29AM +0800, Fengwei Tan wrote:
> When a package defines $(PKG)_FLAT_STACKSIZE, ELF2FLT_FLAGS contains
> -Wl,-elf2flt="-r -s<stack-size>". The embedded quotes are needed to
> keep both elf2flt options in single linker argument.
>
> However, many package Makefiles wrap $(TARGET_CFLAGS) in double quotes,
> for example:
>
> CFLAGS="$(TARGET_CFLAGS)"
>
> After expansion, the embedded quote terminates the outer CFLAGS quote.
> As a result, the shell interprets "-s<stack-size> ..." as a command
> instead of passing it to the compiler.
>
> Pass -r and -s<stack-size> in separate -Wl arguments instead. This
> avoids embedded quotes; GCC forwards both -elf2flt options to
> ld-elf2flt, which collects them before invoking elf2flt.
>
> Signed-off-by: Fengwei Tan <tfx2001@outlook.com>
Thanks a lot for your patch, well spotted!
One thing that was missing from your commit message is the indication
of which commit broke this, so I added that and applied your commit to
our master branch.
This feature is not actually used by any package in Buildroot, which
explains why this problem remained unnoticed. Would you be willing to
work on adding a simple test case in support/testing/ for this? I
guess it could be a very simple br2-external, with a very simple
package that uses <pkg>_FLAT_STACKSIZE.
Aside from that, no many of our users use Buildroot for noMMU
platforms. Would you mind sharing your use case? Which platform are
you using, in which context, how did you end up running into this
<pkg>_FLAT_STACKSIZE issue?
Again, thanks for your contribution!
Thomas
--
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Buildroot] [PATCH] package: fix builds with $(PKG)_FLAT_STACKSIZE
2026-08-20 19:20 ` Thomas Petazzoni via buildroot
@ 2026-08-21 17:26 ` Fengwei Tan
2026-08-21 20:24 ` Thomas Petazzoni via buildroot
0 siblings, 1 reply; 6+ messages in thread
From: Fengwei Tan @ 2026-08-21 17:26 UTC (permalink / raw)
To: Thomas Petazzoni; +Cc: Fengwei Tan, buildroot
Hi Thomas,
Thank you for taking the time to review my patch!
On Thu, Aug 20, 2026 at 09:20:00PM +0200, Thomas Petazzoni wrote:
> Thanks a lot for your patch, well spotted!
>
> One thing that was missing from your commit message is the indication
> of which commit broke this, so I added that and applied your commit to
> our master branch.
>
> This feature is not actually used by any package in Buildroot, which
> explains why this problem remained unnoticed. Would you be willing to
> work on adding a simple test case in support/testing/ for this? I
> guess it could be a very simple br2-external, with a very simple
> package that uses <pkg>_FLAT_STACKSIZE.
Sure. I would be glad to add a test case for this, and I will send it as
a separate patch.
>
> Aside from that, no many of our users use Buildroot for noMMU
> platforms. Would you mind sharing your use case? Which platform are
> you using, in which context, how did you end up running into this
> <pkg>_FLAT_STACKSIZE issue?
I am working on a fork of Buildroot for HPMicro MCUs:
https://github.com/hpm-rs/buildroot
I have ported Linux to a new RISC-V MCU called HPM6750 from HPMicro
Semiconductor Ltd., and I am adding board support for it to Buildroot.
I ran into this problem when trying to run FFmpeg on it. Initially, it
failed with a "stack smashing detected" error. To resolve this, I
attempted to use FFMPEG_FLAT_STACKSIZE to allocate a larger FLAT stack,
which led me to discover the build failure caused by this bug.
>
> Again, thanks for your contribution!
>
> Thomas
> --
> 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Buildroot] [PATCH] package: fix builds with $(PKG)_FLAT_STACKSIZE
2026-08-21 17:26 ` Fengwei Tan
@ 2026-08-21 20:24 ` Thomas Petazzoni via buildroot
2026-08-22 9:14 ` Fengwei Tan
0 siblings, 1 reply; 6+ messages in thread
From: Thomas Petazzoni via buildroot @ 2026-08-21 20:24 UTC (permalink / raw)
To: Fengwei Tan; +Cc: buildroot
Hello,
On Sat, Aug 22, 2026 at 01:26:13AM +0800, Fengwei Tan wrote:
> Sure. I would be glad to add a test case for this, and I will send it as
> a separate patch.
Excellent, thanks!
> I am working on a fork of Buildroot for HPMicro MCUs:
> https://github.com/hpm-rs/buildroot
>
> I have ported Linux to a new RISC-V MCU called HPM6750 from HPMicro
> Semiconductor Ltd., and I am adding board support for it to Buildroot.
>
> I ran into this problem when trying to run FFmpeg on it. Initially, it
> failed with a "stack smashing detected" error. To resolve this, I
> attempted to use FFMPEG_FLAT_STACKSIZE to allocate a larger FLAT stack,
> which led me to discover the build failure caused by this bug.
Nice! To be honest I had never heard of HPMicro, so it's nice to
discover.
Do not hesitate to send patches to add support for your
platform(s). However, for this, we will require that the support for
your platform is also in the upstream Linux kernel: we don't want to
carry dozens/hundreds of platform-specific patches in Buildroot.
But aside from your platform-specific support, do not hesitate to
submit any noMMU fixes you might have, like the one you already
submitted.
Thanks a lot!
Thomas
--
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Buildroot] [PATCH] package: fix builds with $(PKG)_FLAT_STACKSIZE
2026-08-21 20:24 ` Thomas Petazzoni via buildroot
@ 2026-08-22 9:14 ` Fengwei Tan
2026-08-22 9:23 ` Thomas Petazzoni via buildroot
0 siblings, 1 reply; 6+ messages in thread
From: Fengwei Tan @ 2026-08-22 9:14 UTC (permalink / raw)
To: Thomas Petazzoni; +Cc: buildroot
Hi Thomas,
在 2026/8/22 04:24, Thomas Petazzoni 写道:
>> I am working on a fork of Buildroot for HPMicro MCUs:
>> https://github.com/hpm-rs/buildroot
>>
>> I have ported Linux to a new RISC-V MCU called HPM6750 from HPMicro
>> Semiconductor Ltd., and I am adding board support for it to Buildroot.
>>
>> I ran into this problem when trying to run FFmpeg on it. Initially, it
>> failed with a "stack smashing detected" error. To resolve this, I
>> attempted to use FFMPEG_FLAT_STACKSIZE to allocate a larger FLAT stack,
>> which led me to discover the build failure caused by this bug.
>
> Nice! To be honest I had never heard of HPMicro, so it's nice to
> discover.
>
> Do not hesitate to send patches to add support for your
> platform(s). However, for this, we will require that the support for
> your platform is also in the upstream Linux kernel: we don't want to
> carry dozens/hundreds of platform-specific patches in Buildroot.
>
> But aside from your platform-specific support, do not hesitate to
> submit any noMMU fixes you might have, like the one you already
> submitted.
Since there is an ongoing discussion about removing noMMU support from
the Linux kernel[1], I do not plan to upstream the HPMicro platform
support there.
However, I will continue to submit any noMMU fixes to Buildroot whenever
I find them.
Thanks for your advice!
Best Regards,
Fengwei Tan
[1] https://lwn.net/Articles/1035727/
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Buildroot] [PATCH] package: fix builds with $(PKG)_FLAT_STACKSIZE
2026-08-22 9:14 ` Fengwei Tan
@ 2026-08-22 9:23 ` Thomas Petazzoni via buildroot
0 siblings, 0 replies; 6+ messages in thread
From: Thomas Petazzoni via buildroot @ 2026-08-22 9:23 UTC (permalink / raw)
To: Fengwei Tan; +Cc: buildroot
Hello,
On Sat, Aug 22, 2026 at 05:14:39PM +0800, Fengwei Tan wrote:
> Since there is an ongoing discussion about removing noMMU support from
> the Linux kernel[1], I do not plan to upstream the HPMicro platform
> support there.
Meh, OK. I think this is not really the right move from the upstream
Linux kernel maintainers, but oh well.
> However, I will continue to submit any noMMU fixes to Buildroot whenever
> I find them.
If support for noMMU is dropped from upstream Linux, there is a fairly
high chance that we will follow along and at some point also drop
support for noMMU in Buildroot. It makes no sense to have support in
Buildroot if upstream Linux doesn't support noMMU.
Best regards,
Thomas
--
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
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-08-22 9:24 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-17 18:17 [Buildroot] [PATCH] package: fix builds with $(PKG)_FLAT_STACKSIZE Fengwei Tan
2026-08-20 19:20 ` Thomas Petazzoni via buildroot
2026-08-21 17:26 ` Fengwei Tan
2026-08-21 20:24 ` Thomas Petazzoni via buildroot
2026-08-22 9:14 ` Fengwei Tan
2026-08-22 9:23 ` Thomas Petazzoni via buildroot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox