Skip to contentSkip to conversation

Makefile: Only enable --print-gc-section for verbose(V=1) build

PATCH Applied Rahul Pathak 2 participants 2 messages Nov 10, 2025 – Dec 1, 2025 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Makefile: Only enable --print-gc-section for verbose(V=1) build

Earlier this option was enabled during debug build which only prints the linker logs of removing the unused sections. Instead enable this for V=1 and keep the debug build clean.

---
 Makefile | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
Makefile +4 -1
index 398eabe8c964..da7976d5efbb 100644
@@ -444,11 +444,14 @@ DTSCPPFLAGS	=	$(CPPFLAGS) -nostdinc -nostdlib -fno-builtin -D__DTS__ -x assemble
 
 ifneq ($(DEBUG),)
 CFLAGS		+=	-O0
-ELFFLAGS	+=	-Wl,--print-gc-sections
 else
 CFLAGS		+=	-O2
 endif
 
+ifeq ($(V), 1)
+ELFFLAGS	+=	-Wl,--print-gc-sections
+endif
+
 # Setup functions for compilation
 define dynamic_flags
 -I$(shell dirname $(2)) -D__OBJNAME__=$(subst -,_,$(shell basename $(1) .o))
Signature · 7 lines
2.48.1


-- 
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi
Reviewed-by on v1 1/1 Applied
#1 lore raw
Quoted 8 lines · Rahul Pathak

Earlier this option was enabled during debug build which only prints the linker logs of removing the unused sections. Instead enable this for V=1 and keep the debug build clean.

LGTM.

Applied this patch to the riscv/opensbi repo.

Thanks,
Anup

Quoted 32 lines
---
 Makefile | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
Makefile +4 -2
index 398eabe8c964..da7976d5efbb 100644
@@ -444,11 +444,14 @@ DTSCPPFLAGS       =       $(CPPFLAGS) -nostdinc -nostdlib -fno-builtin -D__DTS__ -x assemble
 
 ifneq ($(DEBUG),)
 CFLAGS         +=      -O0
-ELFFLAGS       +=      -Wl,--print-gc-sections
 else
 CFLAGS         +=      -O2
 endif
 
+ifeq ($(V), 1)
+ELFFLAGS       +=      -Wl,--print-gc-sections
+endif
+
 # Setup functions for compilation
 define dynamic_flags
 -I$(shell dirname $(2)) -D__OBJNAME__=$(subst -,_,$(shell basename $(1) .o))
--

2.48.1

--
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi

Signature · 3 lines
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi