Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5646584imu; Mon, 26 Nov 2018 03:29:06 -0800 (PST) X-Google-Smtp-Source: AFSGD/UX3ZX0SvamobBF2Ym2HtZVd0BY9Huh+z5zz0QIhRAKpboeWCOLVGvbJWVxH6PThSZkG/by X-Received: by 2002:a17:902:8607:: with SMTP id f7mr26664733plo.123.1543231746561; Mon, 26 Nov 2018 03:29:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543231746; cv=none; d=google.com; s=arc-20160816; b=Y5sDTeA1qkx8hFJa6kpAFLgO5JhH4gY7IC4+GBzFJgt1smfhsyWbPT0J250vknTzON YsKgDIQmlSwpvItvcyhHWIKsm+BZI1u2yfQdLYlqe/cfeGqZBmP+adGo2tV2LTcCf1ra SDvTe31jWolGzFCKuYfEN7HPA0OZcigqDkFK7zH8XT4Mg8a/7aPnNWFcFX/Ob48QHJBf Yp5TiOC5TsJUxTtbjvV3A7KIeJz9JGElaJVqixeK7sLqfg4I6sG+FIj6CbSB0kuKAuVf JvG9TdkTdZPwjNqM2fp+6EIYBSkvyc4uOMvkpcXNx59tB2ncJpfmfCY0ij1Bi9guY3aV IwIA== 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=vh7itYpfJw0X7HblHr9qgF/UN6DTH1+gzBgs67QF54E=; b=CFONHblREaw/dZ5NT3VP0G/sp+AFiFIEWtVhmjGRhy+uiYWlD/2mrvipC9DHkL2XDL 4tLd4jBQoEa1dGq/SmOF220JdEo1WXnsOy2FzQmb5ZB6a9FwfwCqHR/Hpqg7rzoiFhlr 5ks+6qMxD9ETLmWS6LP+3c0nxOqHgR7PZaKuvDKLwtgkkYMAXlCbTG1OersOixmm8RmD iCXrZ5pA94vClSqr9oNgwe9POMjwjBmW+TiyoaRH43hq/KYdSJY4wL1FXk8vldRIzvOJ 75sw0xgmv+mLFRf/h9dTE298FDY02vyO3s4X37o0okkvzgfU6mWlMEcTL6LPWH6pCTnR W9bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0Elq1hhq; 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 i16si203pgk.445.2018.11.26.03.28.37; Mon, 26 Nov 2018 03:29:06 -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=0Elq1hhq; 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 S1727314AbeKZVr6 (ORCPT + 99 others); Mon, 26 Nov 2018 16:47:58 -0500 Received: from mail.kernel.org ([198.145.29.99]:56298 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726254AbeKZVr5 (ORCPT ); Mon, 26 Nov 2018 16:47:57 -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 0EA8D2089F; Mon, 26 Nov 2018 10:54:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543229653; bh=oD6eMPOW2UXVZ1f8g6xKZ17KGiHmZBPdc+zPy9XgUqc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0Elq1hhqeFtJQvBvFBsxxyqg2D7KzRT3WvUq1FbGRd4BDf3xvLMMwo+60v6LD+XQP MuwdqcT9CqUcXPkNmoXnTS5o2Wb/PiHkfnjdZ7oXiWEhXatG5OnAvwEfMLm7svu9OL KjP/RK1gc1L0y5lJZ/TyOcjS+oI/9X6gLNgBmuAw= 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 , Nathan Chancellor Subject: [PATCH 4.4 21/70] kbuild: Set KBUILD_CFLAGS before incl. arch Makefile Date: Mon, 26 Nov 2018 11:50:36 +0100 Message-Id: <20181126105048.863895905@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181126105046.722096341@linuxfoundation.org> References: <20181126105046.722096341@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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.4-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 [nc: Adjust context] Signed-off-by: Nathan Chancellor Signed-off-by: Greg Kroah-Hartman --- Makefile | 64 +++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 32 insertions(+), 32 deletions(-) --- a/Makefile +++ b/Makefile @@ -612,6 +612,38 @@ endif # $(dot-config) # Defaults to vmlinux, but the arch makefile usually adds further targets all: vmlinux +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 + # The arch Makefile can set ARCH_{CPP,A,C}FLAGS to override the default # values of the respective KBUILD_* variables ARCH_CPPFLAGS := @@ -697,38 +729,6 @@ endif 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