[Bug rust/114629] rust-ast-resolve-expr contains bloated code for funny_error

2024-04-09 Thread dkm at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114629

--- Comment #7 from Marc Poulhiès  ---
There's no language spec yet, it's WIP:
https://github.com/rust-lang/rust/issues/113527

Currently, the reference is rustc and the goal is to match its current
behavior.

I think the frontend is not listed because it's currently not
enabled/working-enough.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Re: [Bug rust/114629] rust-ast-resolve-expr contains bloated code for funny_error

2024-04-09 Thread Jakub Dupak
There is no specification right now. Just reference implementation. The rustc 
team is working on it, but it will take a long time and it is not a priority.
There is a language reference, but it is far from the completeness you would 
need from specification.

BTW, I think it is funny.

On Tue, 9 Apr 2024, at 02:11, pinskia at gcc dot gnu.org wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114629
> 
> --- Comment #5 from Andrew Pinski  ---
> (In reply to Pierre-Emmanuel Patry from comment #2)
> > I can see the problem with the message, but I don't think we can remove the
> > behavior as we have to match rustc's behavior. The compiler has to ICE when
> > meeting this identifier. I suggest changing the message to rustc's one "It
> > looks like you're trying to break rust; would you like some ICE?" and
> > removing the "gcc" identifier check.
> 
> Really this sounds like a bad idea to copy 100% of what rustc does. Instead we
> should follow the rust language specification (hopefully that actually 
> exists).
> 
> While you are at it, it would be useful to add a link to the rust langauge
> specification (like there is for almost all other languages [I see objective-C
> is not listed]) to https://gcc.gnu.org/readings.html .
> 
> -- 
> You are receiving this mail because:
> You are on the CC list for the bug.


Re: [PATCH] build: Check for cargo when building rust language

2024-04-09 Thread Richard Biener
On Mon, Apr 8, 2024 at 6:39 PM  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.

OK.

Please work on documenting build requirements for rust in doc/install.texi,
look for where Ada build requirements are documented.

Richard.

> 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 @

Re: [PATCH] build: Check for cargo when building rust language

2024-04-09 Thread John Paul Adrian Glaubitz
Hello,

On Mon, 2024-04-08 at 18:33 +0200, pierre-emmanuel.pa...@embecosm.com wrote:
> The rust frontend requires cargo to build some of it's components,
> it's presence was not checked during configuration.

Isn't this creating a hen-and-egg problem? How am I supposed to build a Rust
compiler for a target which is not supported by rustc (yet) when gccrs is
supposed to build-depend on cargo which requires rustc?

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913


Re: [PATCH] build: Check for cargo when building rust language

2024-04-09 Thread Jakub Jelinek
On Tue, Apr 09, 2024 at 09:47:18AM +0200, John Paul Adrian Glaubitz wrote:
> Hello,
> 
> On Mon, 2024-04-08 at 18:33 +0200, pierre-emmanuel.pa...@embecosm.com wrote:
> > The rust frontend requires cargo to build some of it's components,
> > it's presence was not checked during configuration.
> 
> Isn't this creating a hen-and-egg problem? How am I supposed to build a Rust
> compiler for a target which is not supported by rustc (yet) when gccrs is
> supposed to build-depend on cargo which requires rustc?

Cross-compilers?

Jakub



Re: [PATCH] build: Check for cargo when building rust language

2024-04-09 Thread John Paul Adrian Glaubitz
On Tue, 2024-04-09 at 10:00 +0200, Jakub Jelinek wrote:
> On Tue, Apr 09, 2024 at 09:47:18AM +0200, John Paul Adrian Glaubitz wrote:
> > Hello,
> > 
> > On Mon, 2024-04-08 at 18:33 +0200, pierre-emmanuel.pa...@embecosm.com wrote:
> > > The rust frontend requires cargo to build some of it's components,
> > > it's presence was not checked during configuration.
> > 
> > Isn't this creating a hen-and-egg problem? How am I supposed to build a Rust
> > compiler for a target which is not supported by rustc (yet) when gccrs is
> > supposed to build-depend on cargo which requires rustc?
> 
> Cross-compilers?

Well, ok. I had there would be a more convenient solution.

I guess we will have to wait for rustc_codegen_gcc to mature then.

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913


Re: [PATCH] build: Check for cargo when building rust language

2024-04-09 Thread Arthur Cohen

Morning all,

On 4/9/24 09:47, John Paul Adrian Glaubitz wrote:

Hello,

On Mon, 2024-04-08 at 18:33 +0200, pierre-emmanuel.pa...@embecosm.com wrote:

The rust frontend requires cargo to build some of it's components,
it's presence was not checked during configuration.


Isn't this creating a hen-and-egg problem? How am I supposed to build a Rust
compiler for a target which is not supported by rustc (yet) when gccrs is
supposed to build-depend on cargo which requires rustc?

Adrian



Quick reminder in case you haven't seen our Request for Comments on the 
main ML that this is only a temporary solution. Once gccrs can compile 
its dependencies, we'll go through a more "classical" bootstrapping chain.


rustc_codegen_gcc can probably already be used for building these 
dependencies however, if you'd like to have a look at that.


Kindly,

Arthur


Re: [PATCH] build: Check for cargo when building rust language

2024-04-09 Thread Iain Sandoe
Hi Arthur,

> On 9 Apr 2024, at 11:40, Arthur Cohen  wrote:

> On 4/9/24 09:47, John Paul Adrian Glaubitz wrote:
>> Hello,
>> On Mon, 2024-04-08 at 18:33 +0200, pierre-emmanuel.pa...@embecosm.com wrote:
>>> The rust frontend requires cargo to build some of it's components,
>>> it's presence was not checked during configuration.
>> Isn't this creating a hen-and-egg problem? How am I supposed to build a Rust
>> compiler for a target which is not supported by rustc (yet) when gccrs is
>> supposed to build-depend on cargo which requires rustc?
>> Adrian
> 
> Quick reminder in case you haven't seen our Request for Comments on the main 
> ML that this is only a temporary solution. Once gccrs can compile its 
> dependencies, we'll go through a more "classical" bootstrapping chain.


I don’t suppose there’s some way to make a “download prerequisites” action for 
this?

(I realise that the prerequisite might not be available for a given platform - 
but then the configure will then just fail to detect them and carry on).

At the least the build documentation requested should (ideally) try to lower 
the barrier to finding the deps and give reliable sources for them.

> rustc_codegen_gcc can probably already be used for building these 
> dependencies however, if you'd like to have a look at that.

Detailing the verious options would also be a helpful part of the build doc.

thanks
Iain



Re: [PATCH] build: Check for cargo when building rust language

2024-04-09 Thread Arthur Cohen

Hi Iain!

On 4/9/24 10:55, Iain Sandoe wrote:

Hi Arthur,


On 9 Apr 2024, at 11:40, Arthur Cohen  wrote:



On 4/9/24 09:47, John Paul Adrian Glaubitz wrote:

Hello,
On Mon, 2024-04-08 at 18:33 +0200, pierre-emmanuel.pa...@embecosm.com wrote:

The rust frontend requires cargo to build some of it's components,
it's presence was not checked during configuration.

Isn't this creating a hen-and-egg problem? How am I supposed to build a Rust
compiler for a target which is not supported by rustc (yet) when gccrs is
supposed to build-depend on cargo which requires rustc?
Adrian


Quick reminder in case you haven't seen our Request for Comments on the main ML that this 
is only a temporary solution. Once gccrs can compile its dependencies, we'll go through a 
more "classical" bootstrapping chain.



I don’t suppose there’s some way to make a “download prerequisites” action for 
this?


Do you mean downloading cargo/Rust as a prerequisite? I don't believe 
this is being done for GNAT/GDC, but I might be wrong.


If you mean the dependencies for our Rust components, those are 
currently being vendored so that we're able to build them offline. I'll 
push the commits soon.




(I realise that the prerequisite might not be available for a given platform - 
but then the configure will then just fail to detect them and carry on).

At the least the build documentation requested should (ideally) try to lower 
the barrier to finding the deps and give reliable sources for them.


rustc_codegen_gcc can probably already be used for building these dependencies 
however, if you'd like to have a look at that.


Detailing the verious options would also be a helpful part of the build doc.

thanks
Iain



Best,

Arthur


Re: [PATCH] build: Check for cargo when building rust language

2024-04-09 Thread Iain Sandoe
Hi Arthur,

> On 9 Apr 2024, at 13:01, Arthur Cohen  wrote:
> 

> On 4/9/24 10:55, Iain Sandoe wrote:
>> Hi Arthur,
>>> On 9 Apr 2024, at 11:40, Arthur Cohen  wrote:
>>> On 4/9/24 09:47, John Paul Adrian Glaubitz wrote:
 Hello,
 On Mon, 2024-04-08 at 18:33 +0200, pierre-emmanuel.pa...@embecosm.com 
 wrote:
> The rust frontend requires cargo to build some of it's components,
> it's presence was not checked during configuration.
 Isn't this creating a hen-and-egg problem? How am I supposed to build a 
 Rust
 compiler for a target which is not supported by rustc (yet) when gccrs is
 supposed to build-depend on cargo which requires rustc?
 Adrian
>>> 
>>> Quick reminder in case you haven't seen our Request for Comments on the 
>>> main ML that this is only a temporary solution. Once gccrs can compile its 
>>> dependencies, we'll go through a more "classical" bootstrapping chain.
>> I don’t suppose there’s some way to make a “download prerequisites” action 
>> for this?
> 
> Do you mean downloading cargo/Rust as a prerequisite? I don't believe this is 
> being done for GNAT/GDC, but I might be wrong.

No, you are quite correct, but the critical difference is that Ada and D both 
make use of earlier versions of GCC - so that (if one wished to be particular) 
it is possible to start with an earlier version of GCC and work forwards (in 
fact that’s what I’ve [I guess all of us] have done for D … and did a looong 
time ago for Ada).

The difference here is that we need to install an executable from somewhere 
else - and making that as simple and trustworthy as possible seems like a good 
move to encourage folks to build & test rust.

> If you mean the dependencies for our Rust components, those are currently 
> being vendored so that we're able to build them offline. I'll push the 
> commits soon.

OK.. I’m sorry to say this - but what’s actually needed is still a little fuzzy 
to me - but I am happy to wait to read the documentation patch and comment then.

thanks
Iain

> 
>> (I realise that the prerequisite might not be available for a given platform 
>> - but then the configure will then just fail to detect them and carry on).
>> At the least the build documentation requested should (ideally) try to lower 
>> the barrier to finding the deps and give reliable sources for them.
>>> rustc_codegen_gcc can probably already be used for building these 
>>> dependencies however, if you'd like to have a look at that.
>> Detailing the verious options would also be a helpful part of the build doc.
>> thanks
>> Iain
> 
> Best,
> 
> Arthur



[Bug rust/114629] rust-ast-resolve-expr contains bloated code for funny_error

2024-04-09 Thread iains at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114629

--- Comment #8 from Iain Sandoe  ---
(In reply to Andrew Pinski from comment #5)
> (In reply to Pierre-Emmanuel Patry from comment #2)


> While you are at it, it would be useful to add a link to the rust langauge
> specification (like there is for almost all other languages [I see
> objective-C is not listed]) to https://gcc.gnu.org/readings.html .

This is getting a bit off-topic for the current PR - but, for the record, I am
not aware of any formal spec for Objective-C/C++ - the API is described in
Apple's developer documentation and compliance is assessed (at least by me) in
terms of "do we implement the things that we claim, in the same way as the
system compiler"?

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Re: [PATCH] build: Check for cargo when building rust language

2024-04-09 Thread Arthur Cohen




On 4/9/24 12:09, Iain Sandoe wrote:

Hi Arthur,


On 9 Apr 2024, at 13:01, Arthur Cohen  wrote:




On 4/9/24 10:55, Iain Sandoe wrote:

Hi Arthur,

On 9 Apr 2024, at 11:40, Arthur Cohen  wrote:
On 4/9/24 09:47, John Paul Adrian Glaubitz wrote:

Hello,
On Mon, 2024-04-08 at 18:33 +0200, pierre-emmanuel.pa...@embecosm.com wrote:

The rust frontend requires cargo to build some of it's components,
it's presence was not checked during configuration.

Isn't this creating a hen-and-egg problem? How am I supposed to build a Rust
compiler for a target which is not supported by rustc (yet) when gccrs is
supposed to build-depend on cargo which requires rustc?
Adrian


Quick reminder in case you haven't seen our Request for Comments on the main ML that this 
is only a temporary solution. Once gccrs can compile its dependencies, we'll go through a 
more "classical" bootstrapping chain.

I don’t suppose there’s some way to make a “download prerequisites” action for 
this?


Do you mean downloading cargo/Rust as a prerequisite? I don't believe this is 
being done for GNAT/GDC, but I might be wrong.


No, you are quite correct, but the critical difference is that Ada and D both 
make use of earlier versions of GCC - so that (if one wished to be particular) 
it is possible to start with an earlier version of GCC and work forwards (in 
fact that’s what I’ve [I guess all of us] have done for D … and did a looong 
time ago for Ada).

The difference here is that we need to install an executable from somewhere else - 
and making that as simple and trustworthy as possible seems like a good move to 
encourage folks to build & test rust.


Ah, that's fair. I guess it will require some modifications to the 
script though, as I would not want to impose Rust on anyone not looking 
to compile gccrs. I'll add this to the list of things to work on before 
14.1 :)


Thanks!




If you mean the dependencies for our Rust components, those are currently being 
vendored so that we're able to build them offline. I'll push the commits soon.


OK.. I’m sorry to say this - but what’s actually needed is still a little fuzzy 
to me - but I am happy to wait to read the documentation patch and comment then.

thanks
Iain




(I realise that the prerequisite might not be available for a given platform - 
but then the configure will then just fail to detect them and carry on).
At the least the build documentation requested should (ideally) try to lower 
the barrier to finding the deps and give reliable sources for them.

rustc_codegen_gcc can probably already be used for building these dependencies 
however, if you'd like to have a look at that.

Detailing the verious options would also be a helpful part of the build doc.
thanks
Iain


Best,

Arthur




Re: [PATCH] build: Check for cargo when building rust language

2024-04-09 Thread Andrew Pinski
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.

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" != 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 

Re: [PATCH] build: Check for cargo when building rust language

2024-04-09 Thread Arthur Cohen

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