zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] disable generation of linemarkers by the preprocessor for sigtmp.c
@ 2015-01-15  8:43 Markus Trippelsdorf
  2015-01-15  9:47 ` Peter Stephenson
  0 siblings, 1 reply; 3+ messages in thread
From: Markus Trippelsdorf @ 2015-01-15  8:43 UTC (permalink / raw)
  To: zsh-workers

Hi.

Upcoming gcc-5 currently miscompiles zsh. The reason is that the
signames2.awk script doesn't handle the new linemarkers generated by
that compiler:

markus@x4 Src % cat sigtmp.c
#include <signal.h>

XXNAMES XXSIGHUP SIGHUP
XXNAMES XXSIGINT SIGINT
XXNAMES XXSIGQUIT SIGQUIT
XXNAMES XXSIGILL SIGILL
XXNAMES XXSIGTRAP SIGTRAP
XXNAMES XXSIGABRT SIGABRT
XXNAMES XXSIGIOT SIGIOT
XXNAMES XXSIGBUS SIGBUS
XXNAMES XXSIGFPE SIGFPE
XXNAMES XXSIGKILL SIGKILL
XXNAMES XXSIGUSR1 SIGUSR1
XXNAMES XXSIGSEGV SIGSEGV
XXNAMES XXSIGUSR2 SIGUSR2
XXNAMES XXSIGPIPE SIGPIPE
XXNAMES XXSIGALRM SIGALRM
XXNAMES XXSIGTERM SIGTERM
XXNAMES XXSIGSTKFLT SIGSTKFLT
XXNAMES XXSIGCLD SIGCLD
XXNAMES XXSIGCHLD SIGCHLD
XXNAMES XXSIGCONT SIGCONT
XXNAMES XXSIGSTOP SIGSTOP
XXNAMES XXSIGTSTP SIGTSTP
XXNAMES XXSIGTTIN SIGTTIN
XXNAMES XXSIGTTOU SIGTTOU
XXNAMES XXSIGURG SIGURG
XXNAMES XXSIGXCPU SIGXCPU
XXNAMES XXSIGXFSZ SIGXFSZ
XXNAMES XXSIGVTALRM SIGVTALRM
XXNAMES XXSIGPROF SIGPROF
XXNAMES XXSIGWINCH SIGWINCH
XXNAMES XXSIGPOLL SIGPOLL
XXNAMES XXSIGIO SIGIO
XXNAMES XXSIGPWR SIGPWR
XXNAMES XXSIGSYS SIGSYS
XXNAMES XXSIGUNUSED SIGUNUSED
XXNAMES XXSIGRTMIN _SIGRTMIN

markus@x4 Src % gcc-4.9 -E sigtmp.c >|sigtmp.out
markus@x4 Src % gcc-5 -E sigtmp.c >|sigtmp_.out
markus@x4 Src % diff -u sigtmp.out sigtmp_.out
--- sigtmp.out  2015-01-15 09:09:41.899667049 +0100
+++ sigtmp_.out 2015-01-15 09:09:45.209590084 +0100
@@ -25,6 +25,8 @@
 
 # 1 "/usr/include/bits/sigset.h" 1 3 4
 # 22 "/usr/include/bits/sigset.h" 3 4
+
+# 22 "/usr/include/bits/sigset.h" 3 4
 typedef int __sig_atomic_t;
 
 
@@ -741,8 +743,8 @@
 
 
 
-# 1 "/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/stddef.h" 1 3 4
-# 212 "/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/stddef.h" 3 4
+# 1 "/usr/lib/gcc/x86_64-pc-linux-gnu/5.0.0/include/stddef.h" 1 3 4
+# 216 "/usr/lib/gcc/x86_64-pc-linux-gnu/5.0.0/include/stddef.h" 3 4
 typedef long unsigned int size_t;
 # 343 "/usr/include/signal.h" 2 3 4
 
@@ -1031,39 +1033,181 @@
 
 # 2 "sigtmp.c" 2
 
-XXNAMES XXSIGHUP 1
-XXNAMES XXSIGINT 2
-XXNAMES XXSIGQUIT 3
-XXNAMES XXSIGILL 4
-XXNAMES XXSIGTRAP 5
-XXNAMES XXSIGABRT 6
-XXNAMES XXSIGIOT 6
-XXNAMES XXSIGBUS 7
-XXNAMES XXSIGFPE 8
-XXNAMES XXSIGKILL 9
-XXNAMES XXSIGUSR1 10
-XXNAMES XXSIGSEGV 11
-XXNAMES XXSIGUSR2 12
-XXNAMES XXSIGPIPE 13
-XXNAMES XXSIGALRM 14
-XXNAMES XXSIGTERM 15
-XXNAMES XXSIGSTKFLT 16
-XXNAMES XXSIGCLD 17
-XXNAMES XXSIGCHLD 17
-XXNAMES XXSIGCONT 18
-XXNAMES XXSIGSTOP 19
-XXNAMES XXSIGTSTP 20
-XXNAMES XXSIGTTIN 21
-XXNAMES XXSIGTTOU 22
-XXNAMES XXSIGURG 23
-XXNAMES XXSIGXCPU 24
-XXNAMES XXSIGXFSZ 25
-XXNAMES XXSIGVTALRM 26
-XXNAMES XXSIGPROF 27
-XXNAMES XXSIGWINCH 28
-XXNAMES XXSIGPOLL 29
-XXNAMES XXSIGIO 29
-XXNAMES XXSIGPWR 30
-XXNAMES XXSIGSYS 31
-XXNAMES XXSIGUNUSED 31
+
+# 3 "sigtmp.c"
+XXNAMES XXSIGHUP 
+# 3 "sigtmp.c" 3 4
+                1
+
+# 4 "sigtmp.c"
+XXNAMES XXSIGINT 
+# 4 "sigtmp.c" 3 4
+                2
...

And then the awk script generates a bogus signames.c file:

 % gawk -f ./signames2.awk sigtmp.out >| signames.c

The fix is simple. Just disable the generation of linemarkers by the
preprocessor.

diff --git a/Src/zsh.mdd b/Src/zsh.mdd
index f0379d2d17c8..649b28991666 100644
--- a/Src/zsh.mdd
+++ b/Src/zsh.mdd
@@ -24,7 +24,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
-	$(CPP) sigtmp.c >sigtmp.out
+	$(CPP) -P sigtmp.c >sigtmp.out
 	$(AWK) -f $(sdir)/signames2.awk sigtmp.out > $@
 	rm -f sigtmp.c sigtmp.out
 
-- 
Markus


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

* Re: [PATCH] disable generation of linemarkers by the preprocessor for sigtmp.c
  2015-01-15  8:43 [PATCH] disable generation of linemarkers by the preprocessor for sigtmp.c Markus Trippelsdorf
@ 2015-01-15  9:47 ` Peter Stephenson
  2015-01-21 13:23   ` Andreas Schwab
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Stephenson @ 2015-01-15  9:47 UTC (permalink / raw)
  To: zsh-workers; +Cc: Markus Trippelsdorf

On Thu, 15 Jan 2015 09:43:37 +0100
Markus Trippelsdorf <markus@trippelsdorf.de> wrote:
> Upcoming gcc-5 currently miscompiles zsh. The reason is that the
> signames2.awk script doesn't handle the new linemarkers generated by
> that compiler:
>
> The fix is simple. Just disable the generation of linemarkers by the
> preprocessor.

Thanks, that's fine for gcc: I'm a bit worried that the -P option isn't
completely standard (and in any case there are some prehistoric
preprocessors out there).  I'd suggest limiting this to the case where CPP
actually is gcc with options which is normal on GNU-based systems.

It should also be possible to improve the AWK script to be more careful
since there's nothing non-standard about the output you show.  I'll
take a look at some point.

diff --git a/Src/zsh.mdd b/Src/zsh.mdd
index f0379d2..71dd613 100644
--- a/Src/zsh.mdd
+++ b/Src/zsh.mdd
@@ -22,9 +22,18 @@ hdrdeps="zshcurses.h zshterm.h"
 :<<\Make
 @CONFIG_MK@
 
+# If we're using gcc as the preprocessor, get rid of the additional
+# lines generated by the preprocessor as they can confuse the script.
+# We don't need these in other cases either, but can't necessarily rely
+# 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
-	$(CPP) sigtmp.c >sigtmp.out
+	case "$(CPP)" in \
+	gcc*) \
+	$(CPP) -P sigtmp.c >sigtmp.out;; \
+	*) \
+	$(CPP) sigtmp.c >sigtmp.out;; \
+	esac
 	$(AWK) -f $(sdir)/signames2.awk sigtmp.out > $@
 	rm -f sigtmp.c sigtmp.out
 


-- 
Peter Stephenson <p.stephenson@samsung.com>  Principal Software Engineer
Tel: +44 (0)1223 434724                Samsung Cambridge Solution Centre
St John's House, St John's Innovation Park, Cowley Road,
Cambridge, CB4 0DS, UK


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

* Re: [PATCH] disable generation of linemarkers by the preprocessor for sigtmp.c
  2015-01-15  9:47 ` Peter Stephenson
@ 2015-01-21 13:23   ` Andreas Schwab
  0 siblings, 0 replies; 3+ messages in thread
From: Andreas Schwab @ 2015-01-21 13:23 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: zsh-workers, Markus Trippelsdorf

Peter Stephenson <p.stephenson@samsung.com> writes:

> On Thu, 15 Jan 2015 09:43:37 +0100
> Markus Trippelsdorf <markus@trippelsdorf.de> wrote:
>> Upcoming gcc-5 currently miscompiles zsh. The reason is that the
>> signames2.awk script doesn't handle the new linemarkers generated by
>> that compiler:
>>
>> The fix is simple. Just disable the generation of linemarkers by the
>> preprocessor.
>
> Thanks, that's fine for gcc: I'm a bit worried that the -P option isn't
> completely standard (and in any case there are some prehistoric
> preprocessors out there).

It should be pretty portable, even v7 had it.

<https://www.freebsd.org/cgi/man.cgi?query=cc&manpath=Unix+Seventh+Edition>

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."


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

end of thread, other threads:[~2015-01-21 13:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-15  8:43 [PATCH] disable generation of linemarkers by the preprocessor for sigtmp.c Markus Trippelsdorf
2015-01-15  9:47 ` Peter Stephenson
2015-01-21 13:23   ` Andreas Schwab

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).