diff mbox

PATCH: PR driver/47547: WHOPR, can't use /dev/null as an output file

Message ID 20110131190309.GA24032@intel.com
State New
Headers show

Commit Message

H.J. Lu Jan. 31, 2011, 7:03 p.m. UTC
Hi,

HOST_BIT_BUCKET is a special case.  We shouldn't use dump base/dir on it.
Tested on Linux/x86-64.  OK for trunk?

Thanks.

H.J.
---
2011-01-31  H.J. Lu  <hongjiu.lu@intel.com>

	PR driver/47547
	* lto-wrapper.c (run_gcc): Don't add -dumpdir if linker_output
	is HOST_BIT_BUCKET.

	* opts.c (finish_options): Don't add x_aux_base_name if it is
	HOST_BIT_BUCKET.

Comments

Diego Novillo Jan. 31, 2011, 7:09 p.m. UTC | #1
On Mon, Jan 31, 2011 at 14:03, H.J. Lu <hongjiu.lu@intel.com> wrote:

> @@ -392,6 +392,7 @@ run_gcc (unsigned argc, char *argv[])
>   if (linker_output)
>     {
>       char *output_dir, *base, *name;
> +      bool bit_bucket = !strcmp (linker_output, HOST_BIT_BUCKET);

strcmp != 0, please.


> --- a/gcc/opts.c
> +++ b/gcc/opts.c
> @@ -633,7 +633,8 @@ finish_options (struct gcc_options *opts, struct gcc_options *opts_set,
>       if (opts->x_dump_dir_name)
>        opts->x_dump_base_name = concat (opts->x_dump_dir_name,
>                                         opts->x_dump_base_name, NULL);
> -      else if (opts->x_aux_base_name)
> +      else if (opts->x_aux_base_name
> +              && strcmp (opts->x_aux_base_name, HOST_BIT_BUCKET))

Likewise.

Could you also add a test for it?


Diego.
H.J. Lu Jan. 31, 2011, 7:30 p.m. UTC | #2
On Mon, Jan 31, 2011 at 11:09 AM, Diego Novillo <dnovillo@google.com> wrote:
> On Mon, Jan 31, 2011 at 14:03, H.J. Lu <hongjiu.lu@intel.com> wrote:
>
>> @@ -392,6 +392,7 @@ run_gcc (unsigned argc, char *argv[])
>>   if (linker_output)
>>     {
>>       char *output_dir, *base, *name;
>> +      bool bit_bucket = !strcmp (linker_output, HOST_BIT_BUCKET);
>
> strcmp != 0, please.

Will do.

>
>> --- a/gcc/opts.c
>> +++ b/gcc/opts.c
>> @@ -633,7 +633,8 @@ finish_options (struct gcc_options *opts, struct gcc_options *opts_set,
>>       if (opts->x_dump_dir_name)
>>        opts->x_dump_base_name = concat (opts->x_dump_dir_name,
>>                                         opts->x_dump_base_name, NULL);
>> -      else if (opts->x_aux_base_name)
>> +      else if (opts->x_aux_base_name
>> +              && strcmp (opts->x_aux_base_name, HOST_BIT_BUCKET))
>
> Likewise.

Will do.

> Could you also add a test for it?
>

I tried and failed. Since testsuite adds "-o xxxx.S", specify
"-o /dev/null" leads to:

Executing on host: /export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc/build-x86_64-linux/gcc/
/export/gnu/import/git/gcc/gcc/testsuite/gcc.dg/pr47547.c   -O2
-fdump-tree-optimized -S -o /dev/null -S  -m32 -o pr47547.s
(timeout = 300)
spawn -ignore SIGHUP /export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc/build-x86_64-linux/gcc/
/export/gnu/import/git/gcc/gcc/testsuite/gcc.dg/pr47547.c -O2
-fdump-tree-optimized -S -o /dev/null -S -m32 -o pr47547.s^M
cc1: error: output filename specified twice^M
compiler exited with status 1
output is:
cc1: error: output filename specified twice^M

FAIL: gcc.dg/pr47547.c (test for excess errors)
Diego Novillo Jan. 31, 2011, 8:04 p.m. UTC | #3
On Mon, Jan 31, 2011 at 14:30, H.J. Lu <hjl.tools@gmail.com> wrote:

> spawn -ignore SIGHUP /export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc
> -B/export/build/gnu/gcc/build-x86_64-linux/gcc/
> /export/gnu/import/git/gcc/gcc/testsuite/gcc.dg/pr47547.c -O2
> -fdump-tree-optimized -S -o /dev/null -S -m32 -o pr47547.s^M
> cc1: error: output filename specified twice^M
> compiler exited with status 1
> output is:
> cc1: error: output filename specified twice^M

Ah, yes.  One way to support it would be to define a new dg-lto-do
string, say "compile-null", and then handle it in lib/lto.exp around
line 293 with

            if { ![string compare "compile-null" $dgdo] } {
                set compile_type "compile-null"
            }

You will then need to change gcc-dg-test-1 in lib/gcc-dg.exp to handle
"compile-null" similarly to "compile" but with '-o /dev/null'.

I think that should work.


Diego.
H.J. Lu Jan. 31, 2011, 8:22 p.m. UTC | #4
On Mon, Jan 31, 2011 at 12:04 PM, Diego Novillo <dnovillo@google.com> wrote:
> On Mon, Jan 31, 2011 at 14:30, H.J. Lu <hjl.tools@gmail.com> wrote:
>
>> spawn -ignore SIGHUP /export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc
>> -B/export/build/gnu/gcc/build-x86_64-linux/gcc/
>> /export/gnu/import/git/gcc/gcc/testsuite/gcc.dg/pr47547.c -O2
>> -fdump-tree-optimized -S -o /dev/null -S -m32 -o pr47547.s^M
>> cc1: error: output filename specified twice^M
>> compiler exited with status 1
>> output is:
>> cc1: error: output filename specified twice^M
>
> Ah, yes.  One way to support it would be to define a new dg-lto-do
> string, say "compile-null", and then handle it in lib/lto.exp around
> line 293 with
>
>            if { ![string compare "compile-null" $dgdo] } {
>                set compile_type "compile-null"
>            }
>
> You will then need to change gcc-dg-test-1 in lib/gcc-dg.exp to handle
> "compile-null" similarly to "compile" but with '-o /dev/null'.
>
> I think that should work.
>

I can work on that when I find time later.

In the meantime, is that OK without a testcase?
Dave Korn Feb. 1, 2011, 6:14 a.m. UTC | #5
On 31/01/2011 19:30, H.J. Lu wrote:
> On Mon, Jan 31, 2011 at 11:09 AM, Diego Novillo <dnovillo@google.com> wrote:
>> On Mon, Jan 31, 2011 at 14:03, H.J. Lu <hongjiu.lu@intel.com> wrote:
>>
>>> @@ -392,6 +392,7 @@ run_gcc (unsigned argc, char *argv[])
>>>   if (linker_output)
>>>     {
>>>       char *output_dir, *base, *name;
>>> +      bool bit_bucket = !strcmp (linker_output, HOST_BIT_BUCKET);
>> strcmp != 0, please.
> 
> Will do.

  You mean "strcmp == 0" not "!=", in this instance.  (Just in case you didn't
already spot it.)

    cheers,
      DaveK
diff mbox

Patch

diff --git a/gcc/lto-wrapper.c b/gcc/lto-wrapper.c
index 6f106a3..05237db 100644
--- a/gcc/lto-wrapper.c
+++ b/gcc/lto-wrapper.c
@@ -392,6 +392,7 @@  run_gcc (unsigned argc, char *argv[])
   if (linker_output)
     {
       char *output_dir, *base, *name;
+      bool bit_bucket = !strcmp (linker_output, HOST_BIT_BUCKET);
 
       output_dir = xstrdup (linker_output);
       base = output_dir;
@@ -406,8 +407,11 @@  run_gcc (unsigned argc, char *argv[])
 	  static char current_dir[] = { '.', DIR_SEPARATOR, '\0' };
 	  output_dir = current_dir;
 	}
-      *argv_ptr++ = "-dumpdir";
-      *argv_ptr++ = output_dir;
+      if (!bit_bucket)
+	{
+	  *argv_ptr++ = "-dumpdir";
+	  *argv_ptr++ = output_dir;
+	}
 
       *argv_ptr++ = "-dumpbase";
     }
diff --git a/gcc/opts.c b/gcc/opts.c
index b958a09..c9b84af 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -633,7 +633,8 @@  finish_options (struct gcc_options *opts, struct gcc_options *opts_set,
       if (opts->x_dump_dir_name)
 	opts->x_dump_base_name = concat (opts->x_dump_dir_name,
 					 opts->x_dump_base_name, NULL);
-      else if (opts->x_aux_base_name)
+      else if (opts->x_aux_base_name
+	       && strcmp (opts->x_aux_base_name, HOST_BIT_BUCKET))
 	{
 	  const char *aux_base;