From patchwork Mon Jul 29 09:15:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 169969 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp1011206ile; Mon, 29 Jul 2019 02:16:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqyu+TrBkDrmVrnOQhMdQ/D6oMX79Oi20ztS0SfzXalCmprTiFljOYQgWb6IAGN1JUP6vtJX X-Received: by 2002:a62:8643:: with SMTP id x64mr36580952pfd.7.1564391792222; Mon, 29 Jul 2019 02:16:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564391792; cv=none; d=google.com; s=arc-20160816; b=maUTVlCGVHCsimybjyuZ3+js4tp53VhadKK1hw4t2mqtMLadqinDww14Mx3aKD5AOE CDbAD693T5jcWq6la2cMsalNCZZRzoE9qxL2hlH8j8iY7yBZKb7zT58Hny2emr6vHIiV pB0MhjjHpmRoGL9EQR/B+Tw3pV6LfidHP0lbkS3Lq42NtDnA06zYg2xyyElGMEAybd7c u43OWj5I6Ughux4lo8399g1ySnePMfAJqmOPftm7yaMiyv1Yzt647hd/GILGNA2os2hk 7wrLA59PsKQ/JiIXQkrHUbnx6PJxnQuwAoTIm/X/Q4ugvNR0h1Q+M/AljqOuT5kSO/TO JPog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=16VOGPWZt50QIHw/yZwbKWLNAnF5eIhm7sbfTUqTMxA=; b=kr536fUoMrDkqIgVUq3J66olMRUkHTUp4lXNjjVsRnIlpkj3iC69tUmIzO6RwqNvqr kguOr+Mh+iWwz/SDFyvJgPtYC4DbPFjBtrujd6DZYmMxBVhoEgTtMqJ1iHq8eheZwuR+ vvQ7yMUhihx6b866aizQ0jAANosBHNAF3WiIGxZNRXKkBnJUiOo3cAtfm77+B+/knxJr air3jw363sh3tUT1Z5AEougCl/AsJYaZf7l5FzxNursdBmxQR6HsSMZZ0k2W63CUstaB 4+rxB6AP1QG3BlLyvjftUoRrVdCnkzCnP08b+wDCmq2jrgYNean0bpsqnAZ9e/MsaeEW SBlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b="u/TOvPqs"; 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 v32si24022470plg.3.2019.07.29.02.16.31; Mon, 29 Jul 2019 02:16:32 -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=@nifty.com header.s=dec2015msa header.b="u/TOvPqs"; 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 S1727477AbfG2JQa (ORCPT + 29 others); Mon, 29 Jul 2019 05:16:30 -0400 Received: from conuserg-10.nifty.com ([210.131.2.77]:61233 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726496AbfG2JQ3 (ORCPT ); Mon, 29 Jul 2019 05:16:29 -0400 Received: from localhost.localdomain (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-10.nifty.com with ESMTP id x6T9FQFU007006; Mon, 29 Jul 2019 18:15:26 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com x6T9FQFU007006 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1564391727; bh=16VOGPWZt50QIHw/yZwbKWLNAnF5eIhm7sbfTUqTMxA=; h=From:To:Cc:Subject:Date:From; b=u/TOvPqsajpOhFpabeQCcu9qwyoIyMmujb5rMmt9gB0Wd+b+HQleb4MRmthDq5rGL 9MJfl3XWc796KP5LciGQTI0lDcDnuMBMCX0hsvK0G33oq5rGnxkOD7DAHhd9cWviI9 R9otBuj5iDdjHfKzzE/Ll53q0VQ01ujIpNhDDyiJWbd8s8go7BT3YWNKG4LITpsIJG /y0WY7HleQol3+W8Zu8r85nJofkrjLEvbnTcF/AOyQj/4A+vRYHv+vkT/Xgql+b/ky HfQSevJduCNBLGpsqSuKkt9pUACuU3kTG5QH9i1CZUjx3DuXo7onZNdSRE6GVSfoYT zmkzFARkmZQkQ== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Stephen Boyd , Nick Desaulniers , Nathan Chancellor , Masahiro Yamada , stable@vger.kernel.org, Michal Marek , clang-built-linux@googlegroups.com, linux-kernel@vger.kernel.org Subject: [PATCH] kbuild: initialize CLANG_FLAGS correctly in the top Makefile Date: Mon, 29 Jul 2019 18:15:17 +0900 Message-Id: <20190729091517.5334-1-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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: # v4.20+ Signed-off-by: Masahiro Yamada --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.17.1 Reviewed-by: Nathan Chancellor diff --git a/Makefile b/Makefile index fa0fbe7851ea..5ee6f6889869 100644 --- a/Makefile +++ b/Makefile @@ -472,6 +472,7 @@ KBUILD_CFLAGS_MODULE := -DMODULE KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds KBUILD_LDFLAGS := GCC_PLUGINS_CFLAGS := +CLANG_FLAGS := export ARCH SRCARCH CONFIG_SHELL HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE AS LD CC export CPP AR NM STRIP OBJCOPY OBJDUMP PAHOLE KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS @@ -519,7 +520,7 @@ endif ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep 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)/..)