From bc5042f1d1085bb9e9f8ca87a02c093ecd20857e Mon Sep 17 00:00:00 2001 From: Fengwei Tan Date: Tue, 18 Aug 2026 02:17:29 +0800 Subject: [PATCH] package/Makefile.in: fix support for $(PKG)_FLAT_STACKSIZE When a package defines $(PKG)_FLAT_STACKSIZE, ELF2FLT_FLAGS contains -Wl,-elf2flt="-r -s". 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 ..." as a command instead of passing it to the compiler. Pass -r and -s in separate -Wl arguments instead. This avoids embedded quotes; GCC forwards both -elf2flt options to ld-elf2flt, which collects them before invoking elf2flt. This got broken by commit 04d7ea4720cbc1e9c4d7ec6307aff71567b0653d ("package: Makefile.in: fix elf2flt invocation options"), which by adding -r as an elf2flt argument, did not correctly handle -s$($(PKG)_FLAT_STACKSIZE). Signed-off-by: Fengwei Tan [Thomas: improve commit message] Signed-off-by: Thomas Petazzoni (cherry picked from commit e913afbeb1ad67ba43829aee94d01d8ca32120fe) Signed-off-by: Titouan Christophe --- package/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/Makefile.in b/package/Makefile.in index 829636900b..5a1c4fa63c 100644 --- a/package/Makefile.in +++ b/package/Makefile.in @@ -210,7 +210,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)