From patchwork Fri Jun 16 00:16:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miguel Ojeda X-Patchwork-Id: 108768 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp997547vqr; Thu, 15 Jun 2023 17:20:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7RlR4uk8uZSp1rRlebkonigo7YbNJVg+lgcjFM6UUSnhtBXse6orqLlF32vBqgWtdRYqtt X-Received: by 2002:a05:6a20:a10b:b0:11d:9307:8acb with SMTP id q11-20020a056a20a10b00b0011d93078acbmr1018215pzk.45.1686874835601; Thu, 15 Jun 2023 17:20:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686874835; cv=none; d=google.com; s=arc-20160816; b=bd92FuWwy9aMQOVKqrbI6ZVlaFDBaU6JV/GM+XVm9hivxKIfY/F7aBLgyKc4DwWSNM +94Kr5XHul9D3a/gzLJIZskKkblGUtJvRprYJViqRjJO3rDOLil0sjLUyapIlLL89MgX 2cFtGDhvEGuiAsjZpqc1NA0g9bGsPEGhGnLcgJGFRuTdtQZ8g7fkd8etnISc3v+UfNPa nhCdVxejIGUOKJLnlGVxLJhUBRvw0aaVMvcJg6FExwaiy8iaJJ2dJ69Y4A1HKE1szT5O 4MLezU+fGWtqQNMLUQUqnZTVOuPGgv5RWzZC5/sid/vRBH2OAH+f76Ww27Mu/avm+dA7 TpGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZVsDlNWjJoBJQASi6kWL9UKJd/XScm4a0XXTcBPj11w=; b=h3+dcAybOQgHictkyOi8i+naWEvF50A1qkvTejXteSDCBpuczJ2CM+mENtYJIfCplO +rIz4fzdsqj7pPArgIUF0vdD5O1yA+lPaWtTBs7eSFKZEran1V0eGxxabpGJnHaKHRzx xTTfWYRIRsxH5SKr68DmDdbkbL8bGW1xHtGviqPxSiarytG6SVOi7alu9p3oQKKoIUAr Z7XBIwDoU6eVwIirG4OM4lEsuzO6edlbH3OY4rzIPM3X+XnbA7H+PG+vVmkSeRR30EoW Z5WKXGuTQZHwd7kr95epRFSzMKuXhdb06WVVxR91yfu7Gj0o3/UUkMm/+Bh3Ko/v0zbB MWHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GP+1tsVw; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k189-20020a633dc6000000b0053eedcd4d81si13916306pga.101.2023.06.15.17.20.20; Thu, 15 Jun 2023 17:20:35 -0700 (PDT) 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=GP+1tsVw; 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 S240736AbjFPAS5 (ORCPT + 99 others); Thu, 15 Jun 2023 20:18:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239209AbjFPASW (ORCPT ); Thu, 15 Jun 2023 20:18:22 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8442030DB; Thu, 15 Jun 2023 17:17:52 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 384A361CF2; Fri, 16 Jun 2023 00:17:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 829CCC433C0; Fri, 16 Jun 2023 00:17:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686874659; bh=ZOoiskACd1/vXGOYvayiPERAILLvpXavPq6Glrg++uA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GP+1tsVwBh5mcRHiNI5An8ChLve9xO1BdD2bzyC/23Ch3DVUUiG1JKhE8HYRKvSCg YV2dlGjlO/VmOUaUPV1E7Rc8PsHNnO/Fgy7Ca+YPGmlJ2QbdtcgLwkTi54uEVaj3kV rqNjgVp1TlxkqbbrpFYSkuxXT7446WpwD01ShZJrOKd28OyPRPmjfZaNSJQXHKchnr MQDMaaHpqJcnBfX89ysrwQ+iSTZGvbyzZkRoeBJI1kYOfjzmykglvpW+v7Iw0hXKMP 7N1QLfSrvN2FbLhuD5uwUfYutqSV71NWWLpQe4klVWglHxLU4bAq34k+1pVKOv6AXv DI7ok7tmxavmw== From: Miguel Ojeda To: Masahiro Yamada , Miguel Ojeda , Wedson Almeida Filho , Alex Gaynor Cc: Nathan Chancellor , Nick Desaulniers , Nicolas Schier , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Alice Ryhl , Andreas Hindborg , linux-kbuild@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev Subject: [PATCH v2 10/11] kbuild: rust_is_available: check that output looks as expected Date: Fri, 16 Jun 2023 02:16:30 +0200 Message-ID: <20230616001631.463536-11-ojeda@kernel.org> In-Reply-To: <20230616001631.463536-1-ojeda@kernel.org> References: <20230616001631.463536-1-ojeda@kernel.org> MIME-Version: 1.0 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,T_SCC_BODY_TEXT_LINE 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768816467931812568?= X-GMAIL-MSGID: =?utf-8?q?1768816467931812568?= The script already checks for `$RUSTC` and `$BINDGEN` existing and exiting without failure. However, one may still pass an unexpected binary that does not output what the later parsing expects. The script still successfully reports a failure as expected, but the error is confusing. For instance: $ RUSTC=true BINDGEN=bindgen CC=clang scripts/rust_is_available.sh scripts/rust_is_available.sh: 19: arithmetic expression: expecting primary: "100000 * + 100 * + " *** *** Please see Documentation/rust/quick-start.rst for details *** on how to set up the Rust support. *** Thus add an explicit check and a proper message for unexpected output from the called command. Similarly, do so for the `libclang` version parsing, too. Link: https://lore.kernel.org/rust-for-linux/CAK7LNAQYk6s11MASRHW6oxtkqF00EJVqhHOP=5rynWt-QDUsXw@mail.gmail.com/ Signed-off-by: Miguel Ojeda Reviewed-by: Martin Rodriguez Reboredo Reviewed-by: Nathan Chancellor --- scripts/rust_is_available.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/scripts/rust_is_available.sh b/scripts/rust_is_available.sh index da8296cd9b8d..117018946b57 100755 --- a/scripts/rust_is_available.sh +++ b/scripts/rust_is_available.sh @@ -97,6 +97,15 @@ rust_compiler_version=$( \ echo "$rust_compiler_output" \ | sed -nE '1s:.*rustc ([0-9]+\.[0-9]+\.[0-9]+).*:\1:p' ) +if [ -z "$rust_compiler_version" ]; then + echo >&2 "***" + echo >&2 "*** Running '$RUSTC' to check the Rust compiler version did not return" + echo >&2 "*** an expected output. See output and docs below for details:" + echo >&2 "***" + echo >&2 "$rust_compiler_output" + echo >&2 "***" + exit 1 +fi rust_compiler_min_version=$($min_tool_version rustc) rust_compiler_cversion=$(get_canonical_version $rust_compiler_version) rust_compiler_min_cversion=$(get_canonical_version $rust_compiler_min_version) @@ -136,6 +145,15 @@ rust_bindings_generator_version=$( \ echo "$rust_bindings_generator_output" \ | sed -nE '1s:.*bindgen ([0-9]+\.[0-9]+\.[0-9]+).*:\1:p' ) +if [ -z "$rust_bindings_generator_version" ]; then + echo >&2 "***" + echo >&2 "*** Running '$BINDGEN' to check the bindings generator version did not return" + echo >&2 "*** an expected output. See output and docs below for details:" + echo >&2 "***" + echo >&2 "$rust_bindings_generator_output" + echo >&2 "***" + exit 1 +fi rust_bindings_generator_min_version=$($min_tool_version bindgen) rust_bindings_generator_cversion=$(get_canonical_version $rust_bindings_generator_version) rust_bindings_generator_min_cversion=$(get_canonical_version $rust_bindings_generator_min_version) @@ -184,6 +202,16 @@ bindgen_libclang_version=$( \ echo "$bindgen_libclang_output" \ | sed -nE 's:.*clang version ([0-9]+\.[0-9]+\.[0-9]+).*:\1:p' ) +if [ -z "$bindgen_libclang_version" ]; then + echo >&2 "***" + echo >&2 "*** Running '$BINDGEN' to check the libclang version (used by the Rust" + echo >&2 "*** bindings generator) did not return an expected output. See output" + echo >&2 "*** and docs below for details:" + echo >&2 "***" + echo >&2 "$bindgen_libclang_output" + echo >&2 "***" + exit 1 +fi 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)