Commit 69ee0b3522428a07ff1765446d631ecc7da6ae0f

Authored by Sam Ravnborg
1 parent b4f555081f

kbuild: do not pick up CFLAGS from the environment

Too many people have CFLAGS set to support building userspace.
And now Kbuild picks up CFLAGS this caused troubles.

Although people should realise that setting CFLAGS has
a 'global' effect the impact on the kernel build is a suprise.
So change kbuild to pick up value from KCFLAGS that is
much less used.

When kbuild pick up a value it will warn like this:
Makefile:544: "WARNING: Appending $KCFLAGS (-O3) from environment to kernel $CFLAGS"

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Thomas Bächler <thomas@archlinux.org>
Cc: David Miller <davem@davemloft.net>
Cc: Ingo Molnar <mingo@redhat.com>

Showing 1 changed file with 16 additions and 3 deletions Side-by-side Diff

... ... @@ -528,9 +528,22 @@
528 528 KBUILD_CFLAGS += $(call cc-option,-Wno-pointer-sign,)
529 529  
530 530 # Add user supplied CPPFLAGS, AFLAGS and CFLAGS as the last assignments
531   -KBUILD_CPPFLAGS += $(CPPFLAGS)
532   -KBUILD_AFLAGS += $(AFLAGS)
533   -KBUILD_CFLAGS += $(CFLAGS)
  531 +# But warn user when we do so
  532 +warn-assign = \
  533 +$(warning "WARNING: Appending $$K$(1) ($(K$(1))) from $(origin K$(1)) to kernel $$$(1)")
  534 +
  535 +ifneq ($(KCPPFLAGS),)
  536 + $(call warn-assign,CPPFLAGS)
  537 + KBUILD_CPPFLAGS += $(KCPPFLAGS)
  538 +endif
  539 +ifneq ($(KAFLAGS),)
  540 + $(call warn-assign,AFLAGS)
  541 + KBUILD_AFLAGS += $(KAFLAGS)
  542 +endif
  543 +ifneq ($(KCFLAGS),)
  544 + $(call warn-assign,CFLAGS)
  545 + KBUILD_CFLAGS += $(KCFLAGS)
  546 +endif
534 547  
535 548 # Use --build-id when available.
536 549 LDFLAGS_BUILD_ID = $(patsubst -Wl$(comma)%,%,\