From patchwork Sat Dec 2 15:51:39 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: 120425 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp2503640qgn; Sat, 2 Dec 2017 08:16:48 -0800 (PST) X-Google-Smtp-Source: AGs4zMY5r2PnpAKuRAqik8sJuKMcbd1G6zG+7IRiDByMMamZlCLm2mhn54NO/6qNVbdImD7naYl7 X-Received: by 10.84.131.227 with SMTP id d90mr9335191pld.117.1512231408133; Sat, 02 Dec 2017 08:16:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512231408; cv=none; d=google.com; s=arc-20160816; b=q7aD017LHAyiCTddXwQiM8z2NOVxbyDmeP3gty9PQFYMzr4QaFJ9fDmttLV/3EOrqH fF/2lfAznP4TZHCNojHNOOZ3NqVCQQENm16p2S1Qzt5muzFpvLpT84akT44sSnCNK9GY usl8OIw5oN9A5EAwO1Kl31QOOMWRSXXQInDMFrPk3o3DG2PtE1QVELu8EcUk/5d4pgUB xPtZNNnBsGPhZ5HZyUnlXI2e/QH3h3OhJqrluY/r6E0kN/BnS/hX8XymgLRY7K/ltB9l ilg9ts3qUFRxuMKHirn3NhuPXQmyCuUXIlK92O/LHGaazD23R2x+TqTitt4Y+f4Iv4fq v2fw== 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=7xrWe8G3nY+smf6OpZmq4p/gPOoklU/hKsEYMBBkuGw=; b=HYIFyBm1KX+7xyQAgqeg/4y1F4VJ1Ieo5Gt96QstkKoo1Mvm9xFjPH0vXYQvxwv2jr jtOtqWG/BNnydtNKyYvLbYFbrzfzNITel8lPqfoX+5zS8QWAqEUKzbuxnu1U2IRzDXG8 A9R/fU7EfxAr/pDQBuFeymbS2qdyO/abBdbbF9ExtW2o7964XZda4218pwCmaNh/0YF6 bnUY0qvHg35Oms2e6XrN78nfRv64iegkjZuvuxM2wyy43jhUTZ4QyKDQeludhqOQovHa maGXyZXTuozG/7jIT18FNxZNAc7HULaLmzb1ei9th5lkaq3qDqDAfw1W6H+6XxJxZqZR Xt3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@verizon.com header.s=corp header.b=Lc8SnTca; dkim=fail header.i=@verizon.com header.s=corp header.b=HuAXY0fs; dkim=fail header.i=@verizon.com header.s=corp header.b=qkaM+Ny4; 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 f10si6422023plm.88.2017.12.02.08.16.47; Sat, 02 Dec 2017 08:16:48 -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=Lc8SnTca; dkim=fail header.i=@verizon.com header.s=corp header.b=HuAXY0fs; dkim=fail header.i=@verizon.com header.s=corp header.b=qkaM+Ny4; 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 S1752767AbdLBQQr (ORCPT + 28 others); Sat, 2 Dec 2017 11:16:47 -0500 Received: from omzsmtpe01.verizonbusiness.com ([199.249.25.210]:62168 "EHLO omzsmtpe01.verizonbusiness.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752488AbdLBPwv (ORCPT ); Sat, 2 Dec 2017 10:52:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1512229971; x=1543765971; h=from:cc:to:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=vNyrV1f8qvvwJNA79tD4BWDLRYroj7NLMwmBYgzyl0g=; b=Lc8SnTcakhaVBk91PoXzLRrhmbfT/if1iLAsNi6wy7QfD06ILb+mYazV 1zQFD3zbIFCE86oWxJFtjkZXpi4ZScMmETBOfbXsWjhER7x8AFoWEPrl3 GXquKXwkSGNf4EyQw269+HSt4Rw1n2hN/mgbrg9b46N5DbPUHkKosxKZQ E=; Received: from unknown (HELO fldsmtpi01.verizon.com) ([166.68.71.143]) by omzsmtpe01.verizonbusiness.com with ESMTP; 02 Dec 2017 15:52:46 +0000 Received: from rogue-10-255-192-101.rogue.vzwcorp.com (HELO atlantis.verizonwireless.com) ([10.255.192.101]) by fldsmtpi01.verizon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 02 Dec 2017 15:52:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1512229938; x=1543765938; h=from:cc:to:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=vNyrV1f8qvvwJNA79tD4BWDLRYroj7NLMwmBYgzyl0g=; b=HuAXY0fs2sNfPDG9L8QZo0iNiCXrCK5fbRLMvcmP6edT/MJumDshH0aW mGe6afVc2xJoaDw2JQ7OTALCamgV6GIBmeJQZwaihrkcTM88hJZCVVaA2 Lm0kbmCYqJ2//6ibA922m2TFjUsAJEoMldPoxRpvNshQGk55UXttkcsaG s=; Received: from surveyor.tdc.vzwcorp.com (HELO eris.verizonwireless.com) ([10.254.88.83]) by atlantis.verizonwireless.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 02 Dec 2017 10:52:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1512229938; x=1543765938; h=to:subject:date:message-id:references:in-reply-to: content-transfer-encoding:mime-version:from:cc; bh=vNyrV1f8qvvwJNA79tD4BWDLRYroj7NLMwmBYgzyl0g=; b=qkaM+Ny4G9b4gaZlwcEadSvV3Im4tqDNdK8Ampd7eTkvBpq//UAnNi9q D1YWjZxeR4Ork0uSJXJlF4n9kiTXST/9zRFtERDg0WsRMorXH16JWuYGd yYLpsD+DCPyfIHo2I2vqbsnyFV6yxUOjrC+tFErpl+7RYzHAbWIGlkWpZ Y=; From: alexander.levin@verizon.com Cc: Masahiro Yamada , alexander.levin@verizon.com X-Host: surveyor.tdc.vzwcorp.com Received: from ohtwi1exh002.uswin.ad.vzwcorp.com ([10.144.218.44]) by eris.verizonwireless.com with ESMTP/TLS/AES128-SHA256; 02 Dec 2017 15:52:18 +0000 Received: from OMZP1LUMXCA14.uswin.ad.vzwcorp.com (144.8.22.189) by OHTWI1EXH002.uswin.ad.vzwcorp.com (10.144.218.44) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sat, 2 Dec 2017 10:52:18 -0500 Received: from OMZP1LUMXCA17.uswin.ad.vzwcorp.com (144.8.22.195) by OMZP1LUMXCA14.uswin.ad.vzwcorp.com (144.8.22.189) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Sat, 2 Dec 2017 09:52:17 -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:52:17 -0600 To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" Subject: [PATCH AUTOSEL for 4.14 54/64] kbuild: do not call cc-option before KBUILD_CFLAGS initialization Thread-Topic: [PATCH AUTOSEL for 4.14 54/64] kbuild: do not call cc-option before KBUILD_CFLAGS initialization Thread-Index: AQHTa4Vw0a5nJ1zMfUKf3IQFrg1Fpw== Date: Sat, 2 Dec 2017 15:51:39 +0000 Message-ID: <20171202155101.7573-54-alexander.levin@verizon.com> References: <20171202155101.7573-1-alexander.levin@verizon.com> In-Reply-To: <20171202155101.7573-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 ede4de0d8634..4d04fcd54bae 100644 --- a/Makefile +++ b/Makefile @@ -373,9 +373,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 := \ @@ -394,21 +391,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 := # Read KERNELRELEASE from include/config/kernel.release (if it exists) KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) @@ -421,7 +416,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 @@ -622,6 +617,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 :=