From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by sourceware.org (Postfix) with ESMTPS id D3D5A3858D35 for ; Mon, 15 Apr 2024 11:14:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D3D5A3858D35 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=baylibre.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D3D5A3858D35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::32f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713179696; cv=none; b=d4mFOzrBeJZnFAkYNPuPFIeXZR7W+DgSHXvkVfU5++9VShEbvDX81ZVbtu9zjW+BVa5a0Coq8hkribplexo6KSQhN6+Ya4UEDUaQRBlZF0D6uxezhmTXY9YRvUi4qFZL1xvB2Y7gBCpU0Rxg4DLtm5fiSx6qys1hKg0IXKamZt4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713179696; c=relaxed/simple; bh=CWRw3prUCxMkSnnyMUkxXikRfbK1GtcXigRqJztDLy0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=xonwfHHzNcGKL/e6byfQT1WuS8b1L1flJ33Lv4LkEWvyFJjmAnM7jrK04xYACntzdMPOuReaDP3he1IB9hbXm6YYhMHekWlgdQ1BQA4j/3zreSkRPufwPplV6SoM2GppOHHQdY348R1Fy8i9DBNVStcbQ+6QTUrKXWMiB7cowDU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-4167fce0a41so21909585e9.0 for ; Mon, 15 Apr 2024 04:14:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1713179691; x=1713784491; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:user-agent :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yYClkUrgJ/I+3MFEGCMwYiAgi4xpkLjs7DXfHrnHcQw=; b=xh/HYLJszp05Mseg+RSBDnOm3BfHU6yMNovLEPnrJ0mHbVA0PxXt38TcsNEixaj9nw iIMJtnkun6eF/+yHJ2tJyki8XaFNjBVUQ3ZbO8EIs3lOt2J5Rmhrmm89MK8ZQyQsh/Td xdyN4zIYjeWi2OuR8+ao/Viych5pV67VOs0IwkuUYMzLaOz7AOceh27XKA7brBmsWjUy KkwWe9yM5eOW6iucebWfjegA8sUpS2ZmG0uz2wECJ2ZP1qpaH9H3FDSW4ihHoTDUrKHz 4bjpLwm0nChAYDWN0SH6Glel3RC6whh+cPyRzohKcvMb2VOOny9EFvc6LZzByWK6iHFg 43Hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713179691; x=1713784491; h=content-transfer-encoding:mime-version:message-id:date:user-agent :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=yYClkUrgJ/I+3MFEGCMwYiAgi4xpkLjs7DXfHrnHcQw=; b=frEItmQ5K/XidqFO/Yx5Vb0yfZeP5IPKVeq/PEK1XOl7F+m5UY6FFhOznAin3ojJOO p9Z/tmnTdGTA4Ggd9AbPrEuxScHNkwe5QMcNdJHNi77FWLRpEyL4D/xA77nCkpkG1u2n 5n3XaDNA3yhFcZlSBSMBhe1xmv9zCFikQAguYYVup+XdFACgGzO8fbKGXgyR+uUOmQ/q 9kDkWLJKggstHWwCOF0suK5aS0MGyFvqCQyP5AvPyb3Ob5OfqjVCqb5Dr7B72zt72jDE LgxqbsM7yxfAZfBD3bsObkhcVhjQuJXzYvf5qmWvTs+gQSvK2DxyiyIKemM8mQYTFi0M HLxw== X-Forwarded-Encrypted: i=1; AJvYcCXHkS9K4dCj/efQ+fm5klm6nXT3aNnx91C2b18qRio9tXsJzKBCJsrVChkKP84XnQxZPBSvoHOpYayG4Unu6lrTPKVxeA== X-Gm-Message-State: AOJu0Yznzba94BQ5iXrx53SoaoDtFcfblo3dogMSrioIs0qfYDKaTMYG Nqs7iGxuqujHmeVgUu9jPmf4Alk4HdbgAzvLS+JOI/k8srTRaedIOnDXZ7qFRKU= X-Google-Smtp-Source: AGHT+IGts5pmKQtBsU0CB5gEJOs95/xHDq/j80GFCzQTj0LrHfxX7j1x4XHh6fHDVlm//yzMA0ZTMA== X-Received: by 2002:a05:600c:4fc7:b0:417:eb5d:281b with SMTP id o7-20020a05600c4fc700b00417eb5d281bmr8709922wmq.17.1713179691373; Mon, 15 Apr 2024 04:14:51 -0700 (PDT) Received: from euler.schwinge.homeip.net (p200300c8b70ce600fbf8323f8abe0da4.dip0.t-ipconnect.de. [2003:c8:b70c:e600:fbf8:323f:8abe:da4]) by smtp.gmail.com with ESMTPSA id fl14-20020a05600c0b8e00b004184f58dfb9sm5321725wmb.13.2024.04.15.04.14.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 04:14:51 -0700 (PDT) From: Thomas Schwinge To: Pierre-Emmanuel Patry , gcc-patches@gcc.gnu.org, gcc-rust@gcc.gnu.org Cc: Arthur Cohen Subject: Re: [PATCH] build: Check for cargo when building rust language In-Reply-To: <20240408163337.303317-2-pierre-emmanuel.patry@embecosm.com> References: <20240408163337.303317-2-pierre-emmanuel.patry@embecosm.com> User-Agent: Notmuch/0.30+8~g47a4bad (https://notmuchmail.org) Emacs/29.2 (x86_64-pc-linux-gnu) Date: Mon, 15 Apr 2024 13:14:42 +0200 Message-ID: <87edb6ev31.fsf@euler.schwinge.ddns.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi! On 2024-04-08T18:33:38+0200, pierre-emmanuel.patry@embecosm.com wrote: > The rust frontend requires cargo to build some of it's components, In GCC upstream still: 's%requires%is going to require'. ;-) > it's presence was not checked during configuration. After confirming the desired semantics/diagnostics, I've now pushed this to trunk branch in commit 3e1e73fc99584440e5967577f2049573eeaf4596 "build: Check for cargo when building rust language". I now wonder: instead of 'AC_CHECK_TOOL', shouldn't this use 'AC_CHECK_PROG'? (We always want plain 'cargo', not host-prefixed 'aarch64-linux-gnu-cargo' etc., right?) I'll look into changing this. Gr=C3=BC=C3=9Fe Thomas > Prevent rust language from building when cargo is > missing. > > config/ChangeLog: > > * acx.m4: Add a macro to check for rust > components. > > ChangeLog: > > * configure: Regenerate. > * configure.ac: Emit an error message when cargo > is missing. > > Signed-off-by: Pierre-Emmanuel Patry > --- > config/acx.m4 | 11 +++++ > configure | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++ > configure.ac | 18 ++++++++ > 3 files changed, 146 insertions(+) > > diff --git a/config/acx.m4 b/config/acx.m4 > index 7efe98aaf96..3c5fe67342e 100644 > --- a/config/acx.m4 > +++ b/config/acx.m4 > @@ -424,6 +424,17 @@ else > fi > ]) >=20=20 > +# Test for Rust > +# We require cargo and rustc for some parts of the rust compiler. > +AC_DEFUN([ACX_PROG_CARGO], > +[AC_REQUIRE([AC_CHECK_TOOL_PREFIX]) > +AC_CHECK_TOOL(CARGO, cargo, no) > +if test "x$CARGO" !=3D xno; then > + have_cargo=3Dyes > +else > + have_cargo=3Dno > +fi]) > + > # Test for D. > AC_DEFUN([ACX_PROG_GDC], > [AC_REQUIRE([AC_CHECK_TOOL_PREFIX]) > diff --git a/configure b/configure > index 874966fb9f0..46e66e20197 100755 > --- a/configure > +++ b/configure > @@ -714,6 +714,7 @@ PGO_BUILD_GEN_CFLAGS > HAVE_CXX11_FOR_BUILD > HAVE_CXX11 > do_compare > +CARGO > GDC > GNATMAKE > GNATBIND > @@ -5786,6 +5787,104 @@ else > have_gdc=3Dno > fi >=20=20 > + > +if test -n "$ac_tool_prefix"; then > + # Extract the first word of "${ac_tool_prefix}cargo", so it can be a p= rogram name with args. > +set dummy ${ac_tool_prefix}cargo; ac_word=3D$2 > +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 > +$as_echo_n "checking for $ac_word... " >&6; } > +if ${ac_cv_prog_CARGO+:} false; then : > + $as_echo_n "(cached) " >&6 > +else > + if test -n "$CARGO"; then > + ac_cv_prog_CARGO=3D"$CARGO" # Let the user override the test. > +else > +as_save_IFS=3D$IFS; IFS=3D$PATH_SEPARATOR > +for as_dir in $PATH > +do > + IFS=3D$as_save_IFS > + test -z "$as_dir" && as_dir=3D. > + for ac_exec_ext in '' $ac_executable_extensions; do > + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then > + ac_cv_prog_CARGO=3D"${ac_tool_prefix}cargo" > + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exe= c_ext" >&5 > + break 2 > + fi > +done > + done > +IFS=3D$as_save_IFS > + > +fi > +fi > +CARGO=3D$ac_cv_prog_CARGO > +if test -n "$CARGO"; then > + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CARGO" >&5 > +$as_echo "$CARGO" >&6; } > +else > + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 > +$as_echo "no" >&6; } > +fi > + > + > +fi > +if test -z "$ac_cv_prog_CARGO"; then > + ac_ct_CARGO=3D$CARGO > + # Extract the first word of "cargo", so it can be a program name with = args. > +set dummy cargo; ac_word=3D$2 > +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 > +$as_echo_n "checking for $ac_word... " >&6; } > +if ${ac_cv_prog_ac_ct_CARGO+:} false; then : > + $as_echo_n "(cached) " >&6 > +else > + if test -n "$ac_ct_CARGO"; then > + ac_cv_prog_ac_ct_CARGO=3D"$ac_ct_CARGO" # Let the user override the te= st. > +else > +as_save_IFS=3D$IFS; IFS=3D$PATH_SEPARATOR > +for as_dir in $PATH > +do > + IFS=3D$as_save_IFS > + test -z "$as_dir" && as_dir=3D. > + for ac_exec_ext in '' $ac_executable_extensions; do > + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then > + ac_cv_prog_ac_ct_CARGO=3D"cargo" > + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exe= c_ext" >&5 > + break 2 > + fi > +done > + done > +IFS=3D$as_save_IFS > + > +fi > +fi > +ac_ct_CARGO=3D$ac_cv_prog_ac_ct_CARGO > +if test -n "$ac_ct_CARGO"; then > + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CARGO" >&5 > +$as_echo "$ac_ct_CARGO" >&6; } > +else > + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 > +$as_echo "no" >&6; } > +fi > + > + if test "x$ac_ct_CARGO" =3D x; then > + CARGO=3D"no" > + else > + case $cross_compiling:$ac_tool_warned in > +yes:) > +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not = prefixed with host triplet" >&5 > +$as_echo "$as_me: WARNING: using cross tools not prefixed with host trip= let" >&2;} > +ac_tool_warned=3Dyes ;; > +esac > + CARGO=3D$ac_ct_CARGO > + fi > +else > + CARGO=3D"$ac_cv_prog_CARGO" > +fi > + > +if test "x$CARGO" !=3D xno; then > + have_cargo=3Dyes > +else > + have_cargo=3Dno > +fi > { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to compare bootstr= apped objects" >&5 > $as_echo_n "checking how to compare bootstrapped objects... " >&6; } > if ${gcc_cv_prog_cmp_skip+:} false; then : > @@ -9099,6 +9198,24 @@ $as_echo "$as_me: WARNING: --enable-host-shared re= quired to build $language" >&2 > ;; > esac >=20=20 > + # Disable Rust if cargo is unavailable. > + case ${add_this_lang}:${language}:${have_cargo} in > + yes:rust:no) > + # Specifically requested language; tell them. > + as_fn_error $? "cargo is required to build $language" "$LINE= NO" 5 > + ;; > + all:rust:no) > + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cargo is r= equired to build $language" >&5 > +$as_echo "$as_me: WARNING: cargo is required to build $language" >&2;} > + add_this_lang=3Dunsupported > + ;; > + *:rust:no) > + # Silently disable. > + add_this_lang=3Dunsupported > + ;; > + esac > + > + > # Disable a language that is unsupported by the target. > case "${add_this_lang}: $unsupported_languages " in > no:*) ;; > diff --git a/configure.ac b/configure.ac > index 4f34004a072..8c33c89d02c 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -1411,6 +1411,7 @@ fi >=20=20 > ACX_PROG_GNAT > ACX_PROG_GDC > +ACX_PROG_CARGO > ACX_PROG_CMP_IGNORE_INITIAL >=20=20 > AC_ARG_ENABLE([bootstrap], > @@ -2305,6 +2306,23 @@ directories, to avoid imposing the performance cos= t of > ;; > esac >=20=20 > + # Disable Rust if cargo is unavailable. > + case ${add_this_lang}:${language}:${have_cargo} in > + yes:rust:no) > + # Specifically requested language; tell them. > + AC_MSG_ERROR([cargo is required to build $language]) > + ;; > + all:rust:no) > + AC_MSG_WARN([cargo is required to build $language]) > + add_this_lang=3Dunsupported > + ;; > + *:rust:no) > + # Silently disable. > + add_this_lang=3Dunsupported > + ;; > + esac > + > + > # Disable a language that is unsupported by the target. > case "${add_this_lang}: $unsupported_languages " in > no:*) ;; > --=20 > 2.43.0