aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Ravnborg <sam@ravnborg.org>2010-07-28 11:33:09 -0400
committerMichal Marek <mmarek@suse.cz>2010-08-03 08:09:45 -0400
commit6588169d516560f68672e2928680b71c647b7806 (patch)
tree91b20bf9197c718ff4b5830bb1aea0b1bc0de272
parentd6f4ceb796ebf1a8c8a9ad4a8ea0d181aaec7de6 (diff)
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 <sam@ravnborg.org> Cc: Denys Vlasenko <vda.linux@googlemail.com> Cc: Haavard Skinnemoen <hskinnemoen@atmel.com> Cc: Mike Frysinger <vapier@gentoo.org> Cc: Tony Luck <tony.luck@intel.com> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Cc: Ralf Baechle <ralf@linux-mips.org> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Chen Liqin <liqin.chen@sunplusct.com> Acked-by: Mike Frysinger <vapier@gentoo.org> [blackfin] Acked-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com> [avr32] Signed-off-by: Michal Marek <mmarek@suse.cz>
-rw-r--r--Documentation/kbuild/kbuild.txt16
-rw-r--r--Documentation/kbuild/makefiles.txt18
-rw-r--r--Makefile13
-rw-r--r--arch/avr32/Makefile2
-rw-r--r--arch/blackfin/Makefile4
-rw-r--r--arch/ia64/Makefile2
-rw-r--r--arch/m32r/Makefile2
-rw-r--r--arch/m68k/Makefile2
-rw-r--r--arch/mips/Makefile6
-rw-r--r--arch/powerpc/Makefile2
-rw-r--r--arch/s390/Makefile3
-rw-r--r--arch/score/Makefile3
-rw-r--r--scripts/Makefile.build9
-rw-r--r--scripts/Makefile.modpost7
14 files changed, 62 insertions, 27 deletions
diff --git a/Documentation/kbuild/kbuild.txt b/Documentation/kbuild/kbuild.txt
index 634c625da8ce..d9c655433ec6 100644
--- a/Documentation/kbuild/kbuild.txt
+++ b/Documentation/kbuild/kbuild.txt
@@ -22,11 +22,23 @@ building C files and assembler files.
22 22
23KAFLAGS 23KAFLAGS
24-------------------------------------------------- 24--------------------------------------------------
25Additional options to the assembler. 25Additional options to the assembler (for built-in and modules).
26
27AFLAGS_MODULE
28--------------------------------------------------
29Addtional module specific options to use for $(AS).
26 30
27KCFLAGS 31KCFLAGS
28-------------------------------------------------- 32--------------------------------------------------
29Additional options to the C compiler. 33Additional options to the C compiler (for built-in and modules).
34
35CFLAGS_MODULE
36--------------------------------------------------
37Addtional module specific options to use for $(CC).
38
39LDFLAGS_MODULE
40--------------------------------------------------
41Additional options used for $(LD) when linking modules.
30 42
31KBUILD_VERBOSE 43KBUILD_VERBOSE
32-------------------------------------------------- 44--------------------------------------------------
diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
index 71c602d61680..802341abf702 100644
--- a/Documentation/kbuild/makefiles.txt
+++ b/Documentation/kbuild/makefiles.txt
@@ -928,11 +928,23 @@ When kbuild executes, the following steps are followed (roughly):
928 $(CFLAGS_KERNEL) contains extra C compiler flags used to compile 928 $(CFLAGS_KERNEL) contains extra C compiler flags used to compile
929 resident kernel code. 929 resident kernel code.
930 930
931 CFLAGS_MODULE $(CC) options specific for modules 931 KBUILD_AFLAGS_MODULE Options for $(AS) when building modules
932 932
933 $(CFLAGS_MODULE) contains extra C compiler flags used to compile code 933 $(KBUILD_AFLAGS_MODULE) is used to add arch specific options that
934 for loadable kernel modules. 934 are used for $(AS).
935 From commandline AFLAGS_MODULE shall be used (see kbuild.txt).
935 936
937 KBUILD_CFLAGS_MODULE Options for $(CC) when building modules
938
939 $(KBUILD_CFLAGS_MODULE) is used to add arch specific options that
940 are used for $(CC).
941 From commandline CFLAGS_MODULE shall be used (see kbuild.txt).
942
943 KBUILD_LDFLAGS_MODULE Options for $(LD) when linking modules
944
945 $(KBUILD_LDFLAGS_MODULE) is used to add arch specific options
946 used when linking modules. This is often a linker script.
947 From commandline LDFLAGS_MODULE shall be used (see kbuild.txt).
936 948
937--- 6.2 Add prerequisites to archprepare: 949--- 6.2 Add prerequisites to archprepare:
938 950
diff --git a/Makefile b/Makefile
index e1dfb90c6092..3dbd62b0bcfe 100644
--- a/Makefile
+++ b/Makefile
@@ -332,10 +332,9 @@ CHECK = sparse
332 332
333CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \ 333CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
334 -Wbitwise -Wno-return-void $(CF) 334 -Wbitwise -Wno-return-void $(CF)
335MODFLAGS = -DMODULE 335CFLAGS_MODULE =
336CFLAGS_MODULE = $(MODFLAGS) 336AFLAGS_MODULE =
337AFLAGS_MODULE = $(MODFLAGS) 337LDFLAGS_MODULE =
338LDFLAGS_MODULE = -T $(srctree)/scripts/module-common.lds
339CFLAGS_KERNEL = 338CFLAGS_KERNEL =
340AFLAGS_KERNEL = 339AFLAGS_KERNEL =
341CFLAGS_GCOV = -fprofile-arcs -ftest-coverage 340CFLAGS_GCOV = -fprofile-arcs -ftest-coverage
@@ -355,6 +354,9 @@ KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
355 -Wno-format-security \ 354 -Wno-format-security \
356 -fno-delete-null-pointer-checks 355 -fno-delete-null-pointer-checks
357KBUILD_AFLAGS := -D__ASSEMBLY__ 356KBUILD_AFLAGS := -D__ASSEMBLY__
357KBUILD_AFLAGS_MODULE := -DMODULE
358KBUILD_CFLAGS_MODULE := -DMODULE
359KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds
358 360
359# Read KERNELRELEASE from include/config/kernel.release (if it exists) 361# Read KERNELRELEASE from include/config/kernel.release (if it exists)
360KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) 362KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null)
@@ -369,6 +371,7 @@ export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS
369export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS 371export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS
370export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE CFLAGS_GCOV 372export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE CFLAGS_GCOV
371export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE 373export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
374export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE
372 375
373# When compiling out-of-tree modules, put MODVERDIR in the module 376# When compiling out-of-tree modules, put MODVERDIR in the module
374# tree rather than in the kernel tree. The kernel tree might 377# tree rather than in the kernel tree. The kernel tree might
@@ -607,7 +610,7 @@ endif
607# Use --build-id when available. 610# Use --build-id when available.
608LDFLAGS_BUILD_ID = $(patsubst -Wl$(comma)%,%,\ 611LDFLAGS_BUILD_ID = $(patsubst -Wl$(comma)%,%,\
609 $(call cc-ldoption, -Wl$(comma)--build-id,)) 612 $(call cc-ldoption, -Wl$(comma)--build-id,))
610LDFLAGS_MODULE += $(LDFLAGS_BUILD_ID) 613KBUILD_LDFLAGS_MODULE += $(LDFLAGS_BUILD_ID)
611LDFLAGS_vmlinux += $(LDFLAGS_BUILD_ID) 614LDFLAGS_vmlinux += $(LDFLAGS_BUILD_ID)
612 615
613ifeq ($(CONFIG_STRIP_ASM_SYMS),y) 616ifeq ($(CONFIG_STRIP_ASM_SYMS),y)
diff --git a/arch/avr32/Makefile b/arch/avr32/Makefile
index ead8a75203a9..22fb66590dcd 100644
--- a/arch/avr32/Makefile
+++ b/arch/avr32/Makefile
@@ -13,7 +13,7 @@ KBUILD_DEFCONFIG := atstk1002_defconfig
13 13
14KBUILD_CFLAGS += -pipe -fno-builtin -mno-pic 14KBUILD_CFLAGS += -pipe -fno-builtin -mno-pic
15KBUILD_AFLAGS += -mrelax -mno-pic 15KBUILD_AFLAGS += -mrelax -mno-pic
16CFLAGS_MODULE += -mno-relax 16KBUILD_CFLAGS_MODULE += -mno-relax
17LDFLAGS_vmlinux += --relax 17LDFLAGS_vmlinux += --relax
18 18
19cpuflags-$(CONFIG_PLATFORM_AT32AP) += -march=ap 19cpuflags-$(CONFIG_PLATFORM_AT32AP) += -march=ap
diff --git a/arch/blackfin/Makefile b/arch/blackfin/Makefile
index d4c7177e7656..f7ef923297fc 100644
--- a/arch/blackfin/Makefile
+++ b/arch/blackfin/Makefile
@@ -15,8 +15,8 @@ GZFLAGS := -9
15 15
16KBUILD_CFLAGS += $(call cc-option,-mno-fdpic) 16KBUILD_CFLAGS += $(call cc-option,-mno-fdpic)
17KBUILD_AFLAGS += $(call cc-option,-mno-fdpic) 17KBUILD_AFLAGS += $(call cc-option,-mno-fdpic)
18CFLAGS_MODULE += -mlong-calls 18KBUILD_CFLAGS_MODULE += -mlong-calls
19LDFLAGS_MODULE += -m elf32bfin 19KBUILD_LDFLAGS_MODULE += -m elf32bfin
20KALLSYMS += --symbol-prefix=_ 20KALLSYMS += --symbol-prefix=_
21 21
22KBUILD_DEFCONFIG := BF537-STAMP_defconfig 22KBUILD_DEFCONFIG := BF537-STAMP_defconfig
diff --git a/arch/ia64/Makefile b/arch/ia64/Makefile
index 475e2725fbde..5ab6af3361a8 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__
22 22
23OBJCOPYFLAGS := --strip-all 23OBJCOPYFLAGS := --strip-all
24LDFLAGS_vmlinux := -static 24LDFLAGS_vmlinux := -static
25LDFLAGS_MODULE += -T $(srctree)/arch/ia64/module.lds 25KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/ia64/module.lds
26AFLAGS_KERNEL := -mconstant-gp 26AFLAGS_KERNEL := -mconstant-gp
27EXTRA := 27EXTRA :=
28 28
diff --git a/arch/m32r/Makefile b/arch/m32r/Makefile
index 469766b24e22..14a3c2314fef 100644
--- a/arch/m32r/Makefile
+++ b/arch/m32r/Makefile
@@ -13,7 +13,7 @@ LDFLAGS_vmlinux :=
13 13
14KBUILD_CFLAGS += -pipe -fno-schedule-insns 14KBUILD_CFLAGS += -pipe -fno-schedule-insns
15CFLAGS_KERNEL += -mmodel=medium 15CFLAGS_KERNEL += -mmodel=medium
16CFLAGS_MODULE += -mmodel=large 16KBUILD_CFLAGS_MODULE += -mmodel=large
17 17
18ifdef CONFIG_CHIP_VDEC2 18ifdef CONFIG_CHIP_VDEC2
19cflags-$(CONFIG_ISA_M32R2) += -DNO_FPU -Wa,-bitinst 19cflags-$(CONFIG_ISA_M32R2) += -DNO_FPU -Wa,-bitinst
diff --git a/arch/m68k/Makefile b/arch/m68k/Makefile
index 570d85c3f97f..b06a7e3cbcd6 100644
--- a/arch/m68k/Makefile
+++ b/arch/m68k/Makefile
@@ -18,7 +18,7 @@ KBUILD_DEFCONFIG := multi_defconfig
18# override top level makefile 18# override top level makefile
19AS += -m68020 19AS += -m68020
20LDFLAGS := -m m68kelf 20LDFLAGS := -m m68kelf
21LDFLAGS_MODULE += -T $(srctree)/arch/m68k/kernel/module.lds 21KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/m68k/kernel/module.lds
22ifneq ($(SUBARCH),$(ARCH)) 22ifneq ($(SUBARCH),$(ARCH))
23 ifeq ($(CROSS_COMPILE),) 23 ifeq ($(CROSS_COMPILE),)
24 CROSS_COMPILE := $(call cc-cross-prefix, \ 24 CROSS_COMPILE := $(call cc-cross-prefix, \
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index 1893efd43fca..a77dcf35c14e 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -93,7 +93,8 @@ all-$(CONFIG_SYS_SUPPORTS_ZBOOT)+= vmlinuz
93cflags-y += -G 0 -mno-abicalls -fno-pic -pipe 93cflags-y += -G 0 -mno-abicalls -fno-pic -pipe
94cflags-y += -msoft-float 94cflags-y += -msoft-float
95LDFLAGS_vmlinux += -G 0 -static -n -nostdlib 95LDFLAGS_vmlinux += -G 0 -static -n -nostdlib
96MODFLAGS += -mlong-calls 96KBUILD_AFLAGS_MODULE += -mlong-calls
97KBUILD_CFLAGS_MODULE += -mlong-calls
97 98
98cflags-y += -ffreestanding 99cflags-y += -ffreestanding
99 100
@@ -172,7 +173,8 @@ cflags-$(CONFIG_CPU_DADDI_WORKAROUNDS) += $(call cc-option,-mno-daddi,)
172 173
173ifdef CONFIG_CPU_SB1 174ifdef CONFIG_CPU_SB1
174ifdef CONFIG_SB1_PASS_1_WORKAROUNDS 175ifdef CONFIG_SB1_PASS_1_WORKAROUNDS
175MODFLAGS += -msb1-pass1-workarounds 176KBUILD_AFLAGS_MODULE += -msb1-pass1-workarounds
177KBUILD_CFLAGS_MODULE += -msb1-pass1-workarounds
176endif 178endif
177endif 179endif
178 180
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 42dcd3f4ad7b..b68a83853e1c 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -93,7 +93,7 @@ else
93 KBUILD_CFLAGS += $(call cc-option,-mtune=power4) 93 KBUILD_CFLAGS += $(call cc-option,-mtune=power4)
94endif 94endif
95else 95else
96LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o 96KBUILD_LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o
97endif 97endif
98 98
99ifeq ($(CONFIG_TUNE_CELL),y) 99ifeq ($(CONFIG_TUNE_CELL),y)
diff --git a/arch/s390/Makefile b/arch/s390/Makefile
index fc8fb20e7fc0..83ef8724c833 100644
--- a/arch/s390/Makefile
+++ b/arch/s390/Makefile
@@ -22,7 +22,8 @@ STACK_SIZE := 8192
22CHECKFLAGS += -D__s390__ -msize-long 22CHECKFLAGS += -D__s390__ -msize-long
23else 23else
24LDFLAGS := -m elf64_s390 24LDFLAGS := -m elf64_s390
25MODFLAGS += -fpic -D__PIC__ 25KBUILD_AFLAGS_MODULE += -fpic -D__PIC__
26KBUILD_CFLAGS_MODULE += -fpic -D__PIC__
26KBUILD_CFLAGS += -m64 27KBUILD_CFLAGS += -m64
27KBUILD_AFLAGS += -m64 28KBUILD_AFLAGS += -m64
28UTS_MACHINE := s390x 29UTS_MACHINE := s390x
diff --git a/arch/score/Makefile b/arch/score/Makefile
index 68e0cd06d5c9..d77dc639d8e3 100644
--- a/arch/score/Makefile
+++ b/arch/score/Makefile
@@ -20,7 +20,8 @@ cflags-y += -G0 -pipe -mel -mnhwloop -D__SCOREEL__ \
20# 20#
21KBUILD_AFLAGS += $(cflags-y) 21KBUILD_AFLAGS += $(cflags-y)
22KBUILD_CFLAGS += $(cflags-y) 22KBUILD_CFLAGS += $(cflags-y)
23MODFLAGS += -mlong-calls 23KBUILD_AFLAGS_MODULE += -mlong-calls
24KBUILD_CFLAGS_MODULE += -mlong-calls
24LDFLAGS += --oformat elf32-littlescore 25LDFLAGS += --oformat elf32-littlescore
25LDFLAGS_vmlinux += -G0 -static -nostdlib 26LDFLAGS_vmlinux += -G0 -static -nostdlib
26 27
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 390aae4bb222..5e7c40e16545 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -115,7 +115,10 @@ endif
115# --------------------------------------------------------------------------- 115# ---------------------------------------------------------------------------
116 116
117# Default is built-in, unless we know otherwise 117# Default is built-in, unless we know otherwise
118modkern_cflags = $(if $(part-of-module), $(CFLAGS_MODULE), $(CFLAGS_KERNEL)) 118modkern_cflags = \
119 $(if $(part-of-module), \
120 $(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE), \
121 $(CFLAGS_KERNEL))
119quiet_modtag := $(empty) $(empty) 122quiet_modtag := $(empty) $(empty)
120 123
121$(real-objs-m) : part-of-module := y 124$(real-objs-m) : part-of-module := y
@@ -250,8 +253,8 @@ $(obj)/%.lst: $(src)/%.c FORCE
250 253
251modkern_aflags := $(AFLAGS_KERNEL) 254modkern_aflags := $(AFLAGS_KERNEL)
252 255
253$(real-objs-m) : modkern_aflags := $(AFLAGS_MODULE) 256$(real-objs-m) : modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE)
254$(real-objs-m:.o=.s): modkern_aflags := $(AFLAGS_MODULE) 257$(real-objs-m:.o=.s): modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE)
255 258
256quiet_cmd_as_s_S = CPP $(quiet_modtag) $@ 259quiet_cmd_as_s_S = CPP $(quiet_modtag) $@
257cmd_as_s_S = $(CPP) $(a_flags) -o $@ $< 260cmd_as_s_S = $(CPP) $(a_flags) -o $@ $<
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
index 8f14c81abbc7..3e3f02409bbd 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -107,7 +107,7 @@ $(modules:.ko=.mod.c): __modpost ;
107modname = $(notdir $(@:.mod.o=)) 107modname = $(notdir $(@:.mod.o=))
108 108
109quiet_cmd_cc_o_c = CC $@ 109quiet_cmd_cc_o_c = CC $@
110 cmd_cc_o_c = $(CC) $(c_flags) $(CFLAGS_MODULE) \ 110 cmd_cc_o_c = $(CC) $(c_flags) $(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE) \
111 -c -o $@ $< 111 -c -o $@ $<
112 112
113$(modules:.ko=.mod.o): %.mod.o: %.mod.c FORCE 113$(modules:.ko=.mod.o): %.mod.o: %.mod.c FORCE
@@ -117,8 +117,9 @@ targets += $(modules:.ko=.mod.o)
117 117
118# Step 6), final link of the modules 118# Step 6), final link of the modules
119quiet_cmd_ld_ko_o = LD [M] $@ 119quiet_cmd_ld_ko_o = LD [M] $@
120 cmd_ld_ko_o = $(LD) -r $(LDFLAGS) $(LDFLAGS_MODULE) -o $@ \ 120 cmd_ld_ko_o = $(LD) -r $(LDFLAGS) \
121 $(filter-out FORCE,$^) 121 $(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \
122 -o $@ $(filter-out FORCE,$^)
122 123
123$(modules): %.ko :%.o %.mod.o FORCE 124$(modules): %.ko :%.o %.mod.o FORCE
124 $(call if_changed,ld_ko_o) 125 $(call if_changed,ld_ko_o)