Skip to content

Commit

Permalink
kbuild: Allow arch Makefiles to override {cpp,ld,c}flags
Browse files Browse the repository at this point in the history
Since commit a1c48bb (Makefile: Fix unrecognized cross-compiler command
line options), the arch Makefile is included earlier by the main
Makefile, preventing the arc architecture to set its -O3 compiler
option. Since there might be more use cases for an arch Makefile to
fine-tune the options, add support for ARCH_CPPFLAGS, ARCH_AFLAGS and
ARCH_CFLAGS variables that are appended to the respective kbuild
variables. The user still has the final say via the KCPPFLAGS, KAFLAGS
and KCFLAGS variables.

Reported-by: Vineet Gupta <[email protected]>
Cc: [email protected] # 3.16+
Signed-off-by: Michal Marek <[email protected]>
  • Loading branch information
michal42 authored and vineetgarc committed Jul 6, 2015
1 parent b607edd commit 61754c1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
8 changes: 8 additions & 0 deletions Documentation/kbuild/makefiles.txt
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,14 @@ When kbuild executes, the following steps are followed (roughly):
$(KBUILD_ARFLAGS) set by the top level Makefile to "D" (deterministic
mode) if this option is supported by $(AR).

ARCH_CPPFLAGS, ARCH_AFLAGS, ARCH_CFLAGS Overrides the kbuild defaults

These variables are appended to the KBUILD_CPPFLAGS,
KBUILD_AFLAGS, and KBUILD_CFLAGS, respectively, after the
top-level Makefile has set any other flags. This provides a
means for an architecture to override the defaults.


--- 6.2 Add prerequisites to archheaders:

The archheaders: rule is used to generate header files that
Expand Down
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -780,10 +780,11 @@ endif
include scripts/Makefile.kasan
include scripts/Makefile.extrawarn

# Add user supplied CPPFLAGS, AFLAGS and CFLAGS as the last assignments
KBUILD_CPPFLAGS += $(KCPPFLAGS)
KBUILD_AFLAGS += $(KAFLAGS)
KBUILD_CFLAGS += $(KCFLAGS)
# Add any arch overrides and user supplied CPPFLAGS, AFLAGS and CFLAGS as the
# last assignments
KBUILD_CPPFLAGS += $(ARCH_CPPFLAGS) $(KCPPFLAGS)
KBUILD_AFLAGS += $(ARCH_AFLAGS) $(KAFLAGS)
KBUILD_CFLAGS += $(ARCH_CFLAGS) $(KCFLAGS)

# Use --build-id when available.
LDFLAGS_BUILD_ID = $(patsubst -Wl$(comma)%,%,\
Expand Down

0 comments on commit 61754c1

Please sign in to comment.