Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1105045pxa; Thu, 20 Aug 2020 02:36:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx0IPAsxJVbc4A0mMdAWjdhv36No1X2bNN3FUB/DZvulFTkBefwqoax2S+a0+NNmAZkr+E6 X-Received: by 2002:aa7:c6c3:: with SMTP id b3mr2041176eds.215.1597916174558; Thu, 20 Aug 2020 02:36:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597916174; cv=none; d=google.com; s=arc-20160816; b=e8Lc75+rXW+a/JrCif8laJo2BQrok3vZ8XKYsHj5tWu5drNwtfyJNHDOX1GnTMDfzq ifMuyyWsWUskxCGfmqJ3Z4kThOV5JJ9iNknwSnlm5FEUeXZPpElo44+KynHpH++tKG2E ba/LZMbStVx30q1nSlUxc5zaIDFwmKOhSB0aN7qzTy4R6R/rqolpXSkfo/QwSVJQ7Hn4 FShw4bezS/hsRQCb6lAKGPQBs7P0kYX42Jqm26cPi1Hh15dA0qoc+s6/GU8mDhK/W6KF fpiLRfZBKxg8qpOJwDqbNdp9+HKP0p48kd7cWeg1WZv0vVZDQVofpuRSh3aYWuoWLMwt 8G1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1OwNae5Z0oQiC4h3Pa3cTa5IDgXOeOkD0IehpanBeag=; b=COxdYHjp0bP67+rOQN82BCEnwqThgZU5ykMXxnhjmehzFEjpjlkbrPhAN1HWgDqJRy dCY3+xeSKzyBZX6Pfw+0AG8G5coslaMsY77Zp93EwjBtFSvx7PFs57hWh/nG4C6HmR1Y Lh4pp6Rk6nm8HJIQLcYGAarkTrAIOZU+koSF8YWSY5bou6Qklm5jGK+c9IIVT2fCktEn 2v+xqywkuSMoEvCuYfMPg8Lw+eRCy+aPFJ40I9FoZA3IbPWrA67J0EKuwqhoNAUF574i gE9RrPCxxTXR8524IVPzfWxGnJT/jZVIE9AjaRuPP0nmj0t4dEl+SgURBO5LLr4GTvFZ r2gQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cnzBBvTd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m21si1071568edr.155.2020.08.20.02.35.50; Thu, 20 Aug 2020 02:36:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cnzBBvTd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728338AbgHTJe6 (ORCPT + 99 others); Thu, 20 Aug 2020 05:34:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:43432 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727822AbgHTJba (ORCPT ); Thu, 20 Aug 2020 05:31:30 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C284B208E4; Thu, 20 Aug 2020 09:31:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597915889; bh=x7h681IlolzOdL7F1weUGqr7IZLFaG+yAVLcUGiSZWo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cnzBBvTdzi5tEank9BHLCXjYRQ4ja7+e23q+Q19HIw3LhzSA15g75c0qVxSQ0jzyf B1Lakafo23nwev2LR8ARPpr/XZG8BGjEHU4gU+wNbmVPUxFy+qmyPJaTq/0fQ99y9m cUj+u78ctmTRRJaerqi/bq8EIVErpFqWlV9zccnM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thomas Hebb , Jiri Olsa , David Carrillo-Cisneros , Ian Rogers , Igor Lubashev , Namhyung Kim , Quentin Monnet , Song Liu , Stephane Eranian , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 5.8 171/232] tools build feature: Use CC and CXX from parent Date: Thu, 20 Aug 2020 11:20:22 +0200 Message-Id: <20200820091621.101308451@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200820091612.692383444@linuxfoundation.org> References: <20200820091612.692383444@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thomas Hebb [ Upstream commit e3232c2f39acafd5a29128425bc30b9884642cfa ] commit c8c188679ccf ("tools build: Use the same CC for feature detection and actual build") changed these assignments from unconditional (:=) to conditional (?=) so that they wouldn't clobber values from the environment. However, conditional assignment does not work properly for variables that Make implicitly sets, among which are CC and CXX. To quote tools/scripts/Makefile.include, which handles this properly: # Makefiles suck: This macro sets a default value of $(2) for the # variable named by $(1), unless the variable has been set by # environment or command line. This is necessary for CC and AR # because make sets default values, so the simpler ?= approach # won't work as expected. In other words, the conditional assignments will not run even if the variables are not overridden in the environment; Make will set CC to "cc" and CXX to "g++" when it starts[1], meaning the variables are not empty by the time the conditional assignments are evaluated. This breaks cross-compilation when CROSS_COMPILE is set but CC isn't, since "cc" gets used for feature detection instead of the cross compiler (and likewise for CXX). To fix the issue, just pass down the values of CC and CXX computed by the parent Makefile, which gets included by the Makefile that actually builds whatever we're detecting features for and so is guaranteed to have good values. This is a better solution anyway, since it means we aren't trying to replicate the logic of the parent build system and so don't risk it getting out of sync. Leave PKG_CONFIG alone, since 1) there's no common logic to compute it in Makefile.include, and 2) it's not an implicit variable, so conditional assignment works properly. [1] https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html Fixes: c8c188679ccf ("tools build: Use the same CC for feature detection and actual build") Signed-off-by: Thomas Hebb Acked-by: Jiri Olsa Cc: David Carrillo-Cisneros Cc: Ian Rogers Cc: Igor Lubashev Cc: Namhyung Kim Cc: Quentin Monnet Cc: Song Liu Cc: Stephane Eranian Cc: thomas hebb Link: http://lore.kernel.org/lkml/0a6e69d1736b0fa231a648f50b0cce5d8a6734ef.1595822871.git.tommyhebb@gmail.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/build/Makefile.feature | 2 +- tools/build/feature/Makefile | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature index cb152370fdefd..774f0b0ca28ac 100644 --- a/tools/build/Makefile.feature +++ b/tools/build/Makefile.feature @@ -8,7 +8,7 @@ endif feature_check = $(eval $(feature_check_code)) define feature_check_code - feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS) $(FEATURE_CHECK_CFLAGS-$(1))" CXXFLAGS="$(EXTRA_CXXFLAGS) $(FEATURE_CHECK_CXXFLAGS-$(1))" LDFLAGS="$(LDFLAGS) $(FEATURE_CHECK_LDFLAGS-$(1))" -C $(feature_dir) $(OUTPUT_FEATURES)test-$1.bin >/dev/null 2>/dev/null && echo 1 || echo 0) + feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CC=$(CC) CXX=$(CXX) CFLAGS="$(EXTRA_CFLAGS) $(FEATURE_CHECK_CFLAGS-$(1))" CXXFLAGS="$(EXTRA_CXXFLAGS) $(FEATURE_CHECK_CXXFLAGS-$(1))" LDFLAGS="$(LDFLAGS) $(FEATURE_CHECK_LDFLAGS-$(1))" -C $(feature_dir) $(OUTPUT_FEATURES)test-$1.bin >/dev/null 2>/dev/null && echo 1 || echo 0) endef feature_set = $(eval $(feature_set_code)) diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile index b1f0321180f5c..93b590d81209c 100644 --- a/tools/build/feature/Makefile +++ b/tools/build/feature/Makefile @@ -74,8 +74,6 @@ FILES= \ FILES := $(addprefix $(OUTPUT),$(FILES)) -CC ?= $(CROSS_COMPILE)gcc -CXX ?= $(CROSS_COMPILE)g++ PKG_CONFIG ?= $(CROSS_COMPILE)pkg-config LLVM_CONFIG ?= llvm-config CLANG ?= clang -- 2.25.1