Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6588169d authored by Sam Ravnborg's avatar Sam Ravnborg Committed by Michal Marek
Browse files

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: default avatarSam 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: default avatarMichal Marek <mmarek@suse.cz>
parent d6f4ceb7
Loading
Loading
Loading
Loading
+14 −2
Original line number Original line Diff line number Diff line
@@ -22,11 +22,23 @@ building C files and assembler files.


KAFLAGS
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
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
KBUILD_VERBOSE
--------------------------------------------------
--------------------------------------------------
+15 −3
Original line number Original line Diff line number Diff line
@@ -928,11 +928,23 @@ When kbuild executes, the following steps are followed (roughly):
	$(CFLAGS_KERNEL) contains extra C compiler flags used to compile
	$(CFLAGS_KERNEL) contains extra C compiler flags used to compile
	resident kernel code.
	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
	$(KBUILD_AFLAGS_MODULE) is used to add arch specific options that
	for loadable kernel modules.
	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:
--- 6.2 Add prerequisites to archprepare:


+8 −5
Original line number Original line Diff line number Diff line
@@ -332,10 +332,9 @@ CHECK = sparse


CHECKFLAGS     := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
CHECKFLAGS     := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
		  -Wbitwise -Wno-return-void $(CF)
		  -Wbitwise -Wno-return-void $(CF)
MODFLAGS	= -DMODULE
CFLAGS_MODULE   =
CFLAGS_MODULE   = $(MODFLAGS)
AFLAGS_MODULE   =
AFLAGS_MODULE   = $(MODFLAGS)
LDFLAGS_MODULE  =
LDFLAGS_MODULE  = -T $(srctree)/scripts/module-common.lds
CFLAGS_KERNEL	=
CFLAGS_KERNEL	=
AFLAGS_KERNEL	=
AFLAGS_KERNEL	=
CFLAGS_GCOV	= -fprofile-arcs -ftest-coverage
CFLAGS_GCOV	= -fprofile-arcs -ftest-coverage
@@ -355,6 +354,9 @@ KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
		   -Wno-format-security \
		   -Wno-format-security \
		   -fno-delete-null-pointer-checks
		   -fno-delete-null-pointer-checks
KBUILD_AFLAGS   := -D__ASSEMBLY__
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)
# Read KERNELRELEASE from include/config/kernel.release (if it exists)
KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null)
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_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS
export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE CFLAGS_GCOV
export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE CFLAGS_GCOV
export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
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
# When compiling out-of-tree modules, put MODVERDIR in the module
# tree rather than in the kernel tree. The kernel tree might
# tree rather than in the kernel tree. The kernel tree might
@@ -607,7 +610,7 @@ endif
# Use --build-id when available.
# Use --build-id when available.
LDFLAGS_BUILD_ID = $(patsubst -Wl$(comma)%,%,\
LDFLAGS_BUILD_ID = $(patsubst -Wl$(comma)%,%,\
			      $(call cc-ldoption, -Wl$(comma)--build-id,))
			      $(call cc-ldoption, -Wl$(comma)--build-id,))
LDFLAGS_MODULE += $(LDFLAGS_BUILD_ID)
KBUILD_LDFLAGS_MODULE += $(LDFLAGS_BUILD_ID)
LDFLAGS_vmlinux += $(LDFLAGS_BUILD_ID)
LDFLAGS_vmlinux += $(LDFLAGS_BUILD_ID)


ifeq ($(CONFIG_STRIP_ASM_SYMS),y)
ifeq ($(CONFIG_STRIP_ASM_SYMS),y)
+1 −1
Original line number Original line Diff line number Diff line
@@ -13,7 +13,7 @@ KBUILD_DEFCONFIG := atstk1002_defconfig


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


cpuflags-$(CONFIG_PLATFORM_AT32AP)	+= -march=ap
cpuflags-$(CONFIG_PLATFORM_AT32AP)	+= -march=ap
+2 −2
Original line number Original line Diff line number Diff line
@@ -15,8 +15,8 @@ GZFLAGS := -9


KBUILD_CFLAGS           += $(call cc-option,-mno-fdpic)
KBUILD_CFLAGS           += $(call cc-option,-mno-fdpic)
KBUILD_AFLAGS           += $(call cc-option,-mno-fdpic)
KBUILD_AFLAGS           += $(call cc-option,-mno-fdpic)
CFLAGS_MODULE    += -mlong-calls
KBUILD_CFLAGS_MODULE    += -mlong-calls
LDFLAGS_MODULE   += -m elf32bfin
KBUILD_LDFLAGS_MODULE   += -m elf32bfin
KALLSYMS         += --symbol-prefix=_
KALLSYMS         += --symbol-prefix=_


KBUILD_DEFCONFIG := BF537-STAMP_defconfig
KBUILD_DEFCONFIG := BF537-STAMP_defconfig
Loading