From patchwork Thu Oct 12 09:22:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 115594 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp1718092qgn; Thu, 12 Oct 2017 02:24:08 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCoQGFkIKupkcPnVeZ1tTHsbpF9DVW9tLuW0o9FY6XMGd7uGuBcIxvzi76g15mitALNoVUS X-Received: by 10.99.168.76 with SMTP id i12mr1574963pgp.427.1507800248792; Thu, 12 Oct 2017 02:24:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507800248; cv=none; d=google.com; s=arc-20160816; b=YVWoTImxCgPdOLOXmJDLn9kqa6Dk2iWWfteZovP0slInOpoeMUqmJTyi5KwOgvYpQv m1HlPNQiMC49Ai1y+uL7vrNgUIHwSwXvnoFSZjwis2evoVkD/WRYp1sG7LLCEc2josXi bVFErbUFK3ZULk9SkogWIVquNKjLBByBZX2RMin7JczQsh6gT4vBkQ9lZ3JRHG6cIrdO my9d/4U8Sy3G/LkhOjSEunsDqgdFqHJVDKysxRB/z6rTs3TKrZZz2R+liZKHD08eEVdf /n9oah0eSxCMQB88xUUOiBTKs+E/qV/2UPTnQr1Ght6vGvjSXQDco9aoSOVyjQvYXbun wnkA== 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:arc-authentication-results; bh=CJrtheQ6GSFW/8qBLctfCe+now8aDTb6VshTAxHj/nQ=; b=Xl3sweXVFlgxCThXBjeFa9Un3oi7Yoq+cqY2VUCqQ16xk8d8S0wr1JSY9Z3A/8nev/ IcEXBAKpykG9keaISIGIO2ezrmP9PQSPzMSomaL6RRlyQzWYjfx4QXk5jstuBpl6m9fn Fej1J4tYk+ViotmEroHyZJt0Uu1vYp0RFhY95apA+aGZDCp1MsheEQCfAI1/ojc+eNb3 +qVGVyhl+4fKT7KWCFoGYOEaSrqBOjKXPkKnGlX9xmJQXlCIDwI2a/mlwL4jUHD4+w5v soc/Ls48gah4/bH5Z7hdSQOUWRDzGw+Bj0Uh9KuyPCTBnfabY8WSw6qWZasSY9vHYav+ 7Yjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=zUuEIMBd; 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 185si929955pfb.265.2017.10.12.02.24.08; Thu, 12 Oct 2017 02:24:08 -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=zUuEIMBd; 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 S1755342AbdJLJYG (ORCPT + 27 others); Thu, 12 Oct 2017 05:24:06 -0400 Received: from conuserg-09.nifty.com ([210.131.2.76]:49843 "EHLO conuserg-09.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752665AbdJLJYE (ORCPT ); Thu, 12 Oct 2017 05:24:04 -0400 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-09.nifty.com with ESMTP id v9C9MSdA020686; Thu, 12 Oct 2017 18:22:28 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com v9C9MSdA020686 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1507800148; bh=CJrtheQ6GSFW/8qBLctfCe+now8aDTb6VshTAxHj/nQ=; h=From:To:Cc:Subject:Date:From; b=zUuEIMBdLzex6ddNQyP2dPWX6dA5pFQSWIDjaFTs6eXpr9bcUQA4eBYqiT092eGj0 L/rKyr0gAvV/j170pghHjZriySeG+w37/99uCmOZtFsbiRbkrTMaT0yLIgxlleYr0A UQkxkD7yd8gn85skusZJiJEOg28LGbq8mVuerZlNwbZtZdFcwjl0gWm/Rm/OswFsLg DXM+0i97K3sKA4yzqqQvJhLBAdW6unp+R9lYAqwJPzHH6ER7MjXylPB+f9LbOs+3N/ KCGFJ9clPAfBojSiW1klg4StwgNbTlt9IvF3plLWhxCfcFoTZh751hyUPnQlY45moT RXa4tIi6v7Spw== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Sam Ravnborg , Douglas Anderson , Masahiro Yamada , Michal Marek , linux-kernel@vger.kernel.org Subject: [PATCH] kbuild: do not call cc-option before KBUILD_CFLAGS initialization Date: Thu, 12 Oct 2017 18:22:25 +0900 Message-Id: <1507800145-29563-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some $(call cc-option,...) are invoked very early, even before KBUILD_CFLAGS, etc. are initialized. The returned string from $(call cc-option,...) depends on KBUILD_CPPFLAGS, KBUILD_CFLAGS, and GCC_PLUGINS_CFLAGS. Since they are exported, they are not empty when the top Makefile is recursively invoked. The recursion occurs in several places. For example, the top Makefile invokes itself for silentoldconfig. "make tinyconfig", "make rpm-pkg" are the cases, too. In those cases, the second call of cc-option from the same line runs a different shell command due to non-pristine KBUILD_CFLAGS. To get the same result all the time, KBUILD_* and GCC_PLUGINS_CFLAGS must be initialized before any call of cc-option. This avoids garbage data in the .cache.mk file. Move all calls of cc-option below the config targets because target compiler flags are unnecessary for Kconfig. Signed-off-by: Masahiro Yamada --- Makefile | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) -- 2.7.4 Reviewed-by: Douglas Anderson diff --git a/Makefile b/Makefile index e5c20ee..2c4a238 100644 --- a/Makefile +++ b/Makefile @@ -392,9 +392,6 @@ LDFLAGS_MODULE = CFLAGS_KERNEL = AFLAGS_KERNEL = LDFLAGS_vmlinux = -CFLAGS_GCOV := -fprofile-arcs -ftest-coverage -fno-tree-loop-im $(call cc-disable-warning,maybe-uninitialized,) -CFLAGS_KCOV := $(call cc-option,-fsanitize-coverage=trace-pc,) - # Use USERINCLUDE when you must reference the UAPI directories only. USERINCLUDE := \ @@ -413,21 +410,19 @@ LINUXINCLUDE := \ -I$(objtree)/include \ $(USERINCLUDE) -KBUILD_CPPFLAGS := -D__KERNEL__ - +KBUILD_AFLAGS := -D__ASSEMBLY__ KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ -fno-strict-aliasing -fno-common -fshort-wchar \ -Werror-implicit-function-declaration \ -Wno-format-security \ - -std=gnu89 $(call cc-option,-fno-PIE) - - + -std=gnu89 +KBUILD_CPPFLAGS := -D__KERNEL__ KBUILD_AFLAGS_KERNEL := KBUILD_CFLAGS_KERNEL := -KBUILD_AFLAGS := -D__ASSEMBLY__ $(call cc-option,-fno-PIE) KBUILD_AFLAGS_MODULE := -DMODULE KBUILD_CFLAGS_MODULE := -DMODULE KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds +GCC_PLUGINS_CFLAGS := export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC export CPP AR NM STRIP OBJCOPY OBJDUMP HOSTLDFLAGS HOST_LOADLIBES @@ -435,7 +430,7 @@ export MAKE AWK GENKSYMS INSTALLKERNEL PERL PYTHON UTS_MACHINE export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS -export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE CFLAGS_GCOV CFLAGS_KCOV CFLAGS_KASAN CFLAGS_UBSAN +export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE CFLAGS_KASAN CFLAGS_UBSAN export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL @@ -607,6 +602,12 @@ endif # Defaults to vmlinux, but the arch makefile usually adds further targets all: vmlinux +KBUILD_CFLAGS += $(call cc-option,-fno-PIE) +KBUILD_AFLAGS += $(call cc-option,-fno-PIE) +CFLAGS_GCOV := -fprofile-arcs -ftest-coverage -fno-tree-loop-im $(call cc-disable-warning,maybe-uninitialized,) +CFLAGS_KCOV := $(call cc-option,-fsanitize-coverage=trace-pc,) +export CFLAGS_GCOV CFLAGS_KCOV + # The arch Makefile can set ARCH_{CPP,A,C}FLAGS to override the default # values of the respective KBUILD_* variables ARCH_CPPFLAGS :=