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

Commit 58f051fc authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull Kbuild updates from Masahiro Yamada:

 - Clean up Makefiles and scripts

 - Improve clang support

 - Remove unneeded genhdr-y syntax

 - Remove unneeded cc-option-align macro

 - Introduce __cc-option macro and use it to fix x86 boot code compiler
   flags

* tag 'kbuild-v4.13' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
  kbuild: improve comments on KBUILD_SRC
  x86/build: Specify stack alignment for clang
  x86/build: Use __cc-option for boot code compiler options
  kbuild: Add __cc-option macro
  kbuild: remove cc-option-align
  kbuild: replace genhdr-y with generated-y
  kbuild: clang: Disable 'address-of-packed-member' warning
  kbuild: remove duplicated arch/*/include/generated/uapi include path
  kbuild: speed up checksyscalls.sh
  kbuild: simplify silent build (-s) detection
parents ef3ad089 c4e6fff1
Loading
Loading
Loading
Loading
+6 −35
Original line number Original line Diff line number Diff line
@@ -45,10 +45,9 @@ This document describes the Linux kernel Makefiles.


	=== 7 Kbuild syntax for exported headers
	=== 7 Kbuild syntax for exported headers
		--- 7.1 no-export-headers
		--- 7.1 no-export-headers
		--- 7.2 genhdr-y
		--- 7.2 generic-y
		--- 7.3 generic-y
		--- 7.3 generated-y
		--- 7.4 generated-y
		--- 7.4 mandatory-y
		--- 7.5 mandatory-y


	=== 8 Kbuild Variables
	=== 8 Kbuild Variables
	=== 9 Makefile language
	=== 9 Makefile language
@@ -487,22 +486,6 @@ more details, with real examples.
	respectively.
	respectively.
	Note: cc-option-yn uses KBUILD_CFLAGS for $(CC) options
	Note: cc-option-yn uses KBUILD_CFLAGS for $(CC) options


    cc-option-align
	gcc versions >= 3.0 changed the type of options used to specify
	alignment of functions, loops etc. $(cc-option-align), when used
	as prefix to the align options, will select the right prefix:
	gcc < 3.00
		cc-option-align = -malign
	gcc >= 3.00
		cc-option-align = -falign

	Example:
		KBUILD_CFLAGS += $(cc-option-align)-functions=4

	In the above example, the option -falign-functions=4 is used for
	gcc >= 3.00. For gcc < 3.00, -malign-functions=4 is used.
	Note: cc-option-align uses KBUILD_CFLAGS for $(CC) options

    cc-disable-warning
    cc-disable-warning
	cc-disable-warning checks if gcc supports a given warning and returns
	cc-disable-warning checks if gcc supports a given warning and returns
	the commandline switch to disable it. This special function is needed,
	the commandline switch to disable it. This special function is needed,
@@ -1277,18 +1260,7 @@ See subsequent chapter for the syntax of the Kbuild file.
	avoid exporting specific headers (e.g. kvm.h) on architectures that do
	avoid exporting specific headers (e.g. kvm.h) on architectures that do
	not support it. It should be avoided as much as possible.
	not support it. It should be avoided as much as possible.


	--- 7.2 genhdr-y
	--- 7.2 generic-y

	genhdr-y specifies asm files to be generated.

		Example:
			#arch/x86/include/uapi/asm/Kbuild
			genhdr-y += unistd_32.h
			genhdr-y += unistd_64.h
			genhdr-y += unistd_x32.h


	--- 7.3 generic-y


	If an architecture uses a verbatim copy of a header from
	If an architecture uses a verbatim copy of a header from
	include/asm-generic then this is listed in the file
	include/asm-generic then this is listed in the file
@@ -1315,11 +1287,10 @@ See subsequent chapter for the syntax of the Kbuild file.
		Example: termios.h
		Example: termios.h
			#include <asm-generic/termios.h>
			#include <asm-generic/termios.h>


	--- 7.4 generated-y
	--- 7.3 generated-y


	If an architecture generates other header files alongside generic-y
	If an architecture generates other header files alongside generic-y
	wrappers, and not included in genhdr-y, then generated-y specifies
	wrappers, generated-y specifies them.
	them.


	This prevents them being treated as stale asm-generic wrappers and
	This prevents them being treated as stale asm-generic wrappers and
	removed.
	removed.
+8 −16
Original line number Original line Diff line number Diff line
@@ -84,17 +84,10 @@ endif
# If the user is running make -s (silent mode), suppress echoing of
# If the user is running make -s (silent mode), suppress echoing of
# commands
# commands


ifneq ($(filter 4.%,$(MAKE_VERSION)),)	# make-4
ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),)
ifneq ($(filter %s ,$(firstword x$(MAKEFLAGS))),)
  quiet=silent_
  quiet=silent_
  tools_silent=s
  tools_silent=s
endif
endif
else					# make-3.8x
ifneq ($(filter s% -s%,$(MAKEFLAGS)),)
  quiet=silent_
  tools_silent=-s
endif
endif


export quiet Q KBUILD_VERBOSE
export quiet Q KBUILD_VERBOSE


@@ -113,8 +106,8 @@ export quiet Q KBUILD_VERBOSE
# The O= assignment takes precedence over the KBUILD_OUTPUT environment
# The O= assignment takes precedence over the KBUILD_OUTPUT environment
# variable.
# variable.


# KBUILD_SRC is set on invocation of make in OBJ directory
# KBUILD_SRC is not intended to be used by the regular user (for now),
# KBUILD_SRC is not intended to be used by the regular user (for now)
# it is set on invocation of make with KBUILD_OUTPUT or O= specified.
ifeq ($(KBUILD_SRC),)
ifeq ($(KBUILD_SRC),)


# OK, Make called in directory where kernel src resides
# OK, Make called in directory where kernel src resides
@@ -135,7 +128,6 @@ ifneq ($(words $(subst :, ,$(CURDIR))), 1)
endif
endif


ifneq ($(KBUILD_OUTPUT),)
ifneq ($(KBUILD_OUTPUT),)
# Invoke a second make in the output directory, passing relevant variables
# check that the output directory actually exists
# check that the output directory actually exists
saved-output := $(KBUILD_OUTPUT)
saved-output := $(KBUILD_OUTPUT)
KBUILD_OUTPUT := $(shell mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) \
KBUILD_OUTPUT := $(shell mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) \
@@ -148,6 +140,7 @@ PHONY += $(MAKECMDGOALS) sub-make
$(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make
$(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make
	@:
	@:


# Invoke a second make in the output directory, passing relevant variables
sub-make:
sub-make:
	$(Q)$(MAKE) -C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR) \
	$(Q)$(MAKE) -C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR) \
	-f $(CURDIR)/Makefile $(filter-out _all sub-make,$(MAKECMDGOALS))
	-f $(CURDIR)/Makefile $(filter-out _all sub-make,$(MAKECMDGOALS))
@@ -303,7 +296,7 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \


HOSTCC       = gcc
HOSTCC       = gcc
HOSTCXX      = g++
HOSTCXX      = g++
HOSTCFLAGS   = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89
HOSTCFLAGS   := -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89
HOSTCXXFLAGS = -O2
HOSTCXXFLAGS = -O2


ifeq ($(shell $(HOSTCC) -v 2>&1 | grep -c "clang version"), 1)
ifeq ($(shell $(HOSTCC) -v 2>&1 | grep -c "clang version"), 1)
@@ -388,12 +381,10 @@ USERINCLUDE := \
# Needed to be compatible with the O= option
# Needed to be compatible with the O= option
LINUXINCLUDE    := \
LINUXINCLUDE    := \
		-I$(srctree)/arch/$(hdr-arch)/include \
		-I$(srctree)/arch/$(hdr-arch)/include \
		-I$(objtree)/arch/$(hdr-arch)/include/generated/uapi \
		-I$(objtree)/arch/$(hdr-arch)/include/generated \
		-I$(objtree)/arch/$(hdr-arch)/include/generated \
		$(if $(KBUILD_SRC), -I$(srctree)/include) \
		$(if $(KBUILD_SRC), -I$(srctree)/include) \
		-I$(objtree)/include
		-I$(objtree)/include \

		$(USERINCLUDE)
LINUXINCLUDE	+= $(filter-out $(LINUXINCLUDE),$(USERINCLUDE))


KBUILD_CPPFLAGS := -D__KERNEL__
KBUILD_CPPFLAGS := -D__KERNEL__


@@ -707,6 +698,7 @@ KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,)
KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable)
KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable)
KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier)
KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier)
KBUILD_CFLAGS += $(call cc-disable-warning, gnu)
KBUILD_CFLAGS += $(call cc-disable-warning, gnu)
KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
# Quiet clang warning: comparison of unsigned expression < 0 is always false
# Quiet clang warning: comparison of unsigned expression < 0 is always false
KBUILD_CFLAGS += $(call cc-disable-warning, tautological-compare)
KBUILD_CFLAGS += $(call cc-disable-warning, tautological-compare)
# CLANG uses a _MergedGlobals as optimization, but this breaks modpost, as the
# CLANG uses a _MergedGlobals as optimization, but this breaks modpost, as the
+3 −3
Original line number Original line Diff line number Diff line
# UAPI Header export list
# UAPI Header export list
include include/uapi/asm-generic/Kbuild.asm
include include/uapi/asm-generic/Kbuild.asm


genhdr-y += unistd-common.h
generated-y += unistd-common.h
genhdr-y += unistd-oabi.h
generated-y += unistd-oabi.h
genhdr-y += unistd-eabi.h
generated-y += unistd-eabi.h


generic-y += siginfo.h
generic-y += siginfo.h
+25 −8
Original line number Original line Diff line number Diff line
@@ -11,6 +11,14 @@ else
        KBUILD_DEFCONFIG := $(ARCH)_defconfig
        KBUILD_DEFCONFIG := $(ARCH)_defconfig
endif
endif


# For gcc stack alignment is specified with -mpreferred-stack-boundary,
# clang has the option -mstack-alignment for that purpose.
ifneq ($(call cc-option, -mpreferred-stack-boundary=4),)
        cc_stack_align_opt := -mpreferred-stack-boundary
else ifneq ($(call cc-option, -mstack-alignment=4),)
        cc_stack_align_opt := -mstack-alignment
endif

# How to compile the 16-bit code.  Note we always compile for -march=i386;
# How to compile the 16-bit code.  Note we always compile for -march=i386;
# that way we can complain to the user if the CPU is insufficient.
# that way we can complain to the user if the CPU is insufficient.
#
#
@@ -24,10 +32,11 @@ REALMODE_CFLAGS := $(M16_CFLAGS) -g -Os -D__KERNEL__ \
		   -DDISABLE_BRANCH_PROFILING \
		   -DDISABLE_BRANCH_PROFILING \
		   -Wall -Wstrict-prototypes -march=i386 -mregparm=3 \
		   -Wall -Wstrict-prototypes -march=i386 -mregparm=3 \
		   -fno-strict-aliasing -fomit-frame-pointer -fno-pic \
		   -fno-strict-aliasing -fomit-frame-pointer -fno-pic \
		   -mno-mmx -mno-sse \
		   -mno-mmx -mno-sse
		   $(call cc-option, -ffreestanding) \

		   $(call cc-option, -fno-stack-protector) \
REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -ffreestanding)
		   $(call cc-option, -mpreferred-stack-boundary=2)
REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -fno-stack-protector)
REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), $(cc_stack_align_opt)=2)
export REALMODE_CFLAGS
export REALMODE_CFLAGS


# BITS is used as extension for files which are available in a 32 bit
# BITS is used as extension for files which are available in a 32 bit
@@ -64,8 +73,10 @@ ifeq ($(CONFIG_X86_32),y)
        # with nonstandard options
        # with nonstandard options
        KBUILD_CFLAGS += -fno-pic
        KBUILD_CFLAGS += -fno-pic


        # prevent gcc from keeping the stack 16 byte aligned
        # Align the stack to the register width instead of using the default
        KBUILD_CFLAGS += $(call cc-option,-mpreferred-stack-boundary=2)
        # alignment of 16 bytes. This reduces stack usage and the number of
        # alignment instructions.
        KBUILD_CFLAGS += $(call cc-option,$(cc_stack_align_opt)=2)


        # Disable unit-at-a-time mode on pre-gcc-4.0 compilers, it makes gcc use
        # Disable unit-at-a-time mode on pre-gcc-4.0 compilers, it makes gcc use
        # a lot more stack due to the lack of sharing of stacklots:
        # a lot more stack due to the lack of sharing of stacklots:
@@ -97,8 +108,14 @@ else
        KBUILD_CFLAGS += $(call cc-option,-mno-80387)
        KBUILD_CFLAGS += $(call cc-option,-mno-80387)
        KBUILD_CFLAGS += $(call cc-option,-mno-fp-ret-in-387)
        KBUILD_CFLAGS += $(call cc-option,-mno-fp-ret-in-387)


	# Use -mpreferred-stack-boundary=3 if supported.
        # By default gcc and clang use a stack alignment of 16 bytes for x86.
	KBUILD_CFLAGS += $(call cc-option,-mpreferred-stack-boundary=3)
        # However the standard kernel entry on x86-64 leaves the stack on an
        # 8-byte boundary. If the compiler isn't informed about the actual
        # alignment it will generate extra alignment instructions for the
        # default alignment which keep the stack *mis*aligned.
        # Furthermore an alignment to the register width reduces stack usage
        # and the number of alignment instructions.
        KBUILD_CFLAGS += $(call cc-option,$(cc_stack_align_opt)=3)


	# Use -mskip-rax-setup if supported.
	# Use -mskip-rax-setup if supported.
	KBUILD_CFLAGS += $(call cc-option,-mskip-rax-setup)
	KBUILD_CFLAGS += $(call cc-option,-mskip-rax-setup)
+3 −4
Original line number Original line Diff line number Diff line
@@ -9,7 +9,6 @@ else
tune		= $(call cc-option,-mcpu=$(1),$(2))
tune		= $(call cc-option,-mcpu=$(1),$(2))
endif
endif


align := $(cc-option-align)
cflags-$(CONFIG_M486)		+= -march=i486
cflags-$(CONFIG_M486)		+= -march=i486
cflags-$(CONFIG_M586)		+= -march=i586
cflags-$(CONFIG_M586)		+= -march=i586
cflags-$(CONFIG_M586TSC)	+= -march=i586
cflags-$(CONFIG_M586TSC)	+= -march=i586
@@ -24,11 +23,11 @@ cflags-$(CONFIG_MK6) += -march=k6
# They make zero difference whatsosever to performance at this time.
# They make zero difference whatsosever to performance at this time.
cflags-$(CONFIG_MK7)		+= -march=athlon
cflags-$(CONFIG_MK7)		+= -march=athlon
cflags-$(CONFIG_MK8)		+= $(call cc-option,-march=k8,-march=athlon)
cflags-$(CONFIG_MK8)		+= $(call cc-option,-march=k8,-march=athlon)
cflags-$(CONFIG_MCRUSOE)	+= -march=i686 $(align)-functions=0 $(align)-jumps=0 $(align)-loops=0
cflags-$(CONFIG_MCRUSOE)	+= -march=i686 -falign-functions=0 -falign-jumps=0 -falign-loops=0
cflags-$(CONFIG_MEFFICEON)	+= -march=i686 $(call tune,pentium3) $(align)-functions=0 $(align)-jumps=0 $(align)-loops=0
cflags-$(CONFIG_MEFFICEON)	+= -march=i686 $(call tune,pentium3) -falign-functions=0 -falign-jumps=0 -falign-loops=0
cflags-$(CONFIG_MWINCHIPC6)	+= $(call cc-option,-march=winchip-c6,-march=i586)
cflags-$(CONFIG_MWINCHIPC6)	+= $(call cc-option,-march=winchip-c6,-march=i586)
cflags-$(CONFIG_MWINCHIP3D)	+= $(call cc-option,-march=winchip2,-march=i586)
cflags-$(CONFIG_MWINCHIP3D)	+= $(call cc-option,-march=winchip2,-march=i586)
cflags-$(CONFIG_MCYRIXIII)	+= $(call cc-option,-march=c3,-march=i486) $(align)-functions=0 $(align)-jumps=0 $(align)-loops=0
cflags-$(CONFIG_MCYRIXIII)	+= $(call cc-option,-march=c3,-march=i486) -falign-functions=0 -falign-jumps=0 -falign-loops=0
cflags-$(CONFIG_MVIAC3_2)	+= $(call cc-option,-march=c3-2,-march=i686)
cflags-$(CONFIG_MVIAC3_2)	+= $(call cc-option,-march=c3-2,-march=i686)
cflags-$(CONFIG_MVIAC7)		+= -march=i686
cflags-$(CONFIG_MVIAC7)		+= -march=i686
cflags-$(CONFIG_MCORE2)		+= -march=i686 $(call tune,core2)
cflags-$(CONFIG_MCORE2)		+= -march=i686 $(call tune,core2)
Loading