diff mbox series

[stage1] Provide warning for missing jobserver.

Message ID 0281e793-09fd-b472-9392-6d2a7c26fe6c@suse.cz
State New
Headers show
Series [stage1] Provide warning for missing jobserver. | expand

Commit Message

Martin Liška March 26, 2020, 9:40 a.m. UTC
Hi.

I'm suggesting to provide a warning when one uses -flto=jobserver
but we can't detect job server for some reason.

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

Ready to be installed in next stage1?
Thanks,
Martin

gcc/ChangeLog:

2020-03-26  Martin Liska  <mliska@suse.cz>

	PR driver/94330
	* lto-wrapper.c (run_gcc): When using -flto=jobserver,
	report warning when the jobserver is not detected.
---
  gcc/lto-wrapper.c | 12 +++++++++---
  1 file changed, 9 insertions(+), 3 deletions(-)

Comments

Jan Hubicka March 26, 2020, 12:42 p.m. UTC | #1
> Hi.
> 
> I'm suggesting to provide a warning when one uses -flto=jobserver
> but we can't detect job server for some reason.
> 
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
> 
> Ready to be installed in next stage1?
> Thanks,
> Martin
> 
> gcc/ChangeLog:
> 
> 2020-03-26  Martin Liska  <mliska@suse.cz>
> 
> 	PR driver/94330
> 	* lto-wrapper.c (run_gcc): When using -flto=jobserver,
> 	report warning when the jobserver is not detected.
This looks like a good idea to me (though I guess Richi needs to approve
it).  I would make message more informative so it is clear that
jobserver is supposed to be provided by GNU make and that we resort
to running in one thread.

Morivation is that prople won't get confused trying to start GCC from
other kind of build systems and also when you cut&paste the command out
the warning should be explicit enough to make you notice that you can
wait for very long time ;)

Honza
> ---
>  gcc/lto-wrapper.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> 

> diff --git a/gcc/lto-wrapper.c b/gcc/lto-wrapper.c
> index 46a88b233f6..6263c164888 100644
> --- a/gcc/lto-wrapper.c
> +++ b/gcc/lto-wrapper.c
> @@ -1473,10 +1473,16 @@ run_gcc (unsigned argc, char *argv[])
>        auto_parallel = 0;
>        parallel = 0;
>      }
> -  else if (!jobserver && jobserver_active_p ())
> +  else
>      {
> -      parallel = 1;
> -      jobserver = 1;
> +      bool active_jobserver = jobserver_active_p ();
> +      if (jobserver && !active_jobserver)
> +	warning (0, "jobserver is not available.");
> +      else if (!jobserver && active_jobserver)
> +	{
> +	  parallel = 1;
> +	  jobserver = 1;
> +	}
>      }
>  
>    if (linker_output)
>
Martin Liška March 26, 2020, 12:49 p.m. UTC | #2
On 3/26/20 1:42 PM, Jan Hubicka wrote:
>> Hi.
>>
>> I'm suggesting to provide a warning when one uses -flto=jobserver
>> but we can't detect job server for some reason.
>>
>> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>>
>> Ready to be installed in next stage1?
>> Thanks,
>> Martin
>>
>> gcc/ChangeLog:
>>
>> 2020-03-26  Martin Liska  <mliska@suse.cz>
>>
>> 	PR driver/94330
>> 	* lto-wrapper.c (run_gcc): When using -flto=jobserver,
>> 	report warning when the jobserver is not detected.
> This looks like a good idea to me (though I guess Richi needs to approve
> it).  I would make message more informative so it is clear that
> jobserver is supposed to be provided by GNU make and that we resort
> to running in one thread.

Feel free to provide a better wording.

> 
> Morivation is that prople won't get confused trying to start GCC from
> other kind of build systems and also when you cut&paste the command out
> the warning should be explicit enough to make you notice that you can
> wait for very long time ;)

Yes, it will be handy for these situations. If possible, I would like to see
it landing in GCC 10. But it's Richi's turn.

Martin

> 
> Honza
>> ---
>>   gcc/lto-wrapper.c | 12 +++++++++---
>>   1 file changed, 9 insertions(+), 3 deletions(-)
>>
>>
> 
>> diff --git a/gcc/lto-wrapper.c b/gcc/lto-wrapper.c
>> index 46a88b233f6..6263c164888 100644
>> --- a/gcc/lto-wrapper.c
>> +++ b/gcc/lto-wrapper.c
>> @@ -1473,10 +1473,16 @@ run_gcc (unsigned argc, char *argv[])
>>         auto_parallel = 0;
>>         parallel = 0;
>>       }
>> -  else if (!jobserver && jobserver_active_p ())
>> +  else
>>       {
>> -      parallel = 1;
>> -      jobserver = 1;
>> +      bool active_jobserver = jobserver_active_p ();
>> +      if (jobserver && !active_jobserver)
>> +	warning (0, "jobserver is not available.");
>> +      else if (!jobserver && active_jobserver)
>> +	{
>> +	  parallel = 1;
>> +	  jobserver = 1;
>> +	}
>>       }
>>   
>>     if (linker_output)
>>
>
Li, Pan2 via Gcc-patches March 28, 2020, 11:51 p.m. UTC | #3
On 3/26/20 3:40 AM, Martin Liška wrote:
> Hi.
> 
> I'm suggesting to provide a warning when one uses -flto=jobserver
> but we can't detect job server for some reason.
> 
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
> 
> Ready to be installed in next stage1?
> Thanks,
> Martin
> 
> gcc/ChangeLog:
> 
> 2020-03-26  Martin Liska  <mliska@suse.cz>
> 
>      PR driver/94330
>      * lto-wrapper.c (run_gcc): When using -flto=jobserver,
>      report warning when the jobserver is not detected.

Sounds like a useful warning.  It would be even better if it said why.
jobserver_active_p() returns false under one of at least three distinct
conditions.  If the function provided a status string in addition to
the boolean result, the string could be included in the text of
the warning.

As an aside, I'd expect -Wformat-diag to complain about the trailing
period:

+	warning (0, "jobserver is not available.");

Martin
Martin Liška March 29, 2020, 5:22 p.m. UTC | #4
On 3/29/20 12:51 AM, Martin Sebor wrote:
> On 3/26/20 3:40 AM, Martin Liška wrote:
>> Hi.
>>
>> I'm suggesting to provide a warning when one uses -flto=jobserver
>> but we can't detect job server for some reason.
>>
>> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>>
>> Ready to be installed in next stage1?
>> Thanks,
>> Martin
>>
>> gcc/ChangeLog:
>>
>> 2020-03-26  Martin Liska  <mliska@suse.cz>
>>
>>      PR driver/94330
>>      * lto-wrapper.c (run_gcc): When using -flto=jobserver,
>>      report warning when the jobserver is not detected.
> 
> Sounds like a useful warning.  It would be even better if it said why.
> jobserver_active_p() returns false under one of at least three distinct
> conditions.  If the function provided a status string in addition to
> the boolean result, the string could be included in the text of
> the warning.
> 
> As an aside, I'd expect -Wformat-diag to complain about the trailing
> period:
> 
> +    warning (0, "jobserver is not available.");
> 
> Martin

Hello.

I like the suggested improvement, there's updated patch that I've just
tested.

Martin
diff mbox series

Patch

diff --git a/gcc/lto-wrapper.c b/gcc/lto-wrapper.c
index 46a88b233f6..6263c164888 100644
--- a/gcc/lto-wrapper.c
+++ b/gcc/lto-wrapper.c
@@ -1473,10 +1473,16 @@  run_gcc (unsigned argc, char *argv[])
       auto_parallel = 0;
       parallel = 0;
     }
-  else if (!jobserver && jobserver_active_p ())
+  else
     {
-      parallel = 1;
-      jobserver = 1;
+      bool active_jobserver = jobserver_active_p ();
+      if (jobserver && !active_jobserver)
+	warning (0, "jobserver is not available.");
+      else if (!jobserver && active_jobserver)
+	{
+	  parallel = 1;
+	  jobserver = 1;
+	}
     }
 
   if (linker_output)