sim: filter out SIGSTKSZ [PR sim/28302]
authorMike Frysinger <vapier@gentoo.org>
Sun, 3 Oct 2021 16:02:53 +0000 (12:02 -0400)
committerMike Frysinger <vapier@gentoo.org>
Wed, 12 Jan 2022 11:02:08 +0000 (06:02 -0500)
We map target signals to host signals so we can propagate signals
between the host & simulated worlds.  That means we need to know
the symbolic names & values of all signals that might be sent.

The tools that generate that list use signal.h and include all
symbols that start with "SIG" so as to automatically include any
new symbols that the C library might add.  Unfortunately, this
also picks up "SIGSTKSZ" which is not actually a signal itself,
but a signal related setting -- it's the size of the stack when
a signal is handled.

By itself this doesn't super matter as we will never see a signal
with that same value (since the range of valid signals tend to be
way less than 1024, and the size of the default signal stack will
never be that small).  But with recent glibc changes that make this
into a dynamic value instead of a compile-time constant, some users
see build failures when building the sim.

As suggested by Adam Sampson, update our scripts to ignore this
symbol to simplify everything and avoid the build failure.

Bug: https://sourceware.org/PR28302

sim/bfin/linux-targ-map.h
sim/common/gennltvals.py
sim/common/nltvals.def

index e9c8c8f273b5cccd9a0ebf2d56c60123a0add5d2..0340ed54764e0485dbe42566bdc1bfc847eed731 100644 (file)
@@ -30,6 +30,7 @@ echo
 # XXX: nothing uses this ?
 echo '#include <signal.h>' | \
 bfin-uclinux-gcc -E -dD -P - | \
+grep -v SIGSTKSZ | \
 sed -r -n \
     -e '1istatic CB_TARGET_DEFS_MAP cb_linux_signal_map[] = {' \
     -e '$i\ \ { 0, -1, -1 }\n};' \
@@ -1987,10 +1988,6 @@ static CB_TARGET_DEFS_MAP cb_linux_signal_map[] =
 #ifdef SIG_SETMASK
 # define TARGET_LINUX_SIG_SETMASK 2
   { "SIG_SETMASK", SIG_SETMASK, TARGET_LINUX_SIG_SETMASK },
-#endif
-#ifdef SIGSTKSZ
-# define TARGET_LINUX_SIGSTKSZ 8192
-  { "SIGSTKSZ", SIGSTKSZ, TARGET_LINUX_SIGSTKSZ },
 #endif
   { 0, -1, -1 }
 };
index b3e558d580a91c56c1bd2a3791b9152ea78afd82..bd4d7e92a47a0b5f6cca4b7710cd2ba5e7509355 100755 (executable)
@@ -67,6 +67,7 @@ FILE_HEADER = f"""\
 def gentvals(output: TextIO, cpp: str, srctype: str, srcdir: Path,
              headers: Iterable[str],
              pattern: str,
+             filter: str = r'^$',
              target: str = None):
     """Extract constants from the specified files using a regular expression.
 
@@ -94,12 +95,13 @@ def gentvals(output: TextIO, cpp: str, srctype: str, srcdir: Path,
     srcfile = ''.join(f'#include <{x}>\n' for x in headers)
     syms = set()
     define_pattern = re.compile(r'^#\s*define\s+(' + pattern + ')')
+    filter_pattern = re.compile(filter)
     for header in headers:
         with open(srcdir / header, 'r', encoding='utf-8') as fp:
             data = fp.read()
         for line in data.splitlines():
             m = define_pattern.match(line)
-            if m:
+            if m and not filter_pattern.search(line):
                 syms.add(m.group(1))
     for sym in sorted(syms):
         srcfile += f'#ifdef {sym}\nDEFVAL {{ "{sym}", {sym} }},\n#endif\n'
@@ -129,7 +131,7 @@ def gen_common(output: TextIO, newlib: Path, cpp: str):
              ('errno.h', 'sys/errno.h'), 'E[A-Z0-9]*')
 
     gentvals(output, cpp, 'signal', newlib / 'newlib/libc/include',
-             ('signal.h', 'sys/signal.h'), r'SIG[A-Z0-9]*')
+             ('signal.h', 'sys/signal.h'), r'SIG[A-Z0-9]*', filter=r'SIGSTKSZ')
 
     gentvals(output, cpp, 'open', newlib / 'newlib/libc/include',
              ('fcntl.h', 'sys/fcntl.h', 'sys/_default_fcntl.h'), r'O_[A-Z0-9]*')
index 8ae88397249c6b24c9cf98d5b6b5c3573bb85295..8bc6ae59026dbff0a24ebc1f8d9af3ace6aa6b28 100644 (file)
  { "SIGPROF", 27 },
  { "SIGQUIT", 3 },
  { "SIGSEGV", 11 },
- { "SIGSTKSZ", 8192 },
  { "SIGSTOP", 17 },
  { "SIGSYS", 12 },
  { "SIGTERM", 15 },
This page took 0.026324 seconds and 4 git commands to generate.