Skip to content

Commit

Permalink
kbuild: allow assignment to {A,C}FLAGS_KERNEL on the command line
Browse files Browse the repository at this point in the history
It is now possible to assign options to AS and CC
on the command line - which is only used for built-in code.

{A,C}FLAGS_KERNEL was used both in the top-level Makefile
in the arch makefiles, thus users had no way to specify
additional options to AS, CC without overriding
the original value.

Introduce a new set of variables KBUILD_{A,C}FLAGS_KERNEL
that is used by arch specific files and free up
{A,C}FLAGS_KERNEL so they can be assigned on
the command line.

All arch Makefiles that used the old variables has been updated.

Signed-off-by: Sam Ravnborg <[email protected]>
Cc: Tony Luck <[email protected]>
Cc: Hirokazu Takata <[email protected]>
Signed-off-by: Michal Marek <[email protected]>
  • Loading branch information
sravnborg authored and michal42 committed Aug 3, 2010
1 parent 6588169 commit 80c00ba
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 7 deletions.
10 changes: 10 additions & 0 deletions Documentation/kbuild/kbuild.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,20 @@ AFLAGS_MODULE
--------------------------------------------------
Addtional module specific options to use for $(AS).

AFLAGS_KERNEL
--------------------------------------------------
Addtional options for $(AS) when used for assembler
code for code that is compiled as built-in.

KCFLAGS
--------------------------------------------------
Additional options to the C compiler (for built-in and modules).

CFLAGS_KERNEL
--------------------------------------------------
Addtional options for $(CC) when used to compile
code that is compiled as built-in.

CFLAGS_MODULE
--------------------------------------------------
Addtional module specific options to use for $(CC).
Expand Down
9 changes: 7 additions & 2 deletions Documentation/kbuild/makefiles.txt
Original file line number Diff line number Diff line change
Expand Up @@ -923,9 +923,9 @@ When kbuild executes, the following steps are followed (roughly):
The first example utilises the trick that a config option expands
to 'y' when selected.

CFLAGS_KERNEL $(CC) options specific for built-in
KBUILD_AFLAGS_KERNEL $(AS) options specific for built-in

$(CFLAGS_KERNEL) contains extra C compiler flags used to compile
$(KBUILD_AFLAGS_KERNEL) contains extra C compiler flags used to compile
resident kernel code.

KBUILD_AFLAGS_MODULE Options for $(AS) when building modules
Expand All @@ -934,6 +934,11 @@ When kbuild executes, the following steps are followed (roughly):
are used for $(AS).
From commandline AFLAGS_MODULE shall be used (see kbuild.txt).

KBUILD_CFLAGS_KERNEL $(CC) options specific for built-in

$(KBUILD_CFLAGS_KERNEL) contains extra C compiler flags used to compile
resident kernel code.

KBUILD_CFLAGS_MODULE Options for $(CC) when building modules

$(KBUILD_CFLAGS_MODULE) is used to add arch specific options that
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,8 @@ KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
-Werror-implicit-function-declaration \
-Wno-format-security \
-fno-delete-null-pointer-checks
KBUILD_AFLAGS_KERNEL :=
KBUILD_CFLAGS_KERNEL :=
KBUILD_AFLAGS := -D__ASSEMBLY__
KBUILD_AFLAGS_MODULE := -DMODULE
KBUILD_CFLAGS_MODULE := -DMODULE
Expand All @@ -372,6 +374,7 @@ export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS
export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE CFLAGS_GCOV
export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE
export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL

# When compiling out-of-tree modules, put MODVERDIR in the module
# tree rather than in the kernel tree. The kernel tree might
Expand Down Expand Up @@ -1481,6 +1484,7 @@ cmd_crmodverdir = $(Q)mkdir -p $(MODVERDIR) \
$(if $(KBUILD_MODULES),; rm -f $(MODVERDIR)/*)

a_flags = -Wp,-MD,$(depfile) $(KBUILD_AFLAGS) $(AFLAGS_KERNEL) \
$(KBUILD_AFLAGS_KERNEL) \
$(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(KBUILD_CPPFLAGS) \
$(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(basetarget).o)

Expand Down
4 changes: 2 additions & 2 deletions arch/ia64/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ CHECKFLAGS += -m64 -D__ia64=1 -D__ia64__=1 -D_LP64 -D__LP64__
OBJCOPYFLAGS := --strip-all
LDFLAGS_vmlinux := -static
KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/ia64/module.lds
AFLAGS_KERNEL := -mconstant-gp
KBUILD_AFLAGS_KERNEL := -mconstant-gp
EXTRA :=

cflags-y := -pipe $(EXTRA) -ffixed-r13 -mfixed-range=f12-f15,f32-f127 \
-falign-functions=32 -frename-registers -fno-optimize-sibling-calls
CFLAGS_KERNEL := -mconstant-gp
KBUILD_CFLAGS_KERNEL := -mconstant-gp

GAS_STATUS = $(shell $(srctree)/arch/ia64/scripts/check-gas "$(CC)" "$(OBJDUMP)")
KBUILD_CPPFLAGS += $(shell $(srctree)/arch/ia64/scripts/toolchain-flags "$(CC)" "$(OBJDUMP)" "$(READELF)")
Expand Down
2 changes: 1 addition & 1 deletion arch/m32r/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ OBJCOPYFLAGS := -O binary -R .note -R .comment -S
LDFLAGS_vmlinux :=

KBUILD_CFLAGS += -pipe -fno-schedule-insns
CFLAGS_KERNEL += -mmodel=medium
KBUILD_CFLAGS_KERNEL += -mmodel=medium
KBUILD_CFLAGS_MODULE += -mmodel=large

ifdef CONFIG_CHIP_VDEC2
Expand Down
4 changes: 2 additions & 2 deletions scripts/Makefile.build
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ endif
modkern_cflags = \
$(if $(part-of-module), \
$(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE), \
$(CFLAGS_KERNEL))
$(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL))
quiet_modtag := $(empty) $(empty)

$(real-objs-m) : part-of-module := y
Expand Down Expand Up @@ -251,7 +251,7 @@ $(obj)/%.lst: $(src)/%.c FORCE
# Compile assembler sources (.S)
# ---------------------------------------------------------------------------

modkern_aflags := $(AFLAGS_KERNEL)
modkern_aflags := $(KBUILD_AFLAGS_KERNEL) $(AFLAGS_KERNEL)

$(real-objs-m) : modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE)
$(real-objs-m:.o=.s): modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE)
Expand Down

0 comments on commit 80c00ba

Please sign in to comment.