zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] Use CC to determine if gcc is used
@ 2015-04-26 17:48 Heiko Becker
  2015-04-27  8:47 ` Peter Stephenson
  0 siblings, 1 reply; 10+ messages in thread
From: Heiko Becker @ 2015-04-26 17:48 UTC (permalink / raw)
  To: zsh-workers

I ran into this with gcc-5.1 and CPP set to x86_64-pc-linux-gnu-cpp
which isn't catched by the intended case branch and caused zsh to be
miscompiled in the process.
---
 Src/zsh.mdd | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Src/zsh.mdd b/Src/zsh.mdd
index 71dd613..3c8c355 100644
--- a/Src/zsh.mdd
+++ b/Src/zsh.mdd
@@ -28,8 +28,8 @@ hdrdeps="zshcurses.h zshterm.h"
 # on the option to remove them being the same.
 signames.c: signames1.awk signames2.awk ../config.h @SIGNAL_H@
 	$(AWK) -f $(sdir)/signames1.awk @SIGNAL_H@ >sigtmp.c
-	case "$(CPP)" in \
-	gcc*) \
+	case "$(CC)" in \
+	*gcc*) \
 	$(CPP) -P sigtmp.c >sigtmp.out;; \
 	*) \
 	$(CPP) sigtmp.c >sigtmp.out;; \
-- 
2.3.3


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

* Re: [PATCH] Use CC to determine if gcc is used
  2015-04-26 17:48 [PATCH] Use CC to determine if gcc is used Heiko Becker
@ 2015-04-27  8:47 ` Peter Stephenson
  2015-04-27  9:07   ` Peter Stephenson
  0 siblings, 1 reply; 10+ messages in thread
From: Peter Stephenson @ 2015-04-27  8:47 UTC (permalink / raw)
  To: zsh-workers

On Sun, 26 Apr 2015 19:48:31 +0200
Heiko Becker <heirecka@exherbo.org> wrote:
> I ran into this with gcc-5.1 and CPP set to x86_64-pc-linux-gnu-cpp
> which isn't catched by the intended case branch and caused zsh to be
> miscompiled in the process.
> ---
>  Src/zsh.mdd | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/Src/zsh.mdd b/Src/zsh.mdd
> index 71dd613..3c8c355 100644
> --- a/Src/zsh.mdd
> +++ b/Src/zsh.mdd
> @@ -28,8 +28,8 @@ hdrdeps="zshcurses.h zshterm.h"
>  # on the option to remove them being the same.
>  signames.c: signames1.awk signames2.awk ../config.h @SIGNAL_H@
>  	$(AWK) -f $(sdir)/signames1.awk @SIGNAL_H@ >sigtmp.c
> -	case "$(CPP)" in \
> -	gcc*) \
> +	case "$(CC)" in \
> +	*gcc*) \
>  	$(CPP) -P sigtmp.c >sigtmp.out;; \
>  	*) \
>  	$(CPP) sigtmp.c >sigtmp.out;; \

That's probably OK, but rather than test CC when using CPP, it might be
simpler just to test if $(CPP) contains "gnu" as an alternative to
"gcc"?

I think signames2.awk could probably be smarter as well.  I haven't seen
the problem myself but presumably it must just be a question of ignoring
lines beginning '#[ 	]*[0-9]'?

diff --git a/Src/zsh.mdd b/Src/zsh.mdd
index 71dd613..3159e18 100644
--- a/Src/zsh.mdd
+++ b/Src/zsh.mdd
@@ -29,7 +29,7 @@ hdrdeps="zshcurses.h zshterm.h"
 signames.c: signames1.awk signames2.awk ../config.h @SIGNAL_H@
 	$(AWK) -f $(sdir)/signames1.awk @SIGNAL_H@ >sigtmp.c
 	case "$(CPP)" in \
-	gcc*) \
+	gcc*|*gnu*) \
 	$(CPP) -P sigtmp.c >sigtmp.out;; \
 	*) \
 	$(CPP) sigtmp.c >sigtmp.out;; \


pws


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

* Re: [PATCH] Use CC to determine if gcc is used
  2015-04-27  8:47 ` Peter Stephenson
@ 2015-04-27  9:07   ` Peter Stephenson
  2015-04-27 13:30     ` Daniel Shahaf
  0 siblings, 1 reply; 10+ messages in thread
From: Peter Stephenson @ 2015-04-27  9:07 UTC (permalink / raw)
  To: zsh-workers

On Mon, 27 Apr 2015 09:47:42 +0100
Peter Stephenson <p.stephenson@samsung.com> wrote:
> That's probably OK, but rather than test CC when using CPP, it might be
> simpler just to test if $(CPP) contains "gnu" as an alternative to
> "gcc"?

... Or is this safer?

diff --git a/Src/zsh.mdd b/Src/zsh.mdd
index 71dd613..820fcab 100644
--- a/Src/zsh.mdd
+++ b/Src/zsh.mdd
@@ -28,8 +28,8 @@ hdrdeps="zshcurses.h zshterm.h"
 # on the option to remove them being the same.
 signames.c: signames1.awk signames2.awk ../config.h @SIGNAL_H@
 	$(AWK) -f $(sdir)/signames1.awk @SIGNAL_H@ >sigtmp.c
-	case "$(CPP)" in \
-	gcc*) \
+	case "`$(CPP) --version 2>&1`" in \
+	*GCC*) \
 	$(CPP) -P sigtmp.c >sigtmp.out;; \
 	*) \
 	$(CPP) sigtmp.c >sigtmp.out;; \

pws


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

* Re: [PATCH] Use CC to determine if gcc is used
  2015-04-27  9:07   ` Peter Stephenson
@ 2015-04-27 13:30     ` Daniel Shahaf
  2015-04-27 14:11       ` Peter Stephenson
  0 siblings, 1 reply; 10+ messages in thread
From: Daniel Shahaf @ 2015-04-27 13:30 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: zsh-workers

Peter Stephenson wrote on Mon, Apr 27, 2015 at 10:07:56 +0100:
> On Mon, 27 Apr 2015 09:47:42 +0100
> Peter Stephenson <p.stephenson@samsung.com> wrote:
> > That's probably OK, but rather than test CC when using CPP, it might be
> > simpler just to test if $(CPP) contains "gnu" as an alternative to
> > "gcc"?

What happens if $(CPP) is set to simply the string 'cpp'?

> 
> ... Or is this safer?
> 
> diff --git a/Src/zsh.mdd b/Src/zsh.mdd
> index 71dd613..820fcab 100644
> --- a/Src/zsh.mdd
> +++ b/Src/zsh.mdd
> @@ -28,8 +28,8 @@ hdrdeps="zshcurses.h zshterm.h"
>  # on the option to remove them being the same.
>  signames.c: signames1.awk signames2.awk ../config.h @SIGNAL_H@
>  	$(AWK) -f $(sdir)/signames1.awk @SIGNAL_H@ >sigtmp.c
> -	case "$(CPP)" in \
> -	gcc*) \
> +	case "`$(CPP) --version 2>&1`" in \
> +	*GCC*) \

This would false negative on my system:

	% cpp --version
	cpp (SUSE Linux) 4.8.1 20130909 [gcc-4_8-branch revision 202388]
	Copyright (C) 2013 Free Software Foundation, Inc.
	This is free software; see the source for copying conditions.  There is NO
	warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

On another system I see:

	% cpp --version
	cpp (GCC) 4.2.1 20070831 patched [FreeBSD]
	Copyright (C) 2007 Free Software Foundation, Inc.
	This is free software; see the source for copying conditions.  There is NO
	warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

So I guess the parenthetical is distro-configurable.  The second line
is constant, though.

Or we could bypass the "Is this a GNU CPP" problem entirely:

[[[
diff --git Src/zsh.mdd Src/zsh.mdd
index 71dd613..8b6842d 100644
--- Src/zsh.mdd
+++ Src/zsh.mdd
@@ -28,12 +28,7 @@ hdrdeps="zshcurses.h zshterm.h"
 # on the option to remove them being the same.
 signames.c: signames1.awk signames2.awk ../config.h @SIGNAL_H@
        $(AWK) -f $(sdir)/signames1.awk @SIGNAL_H@ >sigtmp.c
-       case "$(CPP)" in \
-       gcc*) \
-       $(CPP) -P sigtmp.c >sigtmp.out;; \
-       *) \
-       $(CPP) sigtmp.c >sigtmp.out;; \
-       esac
+       $(CPP) sigtmp.c | grep -v '^ *# *line [0-9]\+' >sigtmp.out
        $(AWK) -f $(sdir)/signames2.awk sigtmp.out > $@
        rm -f sigtmp.c sigtmp.out
 
]]]

(Haven't tested this, sorry.)

Daniel

>  	$(CPP) -P sigtmp.c >sigtmp.out;; \
>  	*) \
>  	$(CPP) sigtmp.c >sigtmp.out;; \
> 
> pws


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

* Re: [PATCH] Use CC to determine if gcc is used
  2015-04-27 13:30     ` Daniel Shahaf
@ 2015-04-27 14:11       ` Peter Stephenson
  2015-04-27 16:37         ` Heiko Becker
  0 siblings, 1 reply; 10+ messages in thread
From: Peter Stephenson @ 2015-04-27 14:11 UTC (permalink / raw)
  To: zsh-workers

On Mon, 27 Apr 2015 13:30:33 +0000
Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
> Or we could bypass the "Is this a GNU CPP" problem entirely:
> 
> [[[
> diff --git Src/zsh.mdd Src/zsh.mdd
> index 71dd613..8b6842d 100644
> --- Src/zsh.mdd
> +++ Src/zsh.mdd
> @@ -28,12 +28,7 @@ hdrdeps="zshcurses.h zshterm.h"
>  # on the option to remove them being the same.
>  signames.c: signames1.awk signames2.awk ../config.h @SIGNAL_H@
>         $(AWK) -f $(sdir)/signames1.awk @SIGNAL_H@ >sigtmp.c
> -       case "$(CPP)" in \
> -       gcc*) \
> -       $(CPP) -P sigtmp.c >sigtmp.out;; \
> -       *) \
> -       $(CPP) sigtmp.c >sigtmp.out;; \
> -       esac
> +       $(CPP) sigtmp.c | grep -v '^ *# *line [0-9]\+' >sigtmp.out
>         $(AWK) -f $(sdir)/signames2.awk sigtmp.out > $@
>         rm -f sigtmp.c sigtmp.out
>  
> ]]]

That's what I'm hoping, however I don't know what the problem actually
is, only what works around it.

pws


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

* Re: [PATCH] Use CC to determine if gcc is used
  2015-04-27 14:11       ` Peter Stephenson
@ 2015-04-27 16:37         ` Heiko Becker
  2015-04-27 16:50           ` Peter Stephenson
  0 siblings, 1 reply; 10+ messages in thread
From: Heiko Becker @ 2015-04-27 16:37 UTC (permalink / raw)
  To: zsh-workers

On 04/27/15 16:11, Peter Stephenson wrote:
> On Mon, 27 Apr 2015 13:30:33 +0000
> Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
>> Or we could bypass the "Is this a GNU CPP" problem entirely:
>> [[[
>> diff --git Src/zsh.mdd Src/zsh.mdd
>> index 71dd613..8b6842d 100644
>> --- Src/zsh.mdd
>> +++ Src/zsh.mdd
>> @@ -28,12 +28,7 @@ hdrdeps="zshcurses.h zshterm.h"
>>  # on the option to remove them being the same.
>>  signames.c: signames1.awk signames2.awk ../config.h @SIGNAL_H@
>>         $(AWK) -f $(sdir)/signames1.awk @SIGNAL_H@ >sigtmp.c
>> -       case "$(CPP)" in \
>> -       gcc*) \
>> -       $(CPP) -P sigtmp.c >sigtmp.out;; \
>> -       *) \
>> -       $(CPP) sigtmp.c >sigtmp.out;; \
>> -       esac
>> +       $(CPP) sigtmp.c | grep -v '^ *# *line [0-9]\+' >sigtmp.out
>>         $(AWK) -f $(sdir)/signames2.awk sigtmp.out > $@
>>         rm -f sigtmp.c sigtmp.out

This fails to compile with gcc-5.1:

config.status: creating Src/Makemod
make[2]: Entering directory
'/var/tmp/paludis/build/app-shells-zsh-scm/work/zsh-scm/Src'
make[2]: Leaving directory
'/var/tmp/paludis/build/app-shells-zsh-scm/work/zsh-scm/Src'
Makefile:452: recipe for target 'headers' failed
make[1]: Leaving directory
'/var/tmp/paludis/build/app-shells-zsh-scm/work/zsh-scm/Src'
Makefile:190: recipe for target 'all' failed
Makemod:543: *** missing separator.  Stop.
make[1]: *** [headers] Error 2
make: *** [all] Error 1

-- 
Best regards,
Heiko


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

* Re: [PATCH] Use CC to determine if gcc is used
  2015-04-27 16:37         ` Heiko Becker
@ 2015-04-27 16:50           ` Peter Stephenson
  2015-04-27 16:57             ` Heiko Becker
  0 siblings, 1 reply; 10+ messages in thread
From: Peter Stephenson @ 2015-04-27 16:50 UTC (permalink / raw)
  To: zsh-workers

On Mon, 27 Apr 2015 18:37:15 +0200
Heiko Becker <mail@heiko-becker.de> wrote:
> This fails to compile with gcc-5.1:

Please could you tell us what the underlying problem is (I mean that the
first patch was trying to fix)?  Then we can fix it properly.  All I
know is it fails somehow --- you said "miscompiled".  If we know how we
ought to be able to stop playing games with versions of CPP (presumably...)

Thanks
pws


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

* Re: [PATCH] Use CC to determine if gcc is used
  2015-04-27 16:50           ` Peter Stephenson
@ 2015-04-27 16:57             ` Heiko Becker
  2015-04-27 17:09               ` Peter Stephenson
  0 siblings, 1 reply; 10+ messages in thread
From: Heiko Becker @ 2015-04-27 16:57 UTC (permalink / raw)
  To: zsh-workers

On 04/27/15 18:50, Peter Stephenson wrote:
> On Mon, 27 Apr 2015 18:37:15 +0200
> Please could you tell us what the underlying problem is (I mean that the
> first patch was trying to fix)?  Then we can fix it properly.  All I
> know is it fails somehow --- you said "miscompiled".  If we know how we
> ought to be able to stop playing games with versions of CPP (presumably...)

Same problem as described here:
http://www.zsh.org/mla/workers/2015/msg00211.html
or here:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=%2064604

When tab-completing something I get the following error
"_main_complete:trap:131: undefined signal: INT".
zsh also crashes on startup if used with konsole.

-- 
Best regards,
Heiko


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

* Re: [PATCH] Use CC to determine if gcc is used
  2015-04-27 16:57             ` Heiko Becker
@ 2015-04-27 17:09               ` Peter Stephenson
  2015-04-27 17:26                 ` Heiko Becker
  0 siblings, 1 reply; 10+ messages in thread
From: Peter Stephenson @ 2015-04-27 17:09 UTC (permalink / raw)
  To: zsh-workers

On Mon, 27 Apr 2015 18:57:09 +0200
Heiko Becker <mail@heiko-becker.de> wrote:
> On 04/27/15 18:50, Peter Stephenson wrote:
> > On Mon, 27 Apr 2015 18:37:15 +0200
> > Please could you tell us what the underlying problem is (I mean that the
> > first patch was trying to fix)?  Then we can fix it properly.  All I
> > know is it fails somehow --- you said "miscompiled".  If we know how we
> > ought to be able to stop playing games with versions of CPP (presumably...)
> 
> Same problem as described here:
> http://www.zsh.org/mla/workers/2015/msg00211.html

OK, I've seen now --- the line markers are actually in the *middle* of
the output.  That's not going to work...  So it really is
gcc-specific; I can't imagine anything else is doing anything that
weird.

Simply removing the line markers won't work, then.  But from what I'm
seeing, the following probably ought to...

diff --git a/Src/zsh.mdd b/Src/zsh.mdd
index 71dd613..c2e59c9 100644
--- a/Src/zsh.mdd
+++ b/Src/zsh.mdd
@@ -28,8 +28,8 @@ hdrdeps="zshcurses.h zshterm.h"
 # on the option to remove them being the same.
 signames.c: signames1.awk signames2.awk ../config.h @SIGNAL_H@
 	$(AWK) -f $(sdir)/signames1.awk @SIGNAL_H@ >sigtmp.c
-	case "$(CPP)" in \
-	gcc*) \
+	case "`$(CPP) --version </dev/null 2>&1`" in \
+	*"Free Software Foundation"*) \
 	$(CPP) -P sigtmp.c >sigtmp.out;; \
 	*) \
 	$(CPP) sigtmp.c >sigtmp.out;; \


pws


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

* Re: [PATCH] Use CC to determine if gcc is used
  2015-04-27 17:09               ` Peter Stephenson
@ 2015-04-27 17:26                 ` Heiko Becker
  0 siblings, 0 replies; 10+ messages in thread
From: Heiko Becker @ 2015-04-27 17:26 UTC (permalink / raw)
  To: zsh-workers

On 04/27/15 19:09, Peter Stephenson wrote:
> Simply removing the line markers won't work, then.  But from what I'm
> seeing, the following probably ought to...
> 
> diff --git a/Src/zsh.mdd b/Src/zsh.mdd
> index 71dd613..c2e59c9 100644
> --- a/Src/zsh.mdd
> +++ b/Src/zsh.mdd
> @@ -28,8 +28,8 @@ hdrdeps="zshcurses.h zshterm.h"
>  # on the option to remove them being the same.
>  signames.c: signames1.awk signames2.awk ../config.h @SIGNAL_H@
>  	$(AWK) -f $(sdir)/signames1.awk @SIGNAL_H@ >sigtmp.c
> -	case "$(CPP)" in \
> -	gcc*) \
> +	case "`$(CPP) --version </dev/null 2>&1`" in \
> +	*"Free Software Foundation"*) \
>  	$(CPP) -P sigtmp.c >sigtmp.out;; \
>  	*) \
>  	$(CPP) sigtmp.c >sigtmp.out;; \

That works fine for my setup and fixes the problem. Thank you!

-- 
Best regards,
Heiko


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

end of thread, other threads:[~2015-04-27 17:26 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-26 17:48 [PATCH] Use CC to determine if gcc is used Heiko Becker
2015-04-27  8:47 ` Peter Stephenson
2015-04-27  9:07   ` Peter Stephenson
2015-04-27 13:30     ` Daniel Shahaf
2015-04-27 14:11       ` Peter Stephenson
2015-04-27 16:37         ` Heiko Becker
2015-04-27 16:50           ` Peter Stephenson
2015-04-27 16:57             ` Heiko Becker
2015-04-27 17:09               ` Peter Stephenson
2015-04-27 17:26                 ` Heiko Becker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

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 NNTP newsgroup(s).