public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] gcc: Make exec-tool.in handle missing Binutils more gracefully
@ 2024-07-28 14:24 Jonathan Wakely
  2024-07-28 16:08 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Jonathan Wakely @ 2024-07-28 14:24 UTC (permalink / raw)
  To: gcc-patches

Bootstrapped on x86_64-linux and for msp430-elf cross with and without
binutils for the target to verify the error is printed as expected.

The $invoked variable will be one of as, collect-ld, nm, or dsymutil,
i.e. the tool that the script is invoking and wants to exec.

OK for trunk?

-- >8 --

When users try to build a cross-compiler without first installing
binutils they get confusing errors like:
/tmp/gcc-obj/./gcc/as: line 114: exec: -m: invalid option

This is an incredibly common source of questions on gcc-help and IRC,
and bogus bug reports e.g. see PR 116119 for the latest example.

This change adds an explicit check for an empty $original variable and
exits with a user-friendly error.

gcc/ChangeLog:

	* exec-tool.in: Exit with an error if $original is empty.
---
 gcc/exec-tool.in | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/gcc/exec-tool.in b/gcc/exec-tool.in
index 7d152e083a7..2767e1019b8 100644
--- a/gcc/exec-tool.in
+++ b/gcc/exec-tool.in
@@ -81,6 +81,14 @@ case "$invoked" in
     ;;
 esac
 
+if test -z "$original"
+then
+  echo "$0: \$original is unset" >&2
+  echo "This probably means there is no '$invoked' for the target." >&2
+  echo "For a cross-compiler, you probably need to install Binutils first." >&2
+  exit 1
+fi
+
 case "$original" in
   ../*)
     # compute absolute path of the location of this script
-- 
2.45.2


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] gcc: Make exec-tool.in handle missing Binutils more gracefully
  2024-07-28 14:24 [PATCH] gcc: Make exec-tool.in handle missing Binutils more gracefully Jonathan Wakely
@ 2024-07-28 16:08 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2024-07-28 16:08 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: gcc-patches



> Am 28.07.2024 um 16:27 schrieb Jonathan Wakely <jwakely@redhat.com>:
> 
> Bootstrapped on x86_64-linux and for msp430-elf cross with and without
> binutils for the target to verify the error is printed as expected.
> 
> The $invoked variable will be one of as, collect-ld, nm, or dsymutil,
> i.e. the tool that the script is invoking and wants to exec.
> 
> OK for trunk?
> 

Ok

Richard 
> -- >8 --
> 
> When users try to build a cross-compiler without first installing
> binutils they get confusing errors like:
> /tmp/gcc-obj/./gcc/as: line 114: exec: -m: invalid option
> 
> This is an incredibly common source of questions on gcc-help and IRC,
> and bogus bug reports e.g. see PR 116119 for the latest example.
> 
> This change adds an explicit check for an empty $original variable and
> exits with a user-friendly error.
> 
> gcc/ChangeLog:
> 
>    * exec-tool.in: Exit with an error if $original is empty.
> ---
> gcc/exec-tool.in | 8 ++++++++
> 1 file changed, 8 insertions(+)
> 
> diff --git a/gcc/exec-tool.in b/gcc/exec-tool.in
> index 7d152e083a7..2767e1019b8 100644
> --- a/gcc/exec-tool.in
> +++ b/gcc/exec-tool.in
> @@ -81,6 +81,14 @@ case "$invoked" in
>     ;;
> esac
> 
> +if test -z "$original"
> +then
> +  echo "$0: \$original is unset" >&2
> +  echo "This probably means there is no '$invoked' for the target." >&2
> +  echo "For a cross-compiler, you probably need to install Binutils first." >&2
> +  exit 1
> +fi
> +
> case "$original" in
>   ../*)
>     # compute absolute path of the location of this script
> --
> 2.45.2
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-07-28 16:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-28 14:24 [PATCH] gcc: Make exec-tool.in handle missing Binutils more gracefully Jonathan Wakely
2024-07-28 16:08 ` Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).