From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by sourceware.org (Postfix) with ESMTPS id CADD4384770C for ; Tue, 9 Apr 2024 14:25:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CADD4384770C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org CADD4384770C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::342 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712672733; cv=none; b=eVlFqqMZ8BKaiINOoT9Q4NIKPsX3yUyz46f7fBRcTd+/D7lHJ5Ph5WzFCzjU73YqloTXKbXWUakGs42GFJy03JU+f+BAeX1BGVd9o/j07JkD5Pa2Wzd+10syrftV0LnG55bJts+pNWpZWteSbdRmb+40l2xoPNC3VhK9YJVzOX4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712672733; c=relaxed/simple; bh=t8gBgVej+s2ltvOMtdXx+W7zse7BYJK0hd4vjgnWlHk=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=oyvsI4CsYcKcehCl+JsO0xCpYGKd6fNaUsAiqn3TFlyl/O77ECCtQ9Ed2MVH+LOCo2iNyZX9qSXocqX9w4BpZ/gPp6ahapNa5CZ3ggJKWVoa1JMlobEdCj2ZQ1hF7r/08yTJ3oCieZ0M/5Dlnp9a/SWcChn7bPqATV8VGEpaS1o= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x342.google.com with SMTP id 5b1f17b1804b1-4166d58a71eso14950685e9.1 for ; Tue, 09 Apr 2024 07:25:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1712672729; x=1713277529; darn=gcc.gnu.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=ZwjY4/tkx7+ps+vDan+VwYlrcmSIGHzQ/dVhlVQdlHo=; b=FbAHvnNvaS1owN11WUnC+MnvQTWDL0U8jc+r9iDWiqKQFmVY8eLqayX2yohZye9zxa myf+RaNhh5iQ9S6Jdr+W9is4YHF3MdgMlLia1Ff+bb/m9ieXA59z25yEVeINBzEktfKK F0j+s5fHyHP6HCFFMKTLzLRb2Q8mx86Qu/GK8j+EgqpNYDvwFngzmE/RSbidCrh/8yBp oMRAjlZGIBvY+ormZHwXJFho+iPLr+SuYOLRoEp/VKmkZi2J1XA+HNuINlzRpi0BPnCc q8ddl+fVI556GuqrIU/O6F6Dm/nf/roPLESKktn6GfD4NNs0dqoQfQf/f1jB+Yc1Xi3W CdHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712672729; x=1713277529; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ZwjY4/tkx7+ps+vDan+VwYlrcmSIGHzQ/dVhlVQdlHo=; b=kAa+78XeP8KH1pO8Jju6e0edEHAqHNpS9dLaTwvf1q4oJohV7pYuQdbofHMGOh8a31 +ovwrwoM2I/cZvkYOholbjlTfZmxgCG0wEYDgE7ja5JXhBJWmUQLzH9Pw1Cp8yJTchyi hNYSD29acy/mofav+HD6T04rJ/kk9X5xsfEJTk5Xm35ncUuj/X1Q5ED4hfWlGOj9Gr4U CtkF4ZLyDIjyKqAdLC0LFuYSyP3emB4wDuw9MVQLnDkzsZQyDck5mXxCBK4wBrYQW6KJ X4WsXjw5/WysmlB2e7Gk0txBILYm/C5mE6jT1z8fFsMw+JzF2vVq8F2XrUeLcrQNWSIQ eVfQ== X-Forwarded-Encrypted: i=1; AJvYcCWJtokXN6kFGJjrCEMmoL5jRIzzc6brqivtcNm84LauA4XVFu6QMvrJkQbDcJQezd43nXD+vSLNf47/ypsHcVW+o5xWWA== X-Gm-Message-State: AOJu0YzS46+U2P+pMAF0JeIsXD0kg/X07CayXDpWFZaBOdgVYz31iUUQ 2hKgj3Yp02QqUTlfWoFb8TMqy6b5EQYADaUcGCLKAL5rg9h6l8bPk9w87Da/yw== X-Google-Smtp-Source: AGHT+IHj17PbHnJVPbfEq2HB3q3EcFhACzgyeUC+oj5nkrXgNOqhTCxqISxzOXjj0fUxqD1Zjr3s0w== X-Received: by 2002:a05:600c:35c6:b0:416:89bc:ded3 with SMTP id r6-20020a05600c35c600b0041689bcded3mr3286234wmq.5.1712672728929; Tue, 09 Apr 2024 07:25:28 -0700 (PDT) Received: from ?IPV6:2a04:cec2:22:4ec2:c376:fd4c:b395:f0a4? ([2a04:cec2:22:4ec2:c376:fd4c:b395:f0a4]) by smtp.gmail.com with ESMTPSA id o16-20020a5d6710000000b00343956e8852sm11601286wru.42.2024.04.09.07.25.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 09 Apr 2024 07:25:28 -0700 (PDT) Message-ID: <90bff6b2-cc96-4cc9-95e8-d7f1baf34ed7@embecosm.com> Date: Tue, 9 Apr 2024 16:25:25 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] build: Check for cargo when building rust language Content-Language: en-US To: Andrew Pinski , pierre-emmanuel.patry@embecosm.com Cc: gcc-patches@gcc.gnu.org, gcc-rust@gcc.gnu.org References: <20240408163337.303317-2-pierre-emmanuel.patry@embecosm.com> From: Arthur Cohen In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 Andrew, On 4/9/24 16:12, Andrew Pinski wrote: > On Mon, Apr 8, 2024 at 9:39 AM 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. There is no need to download things randomly off the internet in order to work with cargo. We have a commit being reviewed which vendors our format parser's two dependencies (libc and unicode functions), and makes it so that cargo builds our components with the --offline flag for no internet access. This will be upstreamed soon. This was a simple one line command and it has been tested on containers without internet access. > > 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. As we talked about yesterday on IRC, cargo does work that way. Sorry if I was unclear. > 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. When the time comes we will be more than happy to remove our dependency on rustc in order to compiler our dependencies with our own Rust front-end. It is one of my objectives, and we're working hard towards making that possible :) Respectfully, Arthur > > > 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" != xno; then >> + have_cargo=yes >> +else >> + have_cargo=no >> +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=no >> fi >> >> + >> +if test -n "$ac_tool_prefix"; then >> + # Extract the first word of "${ac_tool_prefix}cargo", so it can be a program name with args. >> +set dummy ${ac_tool_prefix}cargo; ac_word=$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="$CARGO" # Let the user override the test. >> +else >> +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR >> +for as_dir in $PATH >> +do >> + IFS=$as_save_IFS >> + test -z "$as_dir" && as_dir=. >> + 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="${ac_tool_prefix}cargo" >> + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 >> + break 2 >> + fi >> +done >> + done >> +IFS=$as_save_IFS >> + >> +fi >> +fi >> +CARGO=$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=$CARGO >> + # Extract the first word of "cargo", so it can be a program name with args. >> +set dummy cargo; ac_word=$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="$ac_ct_CARGO" # Let the user override the test. >> +else >> +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR >> +for as_dir in $PATH >> +do >> + IFS=$as_save_IFS >> + test -z "$as_dir" && as_dir=. >> + 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="cargo" >> + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 >> + break 2 >> + fi >> +done >> + done >> +IFS=$as_save_IFS >> + >> +fi >> +fi >> +ac_ct_CARGO=$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" = x; then >> + CARGO="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 triplet" >&2;} >> +ac_tool_warned=yes ;; >> +esac >> + CARGO=$ac_ct_CARGO >> + fi >> +else >> + CARGO="$ac_cv_prog_CARGO" >> +fi >> + >> +if test "x$CARGO" != xno; then >> + have_cargo=yes >> +else >> + have_cargo=no >> +fi >> { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to compare bootstrapped 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 required 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" "$LINENO" 5 >> + ;; >> + all:rust:no) >> + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cargo is required to build $language" >&5 >> +$as_echo "$as_me: WARNING: cargo is required to build $language" >&2;} >> + add_this_lang=unsupported >> + ;; >> + *:rust:no) >> + # Silently disable. >> + add_this_lang=unsupported >> + ;; >> + 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 cost 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=unsupported >> + ;; >> + *:rust:no) >> + # Silently disable. >> + add_this_lang=unsupported >> + ;; >> + esac >> + >> + >> # Disable a language that is unsupported by the target. >> case "${add_this_lang}: $unsupported_languages " in >> no:*) ;; >> -- >> 2.43.0 >>