Skip to contentSkip to conversation

tools/bootconfig: allow overriding CFLAGS and LDFLAGS

PATCH In review Brian Masney 2 participants 6 messages Mar 28, 2025 – May 16, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover tools/bootconfig: allow overriding CFLAGS and LDFLAGS

Allow the user to override the CFLAGS and LDFLAGS similar to what's currently done on other kernel tools. These changes allows bootconfig to be compiled with the hardened compiler and linker flags.

Brian Masney (2):
tools/bootconfig: allow overriding CFLAGS assignment tools/bootconfig: specify LDFLAGS as an argument to CC

 tools/bootconfig/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.47.0
#1 lore raw

PATCH 1/2 tools/bootconfig: allow overriding CFLAGS assignment

Allow overriding the CFLAGS assignment so that the user can pass in an outside value.

---
 tools/bootconfig/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/bootconfig/Makefile +1 -1
index 566c3e0ee561..d2713902ca5c 100644
@@ -10,7 +10,7 @@ srctree := $(patsubst %/,%,$(dir $(srctree)))
 endif
 
 LIBSRC = $(srctree)/lib/bootconfig.c $(srctree)/include/linux/bootconfig.h
-CFLAGS = -Wall -g -I$(CURDIR)/include
+override CFLAGS += -Wall -g -I$(CURDIR)/include
 
 ALL_TARGETS := bootconfig
 ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS))
Signature · 1 line
2.47.0
#2 lore raw

PATCH 2/2 tools/bootconfig: specify LDFLAGS as an argument to CC

In reply to Brian Masney

Explicitly specify LDFLAGS as an argument to CC so that this can be overridden by the user.

---
 tools/bootconfig/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/bootconfig/Makefile +1 -1
index d2713902ca5c..90eb47c9d8de 100644
@@ -18,7 +18,7 @@ ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS))
 all: $(ALL_PROGRAMS) test
 
 $(OUTPUT)bootconfig: main.c include/linux/bootconfig.h $(LIBSRC)
-	$(CC) $(filter %.c,$^) $(CFLAGS) -o $@
+	$(CC) $(filter %.c,$^) $(CFLAGS) $(LDFLAGS) -o $@
 
 test: $(ALL_PROGRAMS) test-bootconfig.sh
 	./test-bootconfig.sh $(OUTPUT)
Signature · 1 line
2.47.0
#3 lore raw
In reply to Brian Masney
Quoted 8 lines · On Fri, 28 Mar 2025 14:38:56 -0400 Brian Masney <[email protected]> wrote:

Allow the user to override the CFLAGS and LDFLAGS similar to what's currently done on other kernel tools. These changes allows bootconfig to be compiled with the hardened compiler and linker flags.

Brian Masney (2):
tools/bootconfig: allow overriding CFLAGS assignment tools/bootconfig: specify LDFLAGS as an argument to CC

Both looks good to me. Let me pick those up.

Thanks!

Quoted 6 lines
 tools/bootconfig/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.47.0
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
#4 lore raw

Hi Masami,

Quoted 7 lines · Masami Hiramatsu
Quoted 4 lines · On Fri, 28 Mar 2025 14:38:56 -0400 Brian Masney <[email protected]> wrote:

Allow the user to override the CFLAGS and LDFLAGS similar to what's currently done on other kernel tools. These changes allows bootconfig to be compiled with the hardened compiler and linker flags.

Quoted 6 lines
Quoted 4 lines

Brian Masney (2):
tools/bootconfig: allow overriding CFLAGS assignment tools/bootconfig: specify LDFLAGS as an argument to CC

Both looks good to me. Let me pick those up.

Should these show up in linux-next by now? I see them in your tree at:

https://web.git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git/log/?h=bootconfig/tools

But not in the for-next branch.

Thanks,
Brian

#5 lore raw
In reply to Masami Hiramatsu (Google)
Quoted 7 lines · On Mon, 31 Mar 2025 21:23:37 +0900 Masami Hiramatsu (Google)…
Quoted 4 lines · On Fri, 28 Mar 2025 14:38:56 -0400 Brian Masney <[email protected]> wrote:

Allow the user to override the CFLAGS and LDFLAGS similar to what's currently done on other kernel tools. These changes allows bootconfig to be compiled with the hardened compiler and linker flags.

Quoted 7 lines
Quoted 4 lines

Brian Masney (2):
tools/bootconfig: allow overriding CFLAGS assignment tools/bootconfig: specify LDFLAGS as an argument to CC

Both looks good to me. Let me pick those up.

Sorry, somehow I missed these patches. I confirmed

tools/bootconfig$ make LDFLAGS=-static

passed the tests and it is statically linked! :)

tools/bootconfig$ file bootconfig
bootconfig: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, BuildID[sha1]=88323308c8d2cc45d1985ef94751bfd60199b32b, for GNU/Linux 3.2.0, with debug_info, not stripped

Thanks!

Quoted 12 lines

Thanks!

Quoted 6 lines
 tools/bootconfig/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.47.0
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>