For -foffload= suggest also 'disable' and 'default' [PR103644]

Message ID 967e5dc9-ed72-a59a-ba9d-6ccac909c5c6@codesourcery.com
State New
Headers
Series For -foffload= suggest also 'disable' and 'default' [PR103644] |

Commit Message

Tobias Burnus Dec. 16, 2021, 9:12 a.m. UTC
  I did run into this when misspelling 'disable':

Currently (with one offload target configured)

$ gcc -foffload=disabled
gcc: error: GCC is not configured to support 'disabled' as offload target
gcc: note: valid offload targets are: amdgcn-amdhsa

or (without offload support)

$ gcc -foffload=disabled
gcc: error: GCC is not configured to support ‘disabled’ as offload target
gcc: note: no offloading targets configured


With the patch:

$ gcc -foffload=disabled
gcc: error: GCC is not configured to support 'disabled' as offload target
gcc: note: valid offload targets are: nvptx-none default disable; did you mean 'disable'?

or

$ gcc -foffload=disabled
gcc: error: GCC is not configured to support ‘disabled’ as offload target
gcc: note: valid offload targets are: default disable; did you mean ‘disable’?

or without hint

$ gcc -foffload=x
gcc: error: GCC is not configured to support ‘x’ as offload target
gcc: note: valid offload targets are: default disable


OK for mainline?

Tobias
-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
  

Comments

Jakub Jelinek Dec. 16, 2021, 9:24 a.m. UTC | #1
On Thu, Dec 16, 2021 at 10:12:24AM +0100, Tobias Burnus wrote:
> I did run into this when misspelling 'disable':
> 
> Currently (with one offload target configured)
> 
> $ gcc -foffload=disabled
> gcc: error: GCC is not configured to support 'disabled' as offload target
> gcc: note: valid offload targets are: amdgcn-amdhsa
> 
> or (without offload support)
> 
> $ gcc -foffload=disabled
> gcc: error: GCC is not configured to support ‘disabled’ as offload target
> gcc: note: no offloading targets configured
> 
> 
> With the patch:
> 
> $ gcc -foffload=disabled
> gcc: error: GCC is not configured to support 'disabled' as offload target
> gcc: note: valid offload targets are: nvptx-none default disable; did you mean 'disable'?
> 
> or
> 
> $ gcc -foffload=disabled
> gcc: error: GCC is not configured to support ‘disabled’ as offload target
> gcc: note: valid offload targets are: default disable; did you mean ‘disable’?
> 
> or without hint
> 
> $ gcc -foffload=x
> gcc: error: GCC is not configured to support ‘x’ as offload target
> gcc: note: valid offload targets are: default disable

Neither default nor disable are valid offload targets, so I think we need
to reword the note. valid ‘-foffload=’ arguments are:
or so?

	Jakub
  
Tobias Burnus Dec. 16, 2021, 9:53 a.m. UTC | #2
On 16.12.21 10:24, Jakub Jelinek wrote:
> Neither default nor disable are valid offload targets, so I think we need
> to reword the note. valid ‘-foffload=’ arguments are:
> or so?

Granted. For the second line, I concur – I am not quite
sure about the first line, i.e.
   gcc: error: GCC is not configured to support ‘nvptx’ as offload target
is nicer than
   gcc: error: GCC is not configured to support ‘nvptx’ as ‘-foffload=’ argument
while for disabled, the second version is better for misspelled arguments like 'disabled'.

I have now used the second version:

gcc: error: GCC is not configured to support ‘disabled’ as ‘-foffload=’ argument
gcc: note: valid ‘-foffload=’ arguments are: default disable; did you mean ‘disable’?

gcc: error: GCC is not configured to support ‘x’ as ‘-foffload=’ argument
gcc: note: valid ‘-foffload=’ arguments are: default disable

Tobias
-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
  
Jakub Jelinek Dec. 16, 2021, 10:15 a.m. UTC | #3
On Thu, Dec 16, 2021 at 10:53:20AM +0100, Tobias Burnus wrote:
> On 16.12.21 10:24, Jakub Jelinek wrote:
> > Neither default nor disable are valid offload targets, so I think we need
> > to reword the note. valid ‘-foffload=’ arguments are:
> > or so?
> 
> Granted. For the second line, I concur – I am not quite
> sure about the first line, i.e.
>   gcc: error: GCC is not configured to support ‘nvptx’ as offload target
> is nicer than
>   gcc: error: GCC is not configured to support ‘nvptx’ as ‘-foffload=’ argument
> while for disabled, the second version is better for misspelled arguments like 'disabled'.
> 
> I have now used the second version:
> 
> gcc: error: GCC is not configured to support ‘disabled’ as ‘-foffload=’ argument
> gcc: note: valid ‘-foffload=’ arguments are: default disable; did you mean ‘disable’?
> 
> gcc: error: GCC is not configured to support ‘x’ as ‘-foffload=’ argument
> gcc: note: valid ‘-foffload=’ arguments are: default disable
> 
> Tobias
> -----------------
> Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955

> For -foffload= suggest also 'disable' and 'default' [PR103644]
> 
> gcc/ChangeLog:
> 
> 	PR driver/103644
> 	* gcc.c (check_offload_target_name): Add 'default' and 'disable'
> 	to the candidate list.

Ok, thanks.

> diff --git a/gcc/gcc.c b/gcc/gcc.c
> index 694c2573109..b75b50b87b2 100644
> --- a/gcc/gcc.c
> +++ b/gcc/gcc.c
> @@ -4017,26 +4017,25 @@ check_offload_target_name (const char *target, ptrdiff_t len)
>        memcpy (cand, OFFLOAD_TARGETS, olen);
>        for (c = strtok (cand, ","); c; c = strtok (NULL, ","))
>  	candidates.safe_push (c);
> +      candidates.safe_push ("default");
> +      candidates.safe_push ("disable");
>  
>        char *target2 = XALLOCAVEC (char, len + 1);
>        memcpy (target2, target, len);
>        target2[len] = '\0';
>  
> -      error ("GCC is not configured to support %qs as offload target", target2);
> +      error ("GCC is not configured to support %qs as %<-foffload=%> argument",
> +	     target2);
>  
> -      if (candidates.is_empty ())
> -	inform (UNKNOWN_LOCATION, "no offloading targets configured");
> +      char *s;
> +      const char *hint = candidates_list_and_hint (target2, s, candidates);
> +      if (hint)
> +	inform (UNKNOWN_LOCATION,
> +		"valid %<-foffload=%> arguments are: %s; "
> +		"did you mean %qs?", s, hint);
>        else
> -	{
> -	  char *s;
> -	  const char *hint = candidates_list_and_hint (target2, s, candidates);
> -	  if (hint)
> -	    inform (UNKNOWN_LOCATION,
> -		    "valid offload targets are: %s; did you mean %qs?", s, hint);
> -	  else
> -	    inform (UNKNOWN_LOCATION, "valid offload targets are: %s", s);
> -	  XDELETEVEC (s);
> -	}
> +	inform (UNKNOWN_LOCATION, "valid %<-foffload=%> arguments are: %s", s);
> +      XDELETEVEC (s);
>        return false;
>      }
>    return true;


	Jakub
  

Patch

For -foffload= suggest also 'disable' and 'default' [PR103644]

gcc/ChangeLog:

	PR driver/103644
	* gcc.c (check_offload_target_name): Add 'default' and 'disable'
	to the candidate list.

diff --git a/gcc/gcc.c b/gcc/gcc.c
index 694c2573109..7eaa7c9d8dc 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -4017,6 +4017,8 @@  check_offload_target_name (const char *target, ptrdiff_t len)
       memcpy (cand, OFFLOAD_TARGETS, olen);
       for (c = strtok (cand, ","); c; c = strtok (NULL, ","))
 	candidates.safe_push (c);
+      candidates.safe_push ("default");
+      candidates.safe_push ("disable");
 
       char *target2 = XALLOCAVEC (char, len + 1);
       memcpy (target2, target, len);
@@ -4024,19 +4026,14 @@  check_offload_target_name (const char *target, ptrdiff_t len)
 
       error ("GCC is not configured to support %qs as offload target", target2);
 
-      if (candidates.is_empty ())
-	inform (UNKNOWN_LOCATION, "no offloading targets configured");
+      char *s;
+      const char *hint = candidates_list_and_hint (target2, s, candidates);
+      if (hint)
+	inform (UNKNOWN_LOCATION,
+		"valid offload targets are: %s; did you mean %qs?", s, hint);
       else
-	{
-	  char *s;
-	  const char *hint = candidates_list_and_hint (target2, s, candidates);
-	  if (hint)
-	    inform (UNKNOWN_LOCATION,
-		    "valid offload targets are: %s; did you mean %qs?", s, hint);
-	  else
-	    inform (UNKNOWN_LOCATION, "valid offload targets are: %s", s);
-	  XDELETEVEC (s);
-	}
+	inform (UNKNOWN_LOCATION, "valid offload targets are: %s", s);
+      XDELETEVEC (s);
       return false;
     }
   return true;