2010-07-28 18:25:32

by Sam Ravnborg

[permalink] [raw]
Subject: [PATCH v2 0/3] update of various kbuild flags to allow user settings

Denys Vlasenko complained that he could not set
a moduel specific linker flags on the command line.

It turned out that the cause of this was kbuild
that assigned a value to a variables that
may be modified by the user.
So any user supplied value would overwrite
the kbuild assigned value.

Fix this so we use internal variables for kbuild
feering up the official variables for use by
the user.

Changes in v2:
Fix so we can now specify both module and built-in
options on command line.
Combine all *_MODULE changes in one patch.
Add a new patch for *_KERNEL changes.
Document the new variables in makefiles.txt
Document the variables that may be set on the command line
in kbuild.txt

The frv Makefile saw a bigger cleanup this time.
I suggest to merge it through kbuild.git because the
update is dependent on the first patch in this serie.

Sam


2010-07-28 18:27:20

by Sam Ravnborg

[permalink] [raw]
Subject: [PATCH 1/3] kbuild: allow assignment to {A,C,LD}FLAGS_MODULE on the command line

>From 40d7c77aeafa6b17503ffdcf58fa01411972b0d1 Mon Sep 17 00:00:00 2001
From: Sam Ravnborg <[email protected]>
Date: Wed, 28 Jul 2010 17:33:09 +0200
Subject: [PATCH 1/3] kbuild: allow assignment to {A,C,LD}FLAGS_MODULE on the command line

It is now possible to assign options to AS, CC and LD
on the command line - which is only used when building modules.

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

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

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

Note: Previously we had a MODFLAGS variable for both
AS and CC. But in favour of consistency this was dropped.
So in some cases arch Makefile has one assignmnet replaced by
two assignmnets.

Note2: MODFLAGS was not documented and is dropped
without any notice. I do not expect much/any breakage
from this.

Signed-off-by: Sam Ravnborg <[email protected]>
Cc: Denys Vlasenko <[email protected]>
Cc: Haavard Skinnemoen <[email protected]>
Cc: Mike Frysinger <[email protected]>
Cc: Tony Luck <[email protected]>
Cc: Geert Uytterhoeven <[email protected]>
Cc: Ralf Baechle <[email protected]>
Cc: Benjamin Herrenschmidt <[email protected]>
Cc: Martin Schwidefsky <[email protected]>
Cc: Chen Liqin <[email protected]>
---
Documentation/kbuild/kbuild.txt | 16 ++++++++++++++--
Documentation/kbuild/makefiles.txt | 18 +++++++++++++++---
Makefile | 13 ++++++++-----
arch/avr32/Makefile | 2 +-
arch/blackfin/Makefile | 4 ++--
arch/ia64/Makefile | 2 +-
arch/m32r/Makefile | 2 +-
arch/m68k/Makefile | 2 +-
arch/mips/Makefile | 6 ++++--
arch/powerpc/Makefile | 2 +-
arch/s390/Makefile | 3 ++-
arch/score/Makefile | 3 ++-
scripts/Makefile.build | 9 ++++++---
scripts/Makefile.modpost | 7 ++++---
14 files changed, 62 insertions(+), 27 deletions(-)

diff --git a/Documentation/kbuild/kbuild.txt b/Documentation/kbuild/kbuild.txt
index 634c625..d9c6554 100644
--- a/Documentation/kbuild/kbuild.txt
+++ b/Documentation/kbuild/kbuild.txt
@@ -22,11 +22,23 @@ building C files and assembler files.

KAFLAGS
--------------------------------------------------
-Additional options to the assembler.
+Additional options to the assembler (for built-in and modules).
+
+AFLAGS_MODULE
+--------------------------------------------------
+Addtional module specific options to use for $(AS).

KCFLAGS
--------------------------------------------------
-Additional options to the C compiler.
+Additional options to the C compiler (for built-in and modules).
+
+CFLAGS_MODULE
+--------------------------------------------------
+Addtional module specific options to use for $(CC).
+
+LDFLAGS_MODULE
+--------------------------------------------------
+Additional options used for $(LD) when linking modules.

KBUILD_VERBOSE
--------------------------------------------------
diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
index 71c602d..802341a 100644
--- a/Documentation/kbuild/makefiles.txt
+++ b/Documentation/kbuild/makefiles.txt
@@ -928,11 +928,23 @@ When kbuild executes, the following steps are followed (roughly):
$(CFLAGS_KERNEL) contains extra C compiler flags used to compile
resident kernel code.

- CFLAGS_MODULE $(CC) options specific for modules
+ KBUILD_AFLAGS_MODULE Options for $(AS) when building modules

- $(CFLAGS_MODULE) contains extra C compiler flags used to compile code
- for loadable kernel modules.
+ $(KBUILD_AFLAGS_MODULE) is used to add arch specific options that
+ are used for $(AS).
+ From commandline AFLAGS_MODULE shall be used (see kbuild.txt).

+ KBUILD_CFLAGS_MODULE Options for $(CC) when building modules
+
+ $(KBUILD_CFLAGS_MODULE) is used to add arch specific options that
+ are used for $(CC).
+ From commandline CFLAGS_MODULE shall be used (see kbuild.txt).
+
+ KBUILD_LDFLAGS_MODULE Options for $(LD) when linking modules
+
+ $(KBUILD_LDFLAGS_MODULE) is used to add arch specific options
+ used when linking modules. This is often a linker script.
+ From commandline LDFLAGS_MODULE shall be used (see kbuild.txt).

--- 6.2 Add prerequisites to archprepare:

diff --git a/Makefile b/Makefile
index a14c207..88447e7 100644
--- a/Makefile
+++ b/Makefile
@@ -332,10 +332,9 @@ CHECK = sparse

CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
-Wbitwise -Wno-return-void $(CF)
-MODFLAGS = -DMODULE
-CFLAGS_MODULE = $(MODFLAGS)
-AFLAGS_MODULE = $(MODFLAGS)
-LDFLAGS_MODULE = -T $(srctree)/scripts/module-common.lds
+CFLAGS_MODULE =
+AFLAGS_MODULE =
+LDFLAGS_MODULE =
CFLAGS_KERNEL =
AFLAGS_KERNEL =
CFLAGS_GCOV = -fprofile-arcs -ftest-coverage
@@ -355,6 +354,9 @@ KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
-Wno-format-security \
-fno-delete-null-pointer-checks
KBUILD_AFLAGS := -D__ASSEMBLY__
+KBUILD_AFLAGS_MODULE := -DMODULE
+KBUILD_CFLAGS_MODULE := -DMODULE
+KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds

# Read KERNELRELEASE from include/config/kernel.release (if it exists)
KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null)
@@ -369,6 +371,7 @@ export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS
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

# When compiling out-of-tree modules, put MODVERDIR in the module
# tree rather than in the kernel tree. The kernel tree might
@@ -607,7 +610,7 @@ endif
# Use --build-id when available.
LDFLAGS_BUILD_ID = $(patsubst -Wl$(comma)%,%,\
$(call cc-ldoption, -Wl$(comma)--build-id,))
-LDFLAGS_MODULE += $(LDFLAGS_BUILD_ID)
+KBUILD_LDFLAGS_MODULE += $(LDFLAGS_BUILD_ID)
LDFLAGS_vmlinux += $(LDFLAGS_BUILD_ID)

ifeq ($(CONFIG_STRIP_ASM_SYMS),y)
diff --git a/arch/avr32/Makefile b/arch/avr32/Makefile
index ead8a75..22fb665 100644
--- a/arch/avr32/Makefile
+++ b/arch/avr32/Makefile
@@ -13,7 +13,7 @@ KBUILD_DEFCONFIG := atstk1002_defconfig

KBUILD_CFLAGS += -pipe -fno-builtin -mno-pic
KBUILD_AFLAGS += -mrelax -mno-pic
-CFLAGS_MODULE += -mno-relax
+KBUILD_CFLAGS_MODULE += -mno-relax
LDFLAGS_vmlinux += --relax

cpuflags-$(CONFIG_PLATFORM_AT32AP) += -march=ap
diff --git a/arch/blackfin/Makefile b/arch/blackfin/Makefile
index 5a97a31..9d5ffaf 100644
--- a/arch/blackfin/Makefile
+++ b/arch/blackfin/Makefile
@@ -18,8 +18,8 @@ ifeq ($(CONFIG_ROMKERNEL),y)
KBUILD_CFLAGS += -mlong-calls
endif
KBUILD_AFLAGS += $(call cc-option,-mno-fdpic)
-CFLAGS_MODULE += -mlong-calls
-LDFLAGS_MODULE += -m elf32bfin
+KBUILD_CFLAGS_MODULE += -mlong-calls
+KBUILD_LDFLAGS_MODULE += -m elf32bfin
KALLSYMS += --symbol-prefix=_

KBUILD_DEFCONFIG := BF537-STAMP_defconfig
diff --git a/arch/ia64/Makefile b/arch/ia64/Makefile
index 8ae0d26..6a4807f 100644
--- a/arch/ia64/Makefile
+++ b/arch/ia64/Makefile
@@ -22,7 +22,7 @@ CHECKFLAGS += -m64 -D__ia64=1 -D__ia64__=1 -D_LP64 -D__LP64__

OBJCOPYFLAGS := --strip-all
LDFLAGS_vmlinux := -static
-LDFLAGS_MODULE += -T $(srctree)/arch/ia64/module.lds
+KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/ia64/module.lds
AFLAGS_KERNEL := -mconstant-gp
EXTRA :=

diff --git a/arch/m32r/Makefile b/arch/m32r/Makefile
index 469766b..14a3c23 100644
--- a/arch/m32r/Makefile
+++ b/arch/m32r/Makefile
@@ -13,7 +13,7 @@ LDFLAGS_vmlinux :=

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

ifdef CONFIG_CHIP_VDEC2
cflags-$(CONFIG_ISA_M32R2) += -DNO_FPU -Wa,-bitinst
diff --git a/arch/m68k/Makefile b/arch/m68k/Makefile
index 570d85c..b06a7e3 100644
--- a/arch/m68k/Makefile
+++ b/arch/m68k/Makefile
@@ -18,7 +18,7 @@ KBUILD_DEFCONFIG := multi_defconfig
# override top level makefile
AS += -m68020
LDFLAGS := -m m68kelf
-LDFLAGS_MODULE += -T $(srctree)/arch/m68k/kernel/module.lds
+KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/m68k/kernel/module.lds
ifneq ($(SUBARCH),$(ARCH))
ifeq ($(CROSS_COMPILE),)
CROSS_COMPILE := $(call cc-cross-prefix, \
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index 0b9c01a..f7139b2 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -93,7 +93,8 @@ all-$(CONFIG_SYS_SUPPORTS_ZBOOT)+= vmlinuz
cflags-y += -G 0 -mno-abicalls -fno-pic -pipe
cflags-y += -msoft-float
LDFLAGS_vmlinux += -G 0 -static -n -nostdlib
-MODFLAGS += -mlong-calls
+KBUILD_AFLAGS_MODULE += -mlong-calls
+KBUILD_CFLAGS_MODULE += -mlong-calls

cflags-y += -ffreestanding

@@ -185,7 +186,8 @@ cflags-$(CONFIG_CPU_DADDI_WORKAROUNDS) += $(call cc-option,-mno-daddi,)

ifdef CONFIG_CPU_SB1
ifdef CONFIG_SB1_PASS_1_WORKAROUNDS
-MODFLAGS += -msb1-pass1-workarounds
+KBUILD_AFLAGS_MODULE += -msb1-pass1-workarounds
+KBUILD_CFLAGS_MODULE += -msb1-pass1-workarounds
endif
endif

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 77cfe7a..5d42f5e 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -94,7 +94,7 @@ else
endif
endif

-LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o
+KBUILD_LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o

ifeq ($(CONFIG_TUNE_CELL),y)
KBUILD_CFLAGS += $(call cc-option,-mtune=cell)
diff --git a/arch/s390/Makefile b/arch/s390/Makefile
index 30c5f01..0c9e6c6 100644
--- a/arch/s390/Makefile
+++ b/arch/s390/Makefile
@@ -24,7 +24,8 @@ CHECKFLAGS += -D__s390__ -msize-long
else
LD_BFD := elf64-s390
LDFLAGS := -m elf64_s390
-MODFLAGS += -fpic -D__PIC__
+KBUILD_AFLAGS_MODULE += -fpic -D__PIC__
+KBUILD_CFLAGS_MODULE += -fpic -D__PIC__
KBUILD_CFLAGS += -m64
KBUILD_AFLAGS += -m64
UTS_MACHINE := s390x
diff --git a/arch/score/Makefile b/arch/score/Makefile
index 68e0cd0..d77dc63 100644
--- a/arch/score/Makefile
+++ b/arch/score/Makefile
@@ -20,7 +20,8 @@ cflags-y += -G0 -pipe -mel -mnhwloop -D__SCOREEL__ \
#
KBUILD_AFLAGS += $(cflags-y)
KBUILD_CFLAGS += $(cflags-y)
-MODFLAGS += -mlong-calls
+KBUILD_AFLAGS_MODULE += -mlong-calls
+KBUILD_CFLAGS_MODULE += -mlong-calls
LDFLAGS += --oformat elf32-littlescore
LDFLAGS_vmlinux += -G0 -static -nostdlib

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 390aae4..5e7c40e 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -115,7 +115,10 @@ endif
# ---------------------------------------------------------------------------

# Default is built-in, unless we know otherwise
-modkern_cflags = $(if $(part-of-module), $(CFLAGS_MODULE), $(CFLAGS_KERNEL))
+modkern_cflags = \
+ $(if $(part-of-module), \
+ $(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE), \
+ $(CFLAGS_KERNEL))
quiet_modtag := $(empty) $(empty)

$(real-objs-m) : part-of-module := y
@@ -250,8 +253,8 @@ $(obj)/%.lst: $(src)/%.c FORCE

modkern_aflags := $(AFLAGS_KERNEL)

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

quiet_cmd_as_s_S = CPP $(quiet_modtag) $@
cmd_as_s_S = $(CPP) $(a_flags) -o $@ $<
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
index 8f14c81..3e3f024 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -107,7 +107,7 @@ $(modules:.ko=.mod.c): __modpost ;
modname = $(notdir $(@:.mod.o=))

quiet_cmd_cc_o_c = CC $@
- cmd_cc_o_c = $(CC) $(c_flags) $(CFLAGS_MODULE) \
+ cmd_cc_o_c = $(CC) $(c_flags) $(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE) \
-c -o $@ $<

$(modules:.ko=.mod.o): %.mod.o: %.mod.c FORCE
@@ -117,8 +117,9 @@ targets += $(modules:.ko=.mod.o)

# Step 6), final link of the modules
quiet_cmd_ld_ko_o = LD [M] $@
- cmd_ld_ko_o = $(LD) -r $(LDFLAGS) $(LDFLAGS_MODULE) -o $@ \
- $(filter-out FORCE,$^)
+ cmd_ld_ko_o = $(LD) -r $(LDFLAGS) \
+ $(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \
+ -o $@ $(filter-out FORCE,$^)

$(modules): %.ko :%.o %.mod.o FORCE
$(call if_changed,ld_ko_o)
--
1.6.0.6

2010-07-28 18:28:09

by Sam Ravnborg

[permalink] [raw]
Subject: [PATCH 2/3] kbuild: allow assignment to {A,C}FLAGS_KERNEL on the command line

>From 4236ab8d726868df7a28132023e6b31e1d82e5b3 Mon Sep 17 00:00:00 2001
From: Sam Ravnborg <[email protected]>
Date: Wed, 28 Jul 2010 19:11:27 +0200
Subject: [PATCH 2/3] kbuild: allow assignment to {A,C}FLAGS_KERNEL on the command line

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]>
---
Documentation/kbuild/kbuild.txt | 10 ++++++++++
Documentation/kbuild/makefiles.txt | 9 +++++++--
Makefile | 4 ++++
arch/ia64/Makefile | 4 ++--
arch/m32r/Makefile | 2 +-
scripts/Makefile.build | 4 ++--
6 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/Documentation/kbuild/kbuild.txt b/Documentation/kbuild/kbuild.txt
index d9c6554..e903f20 100644
--- a/Documentation/kbuild/kbuild.txt
+++ b/Documentation/kbuild/kbuild.txt
@@ -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).
diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
index 802341a..5c878cc 100644
--- a/Documentation/kbuild/makefiles.txt
+++ b/Documentation/kbuild/makefiles.txt
@@ -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
@@ -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
diff --git a/Makefile b/Makefile
index 88447e7..2fb144e 100644
--- a/Makefile
+++ b/Makefile
@@ -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
@@ -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
@@ -1483,6 +1486,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)

diff --git a/arch/ia64/Makefile b/arch/ia64/Makefile
index 6a4807f..be7bfa1 100644
--- a/arch/ia64/Makefile
+++ b/arch/ia64/Makefile
@@ -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)")
diff --git a/arch/m32r/Makefile b/arch/m32r/Makefile
index 14a3c23..8ff5ba0 100644
--- a/arch/m32r/Makefile
+++ b/arch/m32r/Makefile
@@ -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
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 5e7c40e..a1a5cf9 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -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
@@ -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)
--
1.6.0.6

2010-07-28 18:29:01

by Sam Ravnborg

[permalink] [raw]
Subject: [PATCH 3/3] frv: clean up arch/frv/Makefile

>From 2193dfaff6e2260a3ac1d2f578616640d601db55 Mon Sep 17 00:00:00 2001
From: Sam Ravnborg <[email protected]>
Date: Wed, 28 Jul 2010 19:33:00 +0200
Subject: [PATCH 3/3] frv: clean up arch/frv/Makefile

- removed a lot of unused variable assignmnets
- removed unused bootstrap target
- replaced ARCHMODFLAGS with proper KBUILD_{A,C}FLAGS_MODULE assignmnets

The resuting Makefile has not been tested due to lack of toolchain,
but these were all trivial changes.

Signed-off-by: Sam Ravnborg <[email protected]>
Cc: David Howells <[email protected]>
---
arch/frv/Makefile | 22 ++--------------------
1 files changed, 2 insertions(+), 20 deletions(-)

diff --git a/arch/frv/Makefile b/arch/frv/Makefile
index 310c47a..7ff8457 100644
--- a/arch/frv/Makefile
+++ b/arch/frv/Makefile
@@ -23,20 +23,14 @@
# Copyright (C) 1994 by Hamish Macdonald
#

-CCSPECS := $(shell $(CC) -v 2>&1 | grep "^Reading specs from " | head -1 | cut -c20-)
-CCDIR := $(strip $(patsubst %/specs,%,$(CCSPECS)))
-CPUCLASS := fr400
-
-# test for cross compiling
-COMPILE_ARCH = $(shell uname -m)
-
ifdef CONFIG_MMU
UTS_SYSNAME = -DUTS_SYSNAME=\"Linux\"
else
UTS_SYSNAME = -DUTS_SYSNAME=\"uClinux\"
endif

-ARCHMODFLAGS += -G0 -mlong-calls
+KBUILD_AFLAGS_MODULE += -G0 -mlong-calls
+KBUILD_CFLAGS_MODULE += -G0 -mlong-calls

ifdef CONFIG_GPREL_DATA_8
KBUILD_CFLAGS += -G8
@@ -54,7 +48,6 @@ endif

ifdef CONFIG_GC_SECTIONS
KBUILD_CFLAGS += -ffunction-sections -fdata-sections
-LINKFLAGS += --gc-sections
endif

ifndef CONFIG_FRAME_POINTER
@@ -64,16 +57,13 @@ endif
ifdef CONFIG_CPU_FR451_COMPILE
KBUILD_CFLAGS += -mcpu=fr450
KBUILD_AFLAGS += -mcpu=fr450
-ASFLAGS += -mcpu=fr450
else
ifdef CONFIG_CPU_FR551_COMPILE
KBUILD_CFLAGS += -mcpu=fr550
KBUILD_AFLAGS += -mcpu=fr550
-ASFLAGS += -mcpu=fr550
else
KBUILD_CFLAGS += -mcpu=fr400
KBUILD_AFLAGS += -mcpu=fr400
-ASFLAGS += -mcpu=fr400
endif
endif

@@ -83,14 +73,12 @@ endif
KBUILD_CFLAGS += -mno-fdpic -mgpr-32 -msoft-float -mno-media
KBUILD_CFLAGS += -ffixed-fcc3 -ffixed-cc3 -ffixed-gr15 -ffixed-icc2
KBUILD_AFLAGS += -mno-fdpic
-ASFLAGS += -mno-fdpic

# make sure the .S files get compiled with debug info
# and disable optimisations that are unhelpful whilst debugging
ifdef CONFIG_DEBUG_INFO
#KBUILD_CFLAGS += -O1
KBUILD_AFLAGS += -Wa,--gdwarf2
-ASFLAGS += -Wa,--gdwarf2
endif

head-y := arch/frv/kernel/head.o arch/frv/kernel/init_task.o
@@ -105,11 +93,5 @@ all: Image
Image: vmlinux
$(Q)$(MAKE) $(build)=arch/frv/boot $@

-bootstrap:
- $(Q)$(MAKEBOOT) bootstrap
-
archclean:
$(Q)$(MAKE) $(clean)=arch/frv/boot
-
-archdep: scripts/mkdep symlinks
- $(Q)$(MAKE) $(build)=arch/frv/boot dep
--
1.6.0.6

2010-07-28 18:30:28

by Sam Ravnborg

[permalink] [raw]
Subject: Re: [PATCH v2 0/3] update of various kbuild flags to allow user settings

On Wed, Jul 28, 2010 at 08:25:23PM +0200, Sam Ravnborg wrote:
> Denys Vlasenko complained that he could not set
> a moduel specific linker flags on the command line.
>
> It turned out that the cause of this was kbuild
> that assigned a value to a variables that
> may be modified by the user.
> So any user supplied value would overwrite
> the kbuild assigned value.
>
> Fix this so we use internal variables for kbuild
> feering up the official variables for use by
> the user.
>
> Changes in v2:
> Fix so we can now specify both module and built-in
> options on command line.
> Combine all *_MODULE changes in one patch.
> Add a new patch for *_KERNEL changes.
> Document the new variables in makefiles.txt
> Document the variables that may be set on the command line
> in kbuild.txt
>
> The frv Makefile saw a bigger cleanup this time.
> I suggest to merge it through kbuild.git because the
> update is dependent on the first patch in this serie.

Forgot the stats:


Sam Ravnborg (3):
kbuild: allow assignment to {A,C,LD}FLAGS_MODULE on the command line
kbuild: allow assignment to {A,C}FLAGS_KERNEL on the command line
frv: clean up arch/frv/Makefile

Documentation/kbuild/kbuild.txt | 26 ++++++++++++++++++++++++--
Documentation/kbuild/makefiles.txt | 27 ++++++++++++++++++++++-----
Makefile | 17 ++++++++++++-----
arch/avr32/Makefile | 2 +-
arch/blackfin/Makefile | 4 ++--
arch/frv/Makefile | 22 ++--------------------
arch/ia64/Makefile | 6 +++---
arch/m32r/Makefile | 4 ++--
arch/m68k/Makefile | 2 +-
arch/mips/Makefile | 6 ++++--
arch/powerpc/Makefile | 2 +-
arch/s390/Makefile | 3 ++-
arch/score/Makefile | 3 ++-
scripts/Makefile.build | 11 +++++++----
scripts/Makefile.modpost | 7 ++++---
15 files changed, 89 insertions(+), 53 deletions(-)

2010-07-28 18:34:24

by Mike Frysinger

[permalink] [raw]
Subject: Re: [PATCH 1/3] kbuild: allow assignment to {A,C,LD}FLAGS_MODULE on the command line

On Wed, Jul 28, 2010 at 14:27, Sam Ravnborg wrote:
> --- a/arch/blackfin/Makefile
> +++ b/arch/blackfin/Makefile
> -CFLAGS_MODULE    += -mlong-calls
> -LDFLAGS_MODULE   += -m elf32bfin
> +KBUILD_CFLAGS_MODULE    += -mlong-calls
> +KBUILD_LDFLAGS_MODULE   += -m elf32bfin

Acked-by: Mike Frysinger <[email protected]>
-mike

2010-07-29 09:01:32

by Michal Marek

[permalink] [raw]
Subject: Re: [PATCH v2 0/3] update of various kbuild flags to allow user settings

On 28.7.2010 20:25, Sam Ravnborg wrote:
> Denys Vlasenko complained that he could not set
> a moduel specific linker flags on the command line.
>
> It turned out that the cause of this was kbuild
> that assigned a value to a variables that
> may be modified by the user.
> So any user supplied value would overwrite
> the kbuild assigned value.
>
> Fix this so we use internal variables for kbuild
> feering up the official variables for use by
> the user.

Acked-by: Michal Marek <[email protected]>

but I'll wait a while before applying it so that the arch maintainers
can object to / ack the arch-specific changes.

Michal

2010-07-29 09:26:41

by Haavard Skinnemoen

[permalink] [raw]
Subject: Re: [PATCH 1/3] kbuild: allow assignment to {A,C,LD}FLAGS_MODULE on the command line

Sam Ravnborg <[email protected]> wrote:
> diff --git a/arch/avr32/Makefile b/arch/avr32/Makefile
> index ead8a75..22fb665 100644
> --- a/arch/avr32/Makefile
> +++ b/arch/avr32/Makefile
> @@ -13,7 +13,7 @@ KBUILD_DEFCONFIG := atstk1002_defconfig
>
> KBUILD_CFLAGS += -pipe -fno-builtin -mno-pic
> KBUILD_AFLAGS += -mrelax -mno-pic
> -CFLAGS_MODULE += -mno-relax
> +KBUILD_CFLAGS_MODULE += -mno-relax
> LDFLAGS_vmlinux += --relax
>
> cpuflags-$(CONFIG_PLATFORM_AT32AP) += -march=ap

Acked-by: Haavard Skinnemoen <[email protected]>

2010-08-03 12:29:30

by Michal Marek

[permalink] [raw]
Subject: Re: [PATCH v2 0/3] update of various kbuild flags to allow user settings

On 29.7.2010 11:00, Michal Marek wrote:
> On 28.7.2010 20:25, Sam Ravnborg wrote:
>> Denys Vlasenko complained that he could not set
>> a moduel specific linker flags on the command line.
>>
>> It turned out that the cause of this was kbuild
>> that assigned a value to a variables that
>> may be modified by the user.
>> So any user supplied value would overwrite
>> the kbuild assigned value.
>>
>> Fix this so we use internal variables for kbuild
>> feering up the official variables for use by
>> the user.
>
> Acked-by: Michal Marek <[email protected]>
>
> but I'll wait a while before applying it so that the arch maintainers
> can object to / ack the arch-specific changes.

Applied. I'll be sending a pull request to Linus on Wednesday.

Michal