Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8110999imu; Tue, 4 Dec 2018 03:11:21 -0800 (PST) X-Google-Smtp-Source: AFSGD/Ut2iKQEpDpbYZdB00xGkEF/v4nVBryokbSa/Q0soxLl8gqELrd0yfwAXKeQThzGx6Y1Y1T X-Received: by 2002:a63:f615:: with SMTP id m21mr16854057pgh.428.1543921881790; Tue, 04 Dec 2018 03:11:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543921881; cv=none; d=google.com; s=arc-20160816; b=bfZyE9CY3vqeHAmq7F+rkUF/wbCoj6uO5G50GmaXjCTvUeqS+/cL2geMyjN8at5taP A0VJbx2JQ0gwa2IBvv33zrNnMFARCyFgh9hEma6QNfvBFMEfkkuvv/n+iLVOBtvTOoQJ +UvH8nsdQf0+t50knLbPORAl3Ns0zfRNJYcSnceVdsV+9ofLqBzsVLSUaFelEfAaNvtZ 1dY1moosWBWU8G74RTIiGS3eUtHQB45idOXrnFkiNTiLBpDcCJdZFcWH4HP6T7K8t55E sCJe5Qni/+iP9WGy/ud8SZ2P0QN3Dybie7SyYC/IrMIe0zJWInHGZSGLWwDXNkz5J3o4 U7eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=NzTCzbkNVAzK2bcOl8V1ZPeZwysRs7jH2yJ02WLEn/A=; b=keeF/4aYXmvKo/dPM8Is+/lyn8NupPdjgvu5c62boiIyB6897zYzg0i0XrcHprtxjP 7aXf06X1McxwwdtkjFJdZrdVOBMohhl8X5UxwML5wi2S9AePBX/Dh63jVkgG/C4Iumh+ gxrT9Dd0KvWNi5G7dNNORLhNVT70hDrYz3vt30RZX6ziFkHWY6w6vNvby1ZS3GSXCNwK v43kCC4c5H/r19DZrzodvA8NH8xmQ/MsazkxYQe13A1JoLQRECZoFCxgcN4TBv54Z/5l E1KCyqEz85wljed9k+uAEPas95WIIn1RLZ1JeVnrkYS+yFKWxfZO81fY9Ea8s7OiMSCr cNWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=THpgHTae; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e6si15014760pgk.201.2018.12.04.03.11.07; Tue, 04 Dec 2018 03:11:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=THpgHTae; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728803AbeLDLJZ (ORCPT + 99 others); Tue, 4 Dec 2018 06:09:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:59202 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728783AbeLDLJX (ORCPT ); Tue, 4 Dec 2018 06:09:23 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6E683214F1; Tue, 4 Dec 2018 11:09:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543921761; bh=yyMG6LgkEshhUjhf5bY0/vyiyHlpm7UBXRpSxSdYsB0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=THpgHTaeRTsRIJi5F8ngmTXxq6mHudnqzkRlFsq0s+ypI/ZNSMudmMATLb35ffI9+ tlP6zC2oMpYB1b5hwtujNSg8avfwc62Fc4T4JLHJy80zigYoOB0c6NV00fKMhHrdzc CafxjKNdJHk8zkGmviPTp7iy52PJcpj0uIEXcX/U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chris Fries , Nick Desaulniers , Matthias Kaehlcke , Masahiro Yamada Subject: [PATCH 4.9 50/50] kbuild: Set KBUILD_CFLAGS before incl. arch Makefile Date: Tue, 4 Dec 2018 11:50:45 +0100 Message-Id: <20181204103716.982097963@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181204103714.485546262@linuxfoundation.org> References: <20181204103714.485546262@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Chris Fries (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 Signed-off-by: Nick Desaulniers Reviewed-by: Matthias Kaehlcke Tested-by: Matthias Kaehlcke Signed-off-by: Masahiro Yamada [ND: adjusted context due to upstream having removed code above where I placed this block in this backport] Signed-off-by: Greg Kroah-Hartman --- Makefile | 65 +++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 33 insertions(+), 32 deletions(-) --- a/Makefile +++ b/Makefile @@ -509,6 +509,39 @@ ifneq ($(filter install,$(MAKECMDGOALS)) endif 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.build) +KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable) +KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable) +endif + + ifeq ($(mixed-targets),1) # =========================================================================== # We're called with mixed targets (*config and build targets). @@ -704,38 +737,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.build) -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