lkml.org 
[lkml]   [2018]   [Mar]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.14 134/140] kbuild: Set KBUILD_CFLAGS before incl. arch Makefile
    Date
    4.14-stable review patch.  If anyone has any objections, please let me know.

    ------------------

    From: Chris Fries <cfries@google.com>

    commit ae6b289a37890909fea0e4a1666e19377fa0ed2c upstream.

    Set the clang KBUILD_CFLAGS up before including arch/ Makefiles,
    so that ld-options (etc.) can work correctly.

    This fixes errors with clang such as ld-options trying to CC
    against your host architecture, but LD trying to link against
    your target architecture.

    Signed-off-by: Chris Fries <cfries@google.com>
    Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
    Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
    Tested-by: Matthias Kaehlcke <mka@chromium.org>
    Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    ---
    Makefile | 64 +++++++++++++++++++++++++++++++--------------------------------
    1 file changed, 32 insertions(+), 32 deletions(-)

    --- a/Makefile
    +++ b/Makefile
    @@ -482,6 +482,38 @@ ifneq ($(KBUILD_SRC),)
    $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL)
    endif

    +ifeq ($(cc-name),clang)
    +ifneq ($(CROSS_COMPILE),)
    +CLANG_TARGET := --target=$(notdir $(CROSS_COMPILE:%-=%))
    +GCC_TOOLCHAIN := $(realpath $(dir $(shell which $(LD)))/..)
    +endif
    +ifneq ($(GCC_TOOLCHAIN),)
    +CLANG_GCC_TC := --gcc-toolchain=$(GCC_TOOLCHAIN)
    +endif
    +KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
    +KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
    +KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,)
    +KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable)
    +KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier)
    +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
    +KBUILD_CFLAGS += $(call cc-disable-warning, tautological-compare)
    +# CLANG uses a _MergedGlobals as optimization, but this breaks modpost, as the
    +# source of a reference will be _MergedGlobals and not on of the whitelisted names.
    +# See modpost pattern 2
    +KBUILD_CFLAGS += $(call cc-option, -mno-global-merge,)
    +KBUILD_CFLAGS += $(call cc-option, -fcatch-undefined-behavior)
    +KBUILD_CFLAGS += $(call cc-option, -no-integrated-as)
    +KBUILD_AFLAGS += $(call cc-option, -no-integrated-as)
    +else
    +
    +# These warnings generated too much noise in a regular build.
    +# Use make W=1 to enable them (see scripts/Makefile.extrawarn)
    +KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
    +KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
    +endif
    +
    ifeq ($(config-targets),1)
    # ===========================================================================
    # *config targets only - make sure prerequisites are updated, and descend
    @@ -692,38 +724,6 @@ ifdef CONFIG_CC_STACKPROTECTOR
    endif
    KBUILD_CFLAGS += $(stackp-flag)

    -ifeq ($(cc-name),clang)
    -ifneq ($(CROSS_COMPILE),)
    -CLANG_TARGET := --target=$(notdir $(CROSS_COMPILE:%-=%))
    -GCC_TOOLCHAIN := $(realpath $(dir $(shell which $(LD)))/..)
    -endif
    -ifneq ($(GCC_TOOLCHAIN),)
    -CLANG_GCC_TC := --gcc-toolchain=$(GCC_TOOLCHAIN)
    -endif
    -KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
    -KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC)
    -KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,)
    -KBUILD_CFLAGS += $(call cc-disable-warning, unused-variable)
    -KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier)
    -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
    -KBUILD_CFLAGS += $(call cc-disable-warning, tautological-compare)
    -# CLANG uses a _MergedGlobals as optimization, but this breaks modpost, as the
    -# source of a reference will be _MergedGlobals and not on of the whitelisted names.
    -# See modpost pattern 2
    -KBUILD_CFLAGS += $(call cc-option, -mno-global-merge,)
    -KBUILD_CFLAGS += $(call cc-option, -fcatch-undefined-behavior)
    -KBUILD_CFLAGS += $(call cc-option, -no-integrated-as)
    -KBUILD_AFLAGS += $(call cc-option, -no-integrated-as)
    -else
    -
    -# These warnings generated too much noise in a regular build.
    -# Use make W=1 to enable them (see scripts/Makefile.extrawarn)
    -KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
    -KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
    -endif
    -
    ifdef CONFIG_FRAME_POINTER
    KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
    else

    \
     
     \ /
      Last update: 2018-03-13 16:43    [W:4.512 / U:0.080 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site