From patchwork Sat Dec 2 15:52:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Levin, Alexander \(Sasha Levin\)" X-Patchwork-Id: 120420 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp2492105qgn; Sat, 2 Dec 2017 08:04:43 -0800 (PST) X-Google-Smtp-Source: AGs4zMY/S2/6/kRZYK4SuCPJ1W8XqgFD6SDavn2VccNstSRFHzml6lMfl6LB3JzYy+lbF+YuFSNH X-Received: by 10.84.128.2 with SMTP id 2mr9422265pla.238.1512230683564; Sat, 02 Dec 2017 08:04:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512230683; cv=none; d=google.com; s=arc-20160816; b=C4llIrTziqgHM8l1mkZFIqa70jPhHoy4bqOUwLWmN8FT2buBhW3Va59CvbzFIhVM7A 6hrIsViw+pvzJyISXUveljYDnVksH1RP6IFwsB6sJFVN66fNj8Z95Ym7+m77uop88Vvz 9n2Wo7FfWSdn5EVnyWRee3dPgxmvqiJxwcP0pSRmbah8XZAQtWwLvzV/YwSAImQyS+L/ A20mQhXSez5dOUzaDefhvugOwlNW/oPvIWUDMvX8avNqlvlfff2adun8+c6zxSAzrcXw mgsRJxXe91QtdI4TdhDg6Csh57g/DRRR+6y0BjNqBNoLESrkK6ko0eAh/Jv/0iNqSxN4 7JJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:to:cc:from:dkim-signature :dkim-signature:dkim-signature:arc-authentication-results; bh=JPpSGkjuJ9Z+C9NU1VCRfqwRNuhPPiee0+WNVLqwxVk=; b=gGr/uyeWfH0Ts0cSwQvpA6+K/sEYW7EbU/8Gawmykca/tcpKDUq+mqj8BEk1iVMXTZ U9EoOgJ03vSfNs+NQO6Xl4cr6+eA8VRg3EK/KIAcII29+OHUPpJ1xUgdmj2cUc46x7wt azINhhJLKWCroQcXLlU2bHRTm6WLkcchUbs/71RaAXOe4lWfGGxISg0DGJWp0s5Np+Zf 265cFAojlCWDFqN32uSIxosATJbKCwVtXpsxpFXwP9ibNRijwtdJp161uqEK+hpKhRZ6 zuq9IgI6rtRuuPI2robhFZCqpCZ7TgCiUvtb8OBJKxDZDJXTdxyPtGXTxGCGF1g/pAGH Yl2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@verizon.com header.s=corp header.b=obDJE5PT; dkim=fail header.i=@verizon.com header.s=corp header.b=ktYt5Pyq; dkim=fail header.i=@verizon.com header.s=corp header.b=qpljRgOk; 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; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=verizon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d6si3517919pgn.792.2017.12.02.08.04.43; Sat, 02 Dec 2017 08:04:43 -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=fail header.i=@verizon.com header.s=corp header.b=obDJE5PT; dkim=fail header.i=@verizon.com header.s=corp header.b=ktYt5Pyq; dkim=fail header.i=@verizon.com header.s=corp header.b=qpljRgOk; 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; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=verizon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753244AbdLBQEj (ORCPT + 28 others); Sat, 2 Dec 2017 11:04:39 -0500 Received: from omzsmtpe03.verizonbusiness.com ([199.249.25.208]:37349 "EHLO omzsmtpe03.verizonbusiness.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752935AbdLBPyX (ORCPT ); Sat, 2 Dec 2017 10:54:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1512230063; x=1543766063; h=from:cc:to:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=poxyFL6PBBUeC3dWc1mF0Se1vNlu6QVfY0U9ttjobus=; b=obDJE5PTzH6g7s+od3ORPivm9R/D3X7FFuSMZ9i+FA4zgP9BoahZjJxG s2UMaYZoEVhYECaA54uqoVKpXbNrOrE6bk6DvZ9OhBL1wsZohKM2gnIwZ lLkwWPtBnA6RDQbHTxm/uL4R2daeDmzoG8Cn+bbbIYNKCaNBZbgDgv39R g=; Received: from unknown (HELO fldsmtpi02.verizon.com) ([166.68.71.144]) by omzsmtpe03.verizonbusiness.com with ESMTP; 02 Dec 2017 15:54:21 +0000 Received: from rogue-10-255-192-101.rogue.vzwcorp.com (HELO atlantis.verizonwireless.com) ([10.255.192.101]) by fldsmtpi02.verizon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 02 Dec 2017 15:53:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1512230023; x=1543766023; h=from:cc:to:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=poxyFL6PBBUeC3dWc1mF0Se1vNlu6QVfY0U9ttjobus=; b=ktYt5PyqwLtcxq4AbAMDXiVxbkNhV4AFIvRI+sDM+/FUn4/fJubkZRXt DDb9OEXsiWAOKs10pruftowFV69ZbRkBp62dVp6aRQD/yklC/GPWnQVPf OqkN8PpeQfUvB45J5YVuEyyMNiNRw6vl30hBPQvKmdLiS1QfXNkq67kZM o=; Received: from mariner.tdc.vzwcorp.com (HELO eris.verizonwireless.com) ([10.254.88.84]) by atlantis.verizonwireless.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 02 Dec 2017 10:53:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1512230023; x=1543766023; h=to:subject:date:message-id:references:in-reply-to: content-transfer-encoding:mime-version:from:cc; bh=poxyFL6PBBUeC3dWc1mF0Se1vNlu6QVfY0U9ttjobus=; b=qpljRgOkET0Jzv/jpUPBQ/tjJry7VJ6+Q4weV0ePr2Cu2HHiKIMxdbEK 3q/5LVsL0f4cWITmJiPrGKTPapO/A9rMjL13pZh1rUH7yE3bqyIEBkm2K uJLIGAA7JypPP0TilNX6R679JReVSXRbWzyq86aNtQ1p0y4mIz+ZljXsT Y=; From: alexander.levin@verizon.com Cc: Masahiro Yamada , alexander.levin@verizon.com X-Host: mariner.tdc.vzwcorp.com Received: from ohtwi1exh003.uswin.ad.vzwcorp.com ([10.144.218.45]) by eris.verizonwireless.com with ESMTP/TLS/AES128-SHA256; 02 Dec 2017 15:53:43 +0000 Received: from OMZP1LUMXCA20.uswin.ad.vzwcorp.com (144.8.22.198) by OHTWI1EXH003.uswin.ad.vzwcorp.com (10.144.218.45) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sat, 2 Dec 2017 10:53:43 -0500 Received: from OMZP1LUMXCA17.uswin.ad.vzwcorp.com (144.8.22.195) by OMZP1LUMXCA20.uswin.ad.vzwcorp.com (144.8.22.198) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Sat, 2 Dec 2017 09:53:42 -0600 Received: from OMZP1LUMXCA17.uswin.ad.vzwcorp.com ([144.8.22.195]) by OMZP1LUMXCA17.uswin.ad.vzwcorp.com ([144.8.22.195]) with mapi id 15.00.1263.000; Sat, 2 Dec 2017 09:53:42 -0600 To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" Subject: [PATCH AUTOSEL for 4.9 29/33] kbuild: do not call cc-option before KBUILD_CFLAGS initialization Thread-Topic: [PATCH AUTOSEL for 4.9 29/33] kbuild: do not call cc-option before KBUILD_CFLAGS initialization Thread-Index: AQHTa4WNXN5dpjRlhEWxrZMq2gdhKw== Date: Sat, 2 Dec 2017 15:52:27 +0000 Message-ID: <20171202155204.7691-29-alexander.levin@verizon.com> References: <20171202155204.7691-1-alexander.levin@verizon.com> In-Reply-To: <20171202155204.7691-1-alexander.levin@verizon.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.144.60.250] MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Masahiro Yamada [ Upstream commit 433dc2ebe7d17dd21cba7ad5c362d37323592236 ] 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 Reviewed-by: Douglas Anderson Signed-off-by: Sasha Levin --- Makefile | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) -- 2.11.0 diff --git a/Makefile b/Makefile index 8e62f9e2a08c..79104fd025e3 100644 --- a/Makefile +++ b/Makefile @@ -370,9 +370,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 := \ @@ -393,21 +390,19 @@ LINUXINCLUDE := \ LINUXINCLUDE += $(filter-out $(LINUXINCLUDE),$(USERINCLUDE)) -KBUILD_CPPFLAGS := -D__KERNEL__ - +KBUILD_AFLAGS := -D__ASSEMBLY__ KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ -fno-strict-aliasing -fno-common \ -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 := # Read KERNELRELEASE from include/config/kernel.release (if it exists) KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) @@ -420,7 +415,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 @@ -620,6 +615,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 :=