]>
Commit | Line | Data |
---|---|---|
1d2a824d JP |
1 | From 39d53d04357606a15efd400147fa7369d71baf2c Mon Sep 17 00:00:00 2001 |
2 | From: Mike Frysinger <vapier@gentoo.org> | |
3 | Date: Sun, 3 Oct 2021 12:02:53 -0400 | |
4 | Subject: [PATCH] sim: filter out SIGSTKSZ [PR sim/28302] | |
5 | ||
6 | We map target signals to host signals so we can propagate signals | |
7 | between the host & simulated worlds. That means we need to know | |
8 | the symbolic names & values of all signals that might be sent. | |
9 | ||
10 | The tools that generate that list use signal.h and include all | |
11 | symbols that start with "SIG" so as to automatically include any | |
12 | new symbols that the C library might add. Unfortunately, this | |
13 | also picks up "SIGSTKSZ" which is not actually a signal itself, | |
14 | but a signal related setting -- it's the size of the stack when | |
15 | a signal is handled. | |
16 | ||
17 | By itself this doesn't super matter as we will never see a signal | |
18 | with that same value (since the range of valid signals tend to be | |
19 | way less than 1024, and the size of the default signal stack will | |
20 | never be that small). But with recent glibc changes that make this | |
21 | into a dynamic value instead of a compile-time constant, some users | |
22 | see build failures when building the sim. | |
23 | ||
24 | As suggested by Adam Sampson, update our scripts to ignore this | |
25 | symbol to simplify everything and avoid the build failure. | |
26 | ||
27 | Bug: https://sourceware.org/PR28302 | |
28 | --- | |
29 | sim/bfin/linux-targ-map.h | 5 +---- | |
30 | sim/common/gennltvals.py | 6 ++++-- | |
31 | sim/common/nltvals.def | 1 - | |
32 | 3 files changed, 5 insertions(+), 7 deletions(-) | |
33 | ||
34 | diff --git a/sim/bfin/linux-targ-map.h b/sim/bfin/linux-targ-map.h | |
35 | index e9c8c8f273b..0340ed54764 100644 | |
36 | --- a/sim/bfin/linux-targ-map.h | |
37 | +++ b/sim/bfin/linux-targ-map.h | |
38 | @@ -30,6 +30,7 @@ echo | |
39 | # XXX: nothing uses this ? | |
40 | echo '#include <signal.h>' | \ | |
41 | bfin-uclinux-gcc -E -dD -P - | \ | |
42 | +grep -v SIGSTKSZ | \ | |
43 | sed -r -n \ | |
44 | -e '1istatic CB_TARGET_DEFS_MAP cb_linux_signal_map[] = {' \ | |
45 | -e '$i\ \ { 0, -1, -1 }\n};' \ | |
46 | @@ -1987,10 +1988,6 @@ static CB_TARGET_DEFS_MAP cb_linux_signal_map[] = | |
47 | #ifdef SIG_SETMASK | |
48 | # define TARGET_LINUX_SIG_SETMASK 2 | |
49 | { "SIG_SETMASK", SIG_SETMASK, TARGET_LINUX_SIG_SETMASK }, | |
50 | -#endif | |
51 | -#ifdef SIGSTKSZ | |
52 | -# define TARGET_LINUX_SIGSTKSZ 8192 | |
53 | - { "SIGSTKSZ", SIGSTKSZ, TARGET_LINUX_SIGSTKSZ }, | |
54 | #endif | |
55 | { 0, -1, -1 } | |
56 | }; | |
57 | diff --git a/sim/common/gennltvals.py b/sim/common/gennltvals.py | |
58 | index db3ff641d40..955ace34311 100755 | |
59 | --- a/sim/common/gennltvals.py | |
60 | +++ b/sim/common/gennltvals.py | |
61 | @@ -67,6 +67,7 @@ FILE_HEADER = f"""\ | |
62 | def gentvals(output: TextIO, cpp: str, srctype: str, srcdir: Path, | |
63 | headers: Iterable[str], | |
64 | pattern: str, | |
65 | + filter: str = r'^$', | |
66 | target: str = None): | |
67 | """Extract constants from the specified files using a regular expression. | |
68 | ||
69 | @@ -94,12 +95,13 @@ def gentvals(output: TextIO, cpp: str, srctype: str, srcdir: Path, | |
70 | srcfile = ''.join(f'#include <{x}>\n' for x in headers) | |
71 | syms = set() | |
72 | define_pattern = re.compile(r'^#\s*define\s+(' + pattern + ')') | |
73 | + filter_pattern = re.compile(filter) | |
74 | for header in headers: | |
75 | with open(srcdir / header, 'r', encoding='utf-8') as fp: | |
76 | data = fp.read() | |
77 | for line in data.splitlines(): | |
78 | m = define_pattern.match(line) | |
79 | - if m: | |
80 | + if m and not filter_pattern.search(line): | |
81 | syms.add(m.group(1)) | |
82 | for sym in sorted(syms): | |
83 | srcfile += f'#ifdef {sym}\nDEFVAL {{ "{sym}", {sym} }},\n#endif\n' | |
84 | @@ -129,7 +131,7 @@ def gen_common(output: TextIO, newlib: Path, cpp: str): | |
85 | ('errno.h', 'sys/errno.h'), 'E[A-Z0-9]*') | |
86 | ||
87 | gentvals(output, cpp, 'signal', newlib / 'newlib/libc/include', | |
88 | - ('signal.h', 'sys/signal.h'), r'SIG[A-Z0-9]*') | |
89 | + ('signal.h', 'sys/signal.h'), r'SIG[A-Z0-9]*', filter=r'SIGSTKSZ') | |
90 | ||
91 | gentvals(output, cpp, 'open', newlib / 'newlib/libc/include', | |
92 | ('fcntl.h', 'sys/fcntl.h', 'sys/_default_fcntl.h'), r'O_[A-Z0-9]*') | |
93 | diff --git a/sim/common/nltvals.def b/sim/common/nltvals.def | |
94 | index 8ae88397249..8bc6ae59026 100644 | |
95 | --- a/sim/common/nltvals.def | |
96 | +++ b/sim/common/nltvals.def | |
97 | @@ -116,7 +116,6 @@ | |
98 | { "SIGPROF", 27 }, | |
99 | { "SIGQUIT", 3 }, | |
100 | { "SIGSEGV", 11 }, | |
101 | - { "SIGSTKSZ", 8192 }, | |
102 | { "SIGSTOP", 17 }, | |
103 | { "SIGSYS", 12 }, | |
104 | { "SIGTERM", 15 }, | |
105 | -- | |
106 | 2.27.0 | |
107 |