Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp10509181rwl; Wed, 11 Jan 2023 21:55:39 -0800 (PST) X-Google-Smtp-Source: AMrXdXsz4tMtzVCizn4dwLoh+iUtm8eXQcSguAghcbvO7JxG3FnDmtwgh8BC4XBulIHK+KS/DLhR X-Received: by 2002:a05:6a20:e61a:b0:ac:a4fd:f5bf with SMTP id my26-20020a056a20e61a00b000aca4fdf5bfmr91518812pzb.50.1673502938812; Wed, 11 Jan 2023 21:55:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673502938; cv=none; d=google.com; s=arc-20160816; b=wlKcLcxPWaMfkYIKdIQyS2NeGF2PvNCtbVHQ/TQL+IxScaK2w8GHcoY6xmvmS/IjqI NtgjhDES48/g7N/hx8AAX3FdOmQd2kHU2DNu1qWUmqI1qPQP3L/Six5A4nn1gRZdfTzK sDabyXIytin+S0gcLIcWQEpcRp2vMcVEbXPZWCyj+fT29DrSYejQhrQ8aqZK/ybfbinI 40Ex8GsX9NZMtqHSrZqs2pusyHNn4vr95DYOeV4GLKfrW+2MbDm0ssLD03ZBPY5EUEG1 SbGKek5LV7fZBwFbZ+RrUBCJqjjCrabsE8IylzD0uXtqWYfwegEeDRCRIaJyho/Dr04y GXmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=lQxxEPZPU+OWHLatBLdKJPNtssj1HXDm/nW6wXElhuA=; b=EvVo9j5k3j/BYcOHuiEifzzmy3Z4C4hHNQrhCFM4vueHrcZqEocmuc76Ml0PRg+mbV D90SSesE5KYKgBtfK9gyffkZrc62z72Tn6iFUhYLNxvU8nnUflo7ERJQmvY+8f6S5zzz /R7L2ufRJDipYJZfI+OYAZfGHUalpztjUzP+mK9OH74u22wYmPtaKsFEVdg+avhwP+Rv st9AwR5gpnIHH7IYkTLJ2Hu8nQ8JIZ0d6m0ylmMxugLXbKuSffP4ljwufZl0okKgE3K6 Fyh8rCZho8fpoghm/cu1KlC6Fgp0dh6WeOy2TipOh26qpyJqCTCz7jmi/J7+1ociBde4 r0iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nX+zL4aM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y17-20020a170902b49100b00192b23b8444si14708315plr.109.2023.01.11.21.55.32; Wed, 11 Jan 2023 21:55:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nX+zL4aM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236797AbjALFcr (ORCPT + 53 others); Thu, 12 Jan 2023 00:32:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230008AbjALFco (ORCPT ); Thu, 12 Jan 2023 00:32:44 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25F3B1B9F9; Wed, 11 Jan 2023 21:32:43 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A972261F69; Thu, 12 Jan 2023 05:32:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1C9F9C43392; Thu, 12 Jan 2023 05:32:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673501562; bh=qCsLq3Gwfs2hFBNeQ4DQLdXWHTbkhZv7LAbRhhLeMbo=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=nX+zL4aM18oi3+MFVqnmFJLrPk5GuX57Fz+7L+/q2rotOT0Jt2+0K8V9DEdKljjAH /ZqVrLaJANiko11hSmwWSdEbPH8nTe9uCPdDvwb8+nr3yC9fMq+t7CeXefzuO3ZDlw loE8cdycXnhOSXBcve5BTuwKRRo94qNGOGSCxKkgS915zBssWNy8K5RPL8kUtMp7ZI fAKImse67IcjMnhhVRnNcEUrHqNUm4x/LHVE++F5ZwGKumuTcHlJl+EvnLGrfJcnlp 7kiVOVkhX/Ed8zMfnh1uWnERaCdx/BXe4RTzAR9she1piVKHES4ADw6RIpRevy7YhQ 3QeZ4FgthPTgQ== Received: by mail-oa1-f53.google.com with SMTP id 586e51a60fabf-142b72a728fso17820963fac.9; Wed, 11 Jan 2023 21:32:42 -0800 (PST) X-Gm-Message-State: AFqh2kpGm2H6GqKcRN28hc0EQJ8ICxqZeohpLruPzMNgVj887gtLPLGm kSlYKkhoJOwBuH3G0ksBdLlLog8AcM3Zfcz7vzE= X-Received: by 2002:a05:6870:514c:b0:150:7e4a:2f00 with SMTP id z12-20020a056870514c00b001507e4a2f00mr2614641oak.194.1673501561332; Wed, 11 Jan 2023 21:32:41 -0800 (PST) MIME-Version: 1.0 References: <20230109204520.539080-1-ojeda@kernel.org> <20230109204520.539080-5-ojeda@kernel.org> In-Reply-To: <20230109204520.539080-5-ojeda@kernel.org> From: Masahiro Yamada Date: Thu, 12 Jan 2023 14:32:05 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 5/6] kbuild: rust_is_available: fix confusion when a version appears in the path To: Miguel Ojeda Cc: linux-kbuild@vger.kernel.org, Nathan Chancellor , Nick Desaulniers , Nicolas Schier , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 10, 2023 at 5:46 AM Miguel Ojeda wrote: > > `bindgen`'s output for `libclang`'s version check contains paths, which > in turn may contain strings that look like version numbers [1]: > > .../6.1.0-dev/.../rust_is_available_bindgen_libclang.h:2:9: warning: clang version 11.1.0 [-W#pragma-messages], err: false > > which the script will pick up as the version instead of the latter. > > It is also the case that versions may appear after the actual version > (e.g. distribution's version text), which was the reason behind `head` [2]: > > .../rust-is-available-bindgen-libclang.h:2:9: warning: clang version 13.0.0 (Fedora 13.0.0-3.fc35) [-W#pragma-messages], err: false > > Thus instead ask for a match after the `clang version` string. > > Reported-by: Jordan (@jordanisaacs) > Link: https://github.com/Rust-for-Linux/linux/issues/942 [1] > Link: https://github.com/Rust-for-Linux/linux/pull/789 [2] > Signed-off-by: Miguel Ojeda > --- > scripts/rust_is_available.sh | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/scripts/rust_is_available.sh b/scripts/rust_is_available.sh > index 0c082a248f15..a86659410e48 100755 > --- a/scripts/rust_is_available.sh > +++ b/scripts/rust_is_available.sh > @@ -141,9 +141,7 @@ fi > # of the `libclang` found by the Rust bindings generator is suitable. > bindgen_libclang_version=$( \ > echo "$bindgen_libclang_output" \ > - | grep -F 'clang version ' \ > - | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' \ > - | head -n 1 \ > + | sed -nE 's:.*clang version ([0-9]+\.[0-9]+\.[0-9]+).*:\1:p' > ) > bindgen_libclang_min_version=$($min_tool_version llvm) > bindgen_libclang_cversion=$(get_canonical_version $bindgen_libclang_version) > -- > 2.39.0 > You do not need to fork sed. diff --git a/scripts/rust_is_available.sh b/scripts/rust_is_available.sh index 1f478d7e0f77..ebe427e27379 100755 --- a/scripts/rust_is_available.sh +++ b/scripts/rust_is_available.sh @@ -137,14 +137,9 @@ fi # `bindgen` returned successfully, thus use the output to check that the version # of the `libclang` found by the Rust bindings generator is suitable. -bindgen_libclang_version=$( \ - echo "$bindgen_libclang_output" \ - | grep -F 'clang version ' \ - | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' \ - | head -n 1 \ -) +set -- ${bindgen_libclang_output#**clang version} +bindgen_libclang_cversion=$(get_canonical_version $1) bindgen_libclang_min_version=$($min_tool_version llvm) -bindgen_libclang_cversion=$(get_canonical_version $bindgen_libclang_version) bindgen_libclang_min_cversion=$(get_canonical_version $bindgen_libclang_min_version) if [ "$bindgen_libclang_cversion" -lt "$bindgen_libclang_min_cversion" ]; then echo >&2 "***" -- Best Regards Masahiro Yamada