Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4235166ybb; Tue, 7 Apr 2020 03:32:24 -0700 (PDT) X-Google-Smtp-Source: APiQypJMZfRp9/rU0PaMe5Tgu9mvyDFbMiOGI9lkXYS78mh+8clHKf3n0G/ulh3yNP4vEJ22qtdk X-Received: by 2002:a9d:6a05:: with SMTP id g5mr981873otn.116.1586255544054; Tue, 07 Apr 2020 03:32:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586255544; cv=none; d=google.com; s=arc-20160816; b=chbCRsu9FvPQkjgkhkZPorZH5OM0wId586zRQTGi96JwphrzqbBsF05SwtcNvrklwL mts3k1IuGsU+kBJO8KWPSbUwkhs8tWAsGyalnCN+dRnS2ZrNxc78Q+0K+1rjYmwsDdDO kd2zRDeyPzRH+GYS6+flBl7lBnAuKfN8vjiuiQCZr2vT+JemvgFdDueShOn0oq/9+OWJ 9kSVAZ7Q4dZk/shbLMldyB427uW+jEC8wiU9+SLVcfQLN9Mq2cN0wrcB/LWB3dcX7Jv5 1mcwKa5/GPN/L59dFgSBIZyt6MX9Dhhut28GAoNTZSLPRN7/Qx9fzQDLtCju7z0U0PDs f8lw== 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=l59Zf+P8oJMpwNJeufUgJnFvShqBddOuFPfzlRPD+XM=; b=g9Y/SW0BHnMav8YUHCISmdk8kqr5w0hZ344axJOqb9z7ydp6hNYZ4fRsO17JTixqEf 75m1LbgVukLBEgs2PqoPsbYgOORLKp0LhmBPfJCMY0p2xuN5C67KOhQQzq6oSiv7x5Th NcZ0EoQMvywDCOmA0Yjr+CvAa4faDPJ++dKEr2w3BxNcRas2N4nZ/Kke4+iiqVK/jbe+ imLOVYpljm5T1mtxNuVpXUZ1cWFkJ1QFzw7l31NgPgoKMp+g2Ck1M7Hj6jd24ozCiAyX 6rWDJIg9fwuHvd5Mu4Z2zCA0ioBaHXpwBHEPgMfTowEERYifHbD21abbLKGLfzDrWxSj siBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=J4OABTXx; 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 i187si520974oif.89.2020.04.07.03.32.12; Tue, 07 Apr 2020 03:32:24 -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=@kernel.org header.s=default header.b=J4OABTXx; 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 S1728483AbgDGKaC (ORCPT + 99 others); Tue, 7 Apr 2020 06:30:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:60164 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726399AbgDGKWm (ORCPT ); Tue, 7 Apr 2020 06:22:42 -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 6901920731; Tue, 7 Apr 2020 10:22:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586254959; bh=JzE8QSLBSji/fwbdetznn6wuAkvze4RHNwUOhEGZU9c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J4OABTXxxmDPnJ6CFZpCh+lEudHFr6SSl5gxXXdYV6YvOVF5hgIkATGAl/tqeiwSi IUGpTmBVc1d+ZvulMstcxl4N7IS+X6oAgclZPRQPnauZqFNrMdPUzfpTWlpQ8MUgkk /Ls0qjEJLBT8d6ybXvcQnyN5ws9XiEtb8djNhlDA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Masahiro Yamada , George Spelvin , Nathan Chancellor , Sasha Levin Subject: [PATCH 5.4 02/36] kconfig: introduce m32-flag and m64-flag Date: Tue, 7 Apr 2020 12:21:35 +0200 Message-Id: <20200407101454.599954642@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200407101454.281052964@linuxfoundation.org> References: <20200407101454.281052964@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: Masahiro Yamada [ Upstream commit 8cc4fd73501d9f1370c3eebb70cfe8cc9e24062b ] When a compiler supports multiple architectures, some compiler features can be dependent on the target architecture. This is typical for Clang, which supports multiple LLVM backends. Even for GCC, we need to take care of biarch compiler cases. It is not a problem when we evaluate cc-option in Makefiles because cc-option is tested against the flag in question + $(KBUILD_CFLAGS). The cc-option in Kconfig, on the other hand, does not accumulate tested flags. Due to this simplification, it could potentially test cc-option against a different target. At first, Kconfig always evaluated cc-option against the host architecture. Since commit e8de12fb7cde ("kbuild: Check for unknown options with cc-option usage in Kconfig and clang"), in case of cross-compiling with Clang, the target triple is correctly passed to Kconfig. The case with biarch GCC (and native build with Clang) is still not handled properly. We need to pass some flags to specify the target machine bit. Due to the design, all the macros in Kconfig are expanded in the parse stage, where we do not know the target bit size yet. For example, arch/x86/Kconfig allows a user to toggle CONFIG_64BIT. If a compiler flag -foo depends on the machine bit, it must be tested twice, one with -m32 and the other with -m64. However, -m32/-m64 are not always recognized. So, this commits adds m64-flag and m32-flag macros. They expand to -m32, -m64, respectively if supported. Or, they expand to an empty string if unsupported. The typical usage is like this: config FOO bool default $(cc-option,$(m64-flag) -foo) if 64BIT default $(cc-option,$(m32-flag) -foo) This is clumsy, but there is no elegant way to handle this in the current static macro expansion. There was discussion for static functions vs dynamic functions. The consensus was to go as far as possible with the static functions. (https://lkml.org/lkml/2018/3/2/22) Signed-off-by: Masahiro Yamada Tested-by: George Spelvin Reviewed-by: Nathan Chancellor Signed-off-by: Sasha Levin --- scripts/Kconfig.include | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/Kconfig.include b/scripts/Kconfig.include index bfb44b265a948..77a69ba9cd198 100644 --- a/scripts/Kconfig.include +++ b/scripts/Kconfig.include @@ -40,3 +40,10 @@ $(error-if,$(success, $(LD) -v | grep -q gold), gold linker '$(LD)' not supporte # gcc version including patch level gcc-version := $(shell,$(srctree)/scripts/gcc-version.sh $(CC)) + +# machine bit flags +# $(m32-flag): -m32 if the compiler supports it, or an empty string otherwise. +# $(m64-flag): -m64 if the compiler supports it, or an empty string otherwise. +cc-option-bit = $(if-success,$(CC) -Werror $(1) -E -x c /dev/null -o /dev/null,$(1)) +m32-flag := $(cc-option-bit,-m32) +m64-flag := $(cc-option-bit,-m64) -- 2.20.1