Thread (22 messages) 22 messages, 3 authors, 2024-06-10

Re: [PATCH v3 2/4] Makefile: add ability to append to CFLAGS and LDFLAGS

From: Jeff King <hidden>
Date: 2024-06-08 08:55:29
Subsystem: kernel build + files below scripts/ (unless maintained elsewhere), the rest · Maintainers: Nathan Chancellor, Nicolas Schier, Linus Torvalds

On Fri, Jun 07, 2024 at 08:46:34AM +0200, Patrick Steinhardt wrote:
Note that we have to use the `override` directive here such that the
flags get appended when compiling with `make CFLAGS=x CFLAGS_APPEND=y`.
Another way to do this is just:
diff --git a/Makefile b/Makefile
index 2f5f16847a..9cd3b252ff 100644
--- a/Makefile
+++ b/Makefile
@@ -1446,8 +1446,8 @@ ALL_COMMANDS_TO_INSTALL += git-upload-archive$(X)
 ALL_COMMANDS_TO_INSTALL += git-upload-pack$(X)
 endif
 
-ALL_CFLAGS = $(DEVELOPER_CFLAGS) $(CPPFLAGS) $(CFLAGS)
-ALL_LDFLAGS = $(LDFLAGS)
+ALL_CFLAGS = $(DEVELOPER_CFLAGS) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_APPEND)
+ALL_LDFLAGS = $(LDFLAGS) $(LDFLAGS_APPEND)
 
 ifdef SANITIZE
 SANITIZERS := $(foreach flag,$(subst $(comma),$(space),$(SANITIZE)),$(flag))
I can't think offhand of any way that your override would not do the
right thing, but:

 - this is roughly the same problem faced by DEVELOPER_CFLAGS, etc, so
   handling it in the same way makes sense to me

 - I always get nervous around make features like "override", as there
   are sometimes corner cases lurking

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help