diff mbox

Fix precompiled header for '-' being input file (PR, pch/78970)

Message ID d073288d-54e1-caa9-7e57-39dee23dbc6e@suse.cz
State Superseded
Headers show

Commit Message

Martin Liška Jan. 5, 2017, 10:01 a.m. UTC
On 01/05/2017 10:11 AM, Jakub Jelinek wrote:
> On Thu, Jan 05, 2017 at 10:00:33AM +0100, Martin Liška wrote:

>> Having '-' used as indication that input should be taken from standard input

>> is unfriendly to pch which calculates md5sum of all input file descriptors.

>> With that fdopen fails for STDIN_FILENO. To be honest my patch is just a workaround

>> for the ICE. Is there a better solution for that?

> 

> Shouldn't we just error on trying to create PCH for - ?

> I mean, how are you going to use such a PCH file?  ./- is something

> different from - .


I think we should. I prepared a new version of patch which I've been testing.
Are you fine with the error message?

Martin

> 

> If it makes some sense (I don't see it), then the question is if the stdin

> is seakable or not.  If it is not seakable, don't we reject it already, or

> aren't there other places where we want to seek on it?

> If it is seakable, then you might e.g. just read it into a buffer in a loop

> and md5sum the buffer instead of md5summing the stream.

> 

> 	Jakub

>

Comments

Jakub Jelinek Jan. 5, 2017, 10:09 a.m. UTC | #1
On Thu, Jan 05, 2017 at 11:01:37AM +0100, Martin Liška wrote:
> >From 0e14f21128c7aa67ed0eaa10877323a0b2011b63 Mon Sep 17 00:00:00 2001

> From: marxin <mliska@suse.cz>

> Date: Wed, 4 Jan 2017 16:04:44 +0100

> Subject: [PATCH] Error for '-' as filename of a precompiled header (PR

>  pch/78970)

> 

> gcc/ChangeLog:

> 

> 2017-01-05  Martin Liska  <mliska@suse.cz>

> 

> 	* gcc.c (lookup_compiler): Reject '-' filename for a precompiled

> 	header.

> ---

>  gcc/gcc.c | 14 +++++++++++++-

>  1 file changed, 13 insertions(+), 1 deletion(-)

> 

> diff --git a/gcc/gcc.c b/gcc/gcc.c

> index 8154953eb1d..ea4af119e73 100644

> --- a/gcc/gcc.c

> +++ b/gcc/gcc.c

> @@ -8325,7 +8325,19 @@ lookup_compiler (const char *name, size_t length, const char *language)

>      {

>        for (cp = compilers + n_compilers - 1; cp >= compilers; cp--)

>  	if (cp->suffix[0] == '@' && !strcmp (cp->suffix + 1, language))

> -	  return cp;

> +	  {

> +	    if (name != NULL && strcmp (name, "-") == 0

> +		&& (strcmp (cp->suffix, "@c-header") == 0

> +		    || strcmp (cp->suffix, "@c++-header") == 0))

> +	      {

> +		fatal_error (input_location,

> +			     "can't use '-' as input filename for a "

> +			     "precompiled header");


That would be can%'t

Won't the compiler still ICE if you invoke cc1 or cc1plus rather than the driver?

	Jakub
Andreas Schwab Jan. 5, 2017, 12:05 p.m. UTC | #2
On Jan 05 2017, Jakub Jelinek <jakub@redhat.com> wrote:

> On Thu, Jan 05, 2017 at 11:01:37AM +0100, Martin Liška wrote:

>> diff --git a/gcc/gcc.c b/gcc/gcc.c

>> index 8154953eb1d..ea4af119e73 100644

>> --- a/gcc/gcc.c

>> +++ b/gcc/gcc.c

>> @@ -8325,7 +8325,19 @@ lookup_compiler (const char *name, size_t length, const char *language)

>>      {

>>        for (cp = compilers + n_compilers - 1; cp >= compilers; cp--)

>>  	if (cp->suffix[0] == '@' && !strcmp (cp->suffix + 1, language))

>> -	  return cp;

>> +	  {

>> +	    if (name != NULL && strcmp (name, "-") == 0

>> +		&& (strcmp (cp->suffix, "@c-header") == 0

>> +		    || strcmp (cp->suffix, "@c++-header") == 0))

>> +	      {

>> +		fatal_error (input_location,

>> +			     "can't use '-' as input filename for a "

>> +			     "precompiled header");

>

> That would be can%'t


Better: cannot.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
diff mbox

Patch

From 0e14f21128c7aa67ed0eaa10877323a0b2011b63 Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Wed, 4 Jan 2017 16:04:44 +0100
Subject: [PATCH] Error for '-' as filename of a precompiled header (PR
 pch/78970)

gcc/ChangeLog:

2017-01-05  Martin Liska  <mliska@suse.cz>

	* gcc.c (lookup_compiler): Reject '-' filename for a precompiled
	header.
---
 gcc/gcc.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/gcc/gcc.c b/gcc/gcc.c
index 8154953eb1d..ea4af119e73 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -8325,7 +8325,19 @@  lookup_compiler (const char *name, size_t length, const char *language)
     {
       for (cp = compilers + n_compilers - 1; cp >= compilers; cp--)
 	if (cp->suffix[0] == '@' && !strcmp (cp->suffix + 1, language))
-	  return cp;
+	  {
+	    if (name != NULL && strcmp (name, "-") == 0
+		&& (strcmp (cp->suffix, "@c-header") == 0
+		    || strcmp (cp->suffix, "@c++-header") == 0))
+	      {
+		fatal_error (input_location,
+			     "can't use '-' as input filename for a "
+			     "precompiled header");
+		return 0;
+	      }
+
+	    return cp;
+	  }
 
       error ("language %s not recognized", language);
       return 0;
-- 
2.11.0