From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by sourceware.org (Postfix) with ESMTPS id D6066385840B; Tue, 9 Apr 2024 14:12:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D6066385840B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D6066385840B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1034 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712671944; cv=none; b=ITJLYrG8bMA0npJIlblMq+68yqGH6meCG7h7CNigNGNVkuHEm9BJvv6FchB9EvOt/HjXEB5feJviHg4dJzDQqMKfUOS7km0Po+mmJekktpn0cNpV6U2IbLaNTqeyd1JxdPTAsHSb5RqeMpDygXQD+9tdKWU7IGH+MLCPXWlKu00= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712671944; c=relaxed/simple; bh=kHZA6hFtaHeTmZbDKl4X9Qbq9h7E+b485EXQPCCzuQI=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=h5QYfoPcC+Ssy+RrgYfZfqOakdaDPakMGR0F7IrSO/U2nForzwZfYUgYdNysnJBsRdlwlZncKrMcMWsGyH8nxa8eezYEBX9cOrJ6Ne8F7mjEK33J0dvwnCEOHrChvyuf+U3D4PooKOMIAAGH/EB9Q/TDOlnCIF1wf6lSAARZXPA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-2a58209b159so356802a91.3; Tue, 09 Apr 2024 07:12:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712671941; x=1713276741; darn=gcc.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=SsnTUackSX+868sUF72GLpAevG/y9q7ds6wkTCT2JS4=; b=nr86/e0G5QO8FrxIl/tmbY0dGLn+6rG+A6d3oLGErSRXKb8tvaPGEP9/0Wshbsdvcm h4Ty05KXYOTeJtG+xYEN+v+o+UFlR3HYjl2Fbkda6qX/j6aTXme2yothcsiqCFrcvkzr CqDJaRBfGRtg8qEbYIzRKn8V9JHfxutnWq/fWJNblWbvuJY93hJAmEIkJ04HyfwSuSwj Eq/SlIvbqTYkmF65s+QrH3fF0F/ZUoiJJiT3v4ciy2X9wpqnma5+m0AJhAavzDkgtrl2 GSbrDO4iMttjyCffzvo+WHA+NHrQ8c5V5Id08duI4thbRshkrAIFcHMltVicpAtIv6ze Braw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712671941; x=1713276741; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SsnTUackSX+868sUF72GLpAevG/y9q7ds6wkTCT2JS4=; b=d59ixVW83+TPTbMv6JPC/Sb7/YzefNxk7zf6U0lStyDfG/IT0/TYGqwuRjYdDsnjZV SpMXhhuSFuKVjWl5ZxmH19rDSaPvUl9phOQyw3LB5ZNQksCsYmxPMClWeRt5qwlzrSVK IN0up/4RZu23u349dxOC4HPnkvCeebOHXUdJOkQIh6Cq4C+myMU7LhfvkYK1Me3fclj8 ihwQzXr9TH1q85kdTzcWzjzp5vPLFcDdVXYZH8QXps2Buyu/gtFGECNUg727RmNud5HG PRSk/Trm+psvmxdeWbj75OmSHz/4Sl+NBF8zkScZx7gH/8WnpskmyZ+gLROOxD0DEd/i nBeg== X-Forwarded-Encrypted: i=1; AJvYcCXl7es3IdABPQZnY/zKP1tklFsFf0D5nWX3dp/zxP7j8eK9gnOheVejP9tO+TFuszptPw3NDgHUSbhMg0+hwLSjuwiWfw== X-Gm-Message-State: AOJu0YyTSiU9XoUYWUQiXP3hewULOoKmrOXNRWZ+SNMC1wtl7kAstlU1 A2DEm4X9vkYQJsW8L40Pp2cSm7WjrDS81zShF5CMNx6DjRLXFQRW/0yLnBWmJxlTFws3s5uNfiU kYBvQY84EJ+UBV2OpuFg+dhexNAAVo7kc X-Google-Smtp-Source: AGHT+IEzd8EGdlDQf/luuz6vxRv9bDIX1OSQyCmMtTq7bQM2R+Sgw/HfgtHh61PFztjBmg6LNiXHM3Avkss4p8yCZos= X-Received: by 2002:a17:90a:ce82:b0:2a2:39ac:ab48 with SMTP id g2-20020a17090ace8200b002a239acab48mr9654838pju.5.1712671940688; Tue, 09 Apr 2024 07:12:20 -0700 (PDT) MIME-Version: 1.0 References: <20240408163337.303317-2-pierre-emmanuel.patry@embecosm.com> In-Reply-To: <20240408163337.303317-2-pierre-emmanuel.patry@embecosm.com> From: Andrew Pinski Date: Tue, 9 Apr 2024 07:12:08 -0700 Message-ID: Subject: Re: [PATCH] build: Check for cargo when building rust language To: pierre-emmanuel.patry@embecosm.com Cc: gcc-patches@gcc.gnu.org, gcc-rust@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,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: On Mon, Apr 8, 2024 at 9:39=E2=80=AFAM = wrote: > > From: Pierre-Emmanuel Patry > > Hello, > > The rust frontend requires cargo to build some of it's components, > it's presence was not checked during configuration. NOTE cargo itself is a huge security hole. If anything we should place all of the required dependencies with the specific versions that has been tested on gcc.gnu.org (with md5 sums) and download that instead of depending on some random downloads via cargo. Talk about broken supply chain when things are downloading things randomly off the internet. If there is a way to cache and use those specific versions using cargo, that should be done but I suspect cargo does not work that way. Also any time someone says this is a temporary measure it is NOT and we should never treat it as such unless you already have a patch to remove it. Thanks, Andrew Pinski > > Best regards, > Pierre-Emmanuel > > ---------- > > 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 > ]) > > +# 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 > > + > +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 > > + # 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 > > ACX_PROG_GNAT > ACX_PROG_GDC > +ACX_PROG_CARGO > ACX_PROG_CMP_IGNORE_INITIAL > > AC_ARG_ENABLE([bootstrap], > @@ -2305,6 +2306,23 @@ directories, to avoid imposing the performance cos= t of > ;; > esac > > + # 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:*) ;; > -- > 2.43.0 >