From patchwork Wed Oct 4 03:56:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 114722 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp2632212qgn; Tue, 3 Oct 2017 20:57:51 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBPINWxoddv3ZeYZSyp8mMKPuziORKI9ljwhYtw82boEKmbdnyNQ3DDWoI0tPhrcqUNSv5t X-Received: by 10.159.245.141 with SMTP id a13mr13999540pls.441.1507089471698; Tue, 03 Oct 2017 20:57:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507089471; cv=none; d=google.com; s=arc-20160816; b=E9PgNb9AoG0Q3mHyxbKg1mXPQ43VWbeZOo6KADRGA8PVgg6tXoCY5ZUi7hyVnqO+hv tBDgbm5etJ9pDYsJNaw26Poxnav45Rr+bYfD3RREJawGW5S6t1peTw17RC4QkQ6z9vr5 9fh0s2XnM+dgZXZ3G4JmvTOhkogSCtOExAE9JQFtkJdoFjeD0TjKcaQPElnYyWbc4Eqq WaK0VG8Rdzd+8UPh9eNTxMj2t6vFDkJZYhiV7tS5voJ0HuO1tPHfMtZzmX17Cw/QjNTD YgFRlvR8hGX7RXMj7TTrOgLH56h8RIYmI71BOAYhi8Mj4j5bWOjLt4JPBTwUijWWR9vV i5Zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=RNuM0MTrReCiZBCIb2/oxKdPp6yQ0Y1AAuRaiTLtJss=; b=fU+tqZjoAc5v8yaNhYiIitwepI8dGqp2zOwM4TZg4SRl0C0/GSX2GE1JlomPTOgKQT a8lZ4n4yxrcMo182RePg79FRM9p3vWv75LiS6G21G8c+ivHjhqFbNo5knOn2yhjQzA/s copmX3mUCtfgGXaA4BAReCY16wnErGpc1vyTqd/ygZrBy2axQ0pC3mMU3puiaeKISJXj /riW3wodghm8eR5vXJN5RcvmgiCivpsZdfihJUOVafIJqjhg5JrxNxitEyYXLpVmGtIJ 9i2Kjhgi7hfDJZRI466EftFgZTID917k8DAemzyMcxWw0gG8mAgaB+SbgLr2tnNCzQdl 9ioQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=PaUmGQ2H; 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 n62si11188648pfh.131.2017.10.03.20.57.51; Tue, 03 Oct 2017 20:57:51 -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=PaUmGQ2H; 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 S1752114AbdJDD5h (ORCPT + 26 others); Tue, 3 Oct 2017 23:57:37 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:25229 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751692AbdJDD5c (ORCPT ); Tue, 3 Oct 2017 23:57:32 -0400 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id v943u8Pp001949; Wed, 4 Oct 2017 12:56:10 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com v943u8Pp001949 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1507089371; bh=RNuM0MTrReCiZBCIb2/oxKdPp6yQ0Y1AAuRaiTLtJss=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PaUmGQ2HRp29kH2XIqOjBQtmKTCJI0H002EGXjxQ8hdkRH3H385UhUvdaPxmLOWhE 0zoSKYjsBtk4Nej8EYerpV6MhV9l8YXoM0bqM9A6IzHEblrq1AOIuaStVBBixgRtR5 z5I5L4G9TiwXkHfekjguyASnJXeouxvN3Q8CVnGh35gcPU1+/WblnUo/j3QMhZCc+Z YdUT6hIhJxumvQ9EfbRb6BLPeycnPVbKDEn5L4FGhD1FnM8+evDpKQtDiSdRW3de9H Q2FPrdP86MVBXCl+N3SMQjGNZxdkqQhgAVONLeIP4cPlxllnGY45ZSqo83niZOcKUO JZJ/xG920y8dg== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Douglas Anderson , Sam Ravnborg , linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [RFC PATCH 4/4] kbuild: evaluate cc-option and friends only when building kernel Date: Wed, 4 Oct 2017 12:56:07 +0900 Message-Id: <1507089367-10402-4-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507089367-10402-1-git-send-email-yamada.masahiro@socionext.com> References: <1507089367-10402-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org $(call cc-option,...) is costly because it invokes the C compiler. Given that only some targets need compiler flags, it is pointless to compute them all the time. The variable no-dot-config-targets lists the targets we can run without the .config file, such as "make clean", "make help", etc. My idea is similar here. We can add no-compiler-targets to list the targets we can run without the target compiler information. This includes no-dot-config-targets + config targets + misc. When we run only targets listed in the no-compiler-targets, we can set cc-option and friends to no-op. The hostcc-option is an exception since the host compiler is needed for building fixdep, kconfig, etc. I did not add "dtbs" and "%.dtb" to no-compiler-targets. This is intentional. Theoretically, we can build device tree blobs without the C compiler. It it true that in-kernel DT files are pre-processed by CPP before DTC, but KBUILD_CPPFLAGS is unused. However, for the reason of scripts/dtc/ location, Kbuild descends into scripts/mod/ before the DT build. I do not want to trigger the unrelated re-build of modpost when building DT. Perhaps, we can fix this with further refactoring, but not now. Signed-off-by: Masahiro Yamada --- Makefile | 10 ++++++++++ scripts/Kbuild.include | 14 +++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/Makefile b/Makefile index a4fd682..80e1a38 100644 --- a/Makefile +++ b/Makefile @@ -224,9 +224,13 @@ no-dot-config-targets := clean mrproper distclean \ $(version_h) headers_% archheaders archscripts \ kernelversion %src-pkg +no-compiler-targets := $(no-dot-config-targets) config %config \ + kernelrelease image_name + config-targets := 0 mixed-targets := 0 dot-config := 1 +need-compiler := 1 ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),) ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),) @@ -234,6 +238,12 @@ ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),) endif endif +ifneq ($(filter $(no-compiler-targets), $(MAKECMDGOALS)),) + ifeq ($(filter-out $(no-compiler-targets), $(MAKECMDGOALS)),) + need-compiler := 0 + endif +endif + ifeq ($(KBUILD_EXTMOD),) ifneq ($(filter config %config,$(MAKECMDGOALS)),) config-targets := 1 diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 9ffd3dd..222d0a2 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -96,6 +96,13 @@ try-run = $(shell set -e; \ fi; \ rm -f "$$TMP" "$$TMPO") +# hostcc-option +# Usage: cflags-y += $(call hostcc-option,-march=winchip-c6,-march=i586) +hostcc-option = $(call __cc-option, $(HOSTCC),\ + $(HOSTCFLAGS) $(HOST_EXTRACFLAGS),$(1),$(2)) + +ifeq ($(need-compiler),1) + # as-option # Usage: cflags-y += $(call as-option,-Wa$(comma)-isa=foo,) @@ -123,11 +130,6 @@ CC_OPTION_CFLAGS = $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS)) cc-option = $(call __cc-option, $(CC),\ $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS),$(1),$(2)) -# hostcc-option -# Usage: cflags-y += $(call hostcc-option,-march=winchip-c6,-march=i586) -hostcc-option = $(call __cc-option, $(HOSTCC),\ - $(HOSTCFLAGS) $(HOST_EXTRACFLAGS),$(1),$(2)) - # cc-option-yn # Usage: flag := $(call cc-option-yn,-march=winchip-c6) cc-option-yn = $(call try-run,\ @@ -180,6 +182,8 @@ ld-version = $(shell $(LD) --version | $(srctree)/scripts/ld-version.sh) # Usage: $(call ld-ifversion, -ge, 22252, y) ld-ifversion = $(shell [ $(ld-version) $(1) $(2) ] && echo $(3) || echo $(4)) +endif + ###### ###