Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp2749534ybh; Mon, 5 Aug 2019 06:15:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqwCkC1mL9BiOn/QoUzu9VTJxAMXOoHbuxKvxXOfzbqJjTCoec6dr1u++/JdaxE8wn7QWXCL X-Received: by 2002:a63:4846:: with SMTP id x6mr100897805pgk.332.1565010935940; Mon, 05 Aug 2019 06:15:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565010935; cv=none; d=google.com; s=arc-20160816; b=uw/CEgSQ4vzmB6yByPv2UYCkCoirjAU0f03CAWypL9gzSudl4kSNUcCrPAeXppNcBg ePfeW7CU+FaafAKUgSVVcMVOj1wvo4ABSplswmoqqr+OaoLyNIIouNonvr6gAh4swzB+ 2qqqWHZagEJUvuGBZfXeBDYArlX4myRrbBHgPqbJzCYkwTqrK2nZEoMB0r9ugGEvQsn8 UJM0j4qGUco6Mig1vGdtuIh1i6srcmiLhUiUaysoxUR/iIgipcWX8/gNaLn+ZApIVcC8 TRKxjQ34b1EMsFxzl73UgCUUMJ+bHNWBZKYsUR1l7YzG92kaPbmZCWy/bxYd6ZO4SLy9 oEsA== 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=wzr6zYGNzfR4BhzvVxaSZ05tDiLWDatsPcRIDapAehQ=; b=s37mn/azNb9qGGEe9DQXMdNAoV6OevzwmRrx23KSkhg2DqrpWMjesHz7j1rIMO4+RR j6MKyEsuno88h+1np6c2F+ro1KKioaXSZrOf2JJH3xuEq1z5hnDwZdKcaQSqsICt2Yxq zdVbHmlVIkdCuPAmYqLjLuu0XAYkUVEhIvXPAJpqMPEZuTFkg0QlpSttULUcqd855Wpt uX6XaTQhp55y5ldwiamYdXO02PxMFeIlDO21BMojmEayYDHVzIjlVnvzZ4LoYghSSNAB mQGWGfllRhWe7X50Fz30yT3m+T6wQi1ZiTCd/zxSHBo53geBkFF3pAS05Fm3uYBzIQUi +Wtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TapZCQzW; 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 r1si12942231pjp.80.2019.08.05.06.15.20; Mon, 05 Aug 2019 06:15:35 -0700 (PDT) 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=TapZCQzW; 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 S1730236AbfHENNl (ORCPT + 99 others); Mon, 5 Aug 2019 09:13:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:47182 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729321AbfHENI4 (ORCPT ); Mon, 5 Aug 2019 09:08:56 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 33E5B2067D; Mon, 5 Aug 2019 13:08:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565010535; bh=sEKyctDPn526D1KeohGJuIE9HPDNiKe2i4pehAkUN48=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TapZCQzW9XqoBeq6mlslgqTtEIUrDJG39nSicyFP7Za0tMn4zZhGNufVNI7yq9CZz usJJ0ubyadxpjkXXNEIKKiwvI7iosdAc46sXg+RllxfNZrPfMnprNqvkdUI1qCmA9c xoxoqFw9PJXtCAeH6dWGwbgw0DGW6s/516IZU8fE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Masahiro Yamada , Nathan Chancellor , Nick Desaulniers Subject: [PATCH 4.14 33/53] kbuild: initialize CLANG_FLAGS correctly in the top Makefile Date: Mon, 5 Aug 2019 15:02:58 +0200 Message-Id: <20190805124931.821959546@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190805124927.973499541@linuxfoundation.org> References: <20190805124927.973499541@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Masahiro Yamada commit 5241ab4cf42d3a93b933b55d3d53f43049081fa1 upstream. CLANG_FLAGS is initialized by the following line: CLANG_FLAGS := --target=$(notdir $(CROSS_COMPILE:%-=%)) ..., which is run only when CROSS_COMPILE is set. Some build targets (bindeb-pkg etc.) recurse to the top Makefile. When you build the kernel with Clang but without CROSS_COMPILE, the same compiler flags such as -no-integrated-as are accumulated into CLANG_FLAGS. If you run 'make CC=clang' and then 'make CC=clang bindeb-pkg', Kbuild will recompile everything needlessly due to the build command change. Fix this by correctly initializing CLANG_FLAGS. Fixes: 238bcbc4e07f ("kbuild: consolidate Clang compiler flags") Cc: # v5.0+ Signed-off-by: Masahiro Yamada Reviewed-by: Nathan Chancellor Acked-by: Nick Desaulniers Signed-off-by: Greg Kroah-Hartman --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/Makefile +++ b/Makefile @@ -427,6 +427,7 @@ KBUILD_AFLAGS_MODULE := -DMODULE KBUILD_CFLAGS_MODULE := -DMODULE KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds GCC_PLUGINS_CFLAGS := +CLANG_FLAGS := export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC export CPP AR NM STRIP OBJCOPY OBJDUMP HOSTLDFLAGS HOST_LOADLIBES @@ -479,7 +480,7 @@ endif ifeq ($(cc-name),clang) ifneq ($(CROSS_COMPILE),) -CLANG_FLAGS := --target=$(notdir $(CROSS_COMPILE:%-=%)) +CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%)) GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit)) CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR) GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..)