unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: Carlos O'Donell <carlos@redhat.com>
Cc: Florian Weimer <fweimer@redhat.com>,
	Joseph Myers <joseph@codesourcery.com>,
	Szabolcs Nagy <szabolcs.nagy@arm.com>,
	libc-alpha@sourceware.org
Subject: [RFC PATCH glibc 08/13] build-many-glibcs.py: Implement update-syscalls command
Date: Mon,  6 Jan 2020 10:57:08 -0500	[thread overview]
Message-ID: <20200106155713.397-9-mathieu.desnoyers@efficios.com> (raw)
In-Reply-To: <20200106155713.397-1-mathieu.desnoyers@efficios.com>

From: Florian Weimer <fweimer@redhat.com>

This command uses pre-built compilers to re-install the Linux headers
from the current sources into a temporary location and runs glibc's
“make update-syscalls-lists” against that.  This updates the glibc
source tree with the current system call numbers.
---
 scripts/build-many-glibcs.py | 65 ++++++++++++++++++++++++++++++++++--
 1 file changed, 62 insertions(+), 3 deletions(-)

diff --git a/scripts/build-many-glibcs.py b/scripts/build-many-glibcs.py
index 58f2409b1d..eedaa55033 100755
--- a/scripts/build-many-glibcs.py
+++ b/scripts/build-many-glibcs.py
@@ -498,7 +498,10 @@ class Context(object):
             old_components = ('gmp', 'mpfr', 'mpc', 'binutils', 'gcc', 'linux',
                               'mig', 'gnumach', 'hurd')
             old_versions = self.build_state['compilers']['build-versions']
-            self.build_glibcs(configs)
+            if action == 'update-syscalls':
+                self.update_syscalls(configs)
+            else:
+                self.build_glibcs(configs)
         self.write_files()
         self.do_build()
         if configs:
@@ -689,6 +692,15 @@ class Context(object):
         for c in configs:
             self.glibc_configs[c].build()
 
+    def update_syscalls(self, configs):
+        """Update the glibc syscall lists."""
+        if not configs:
+            self.remove_dirs(os.path.join(self.builddir, 'update-syscalls'))
+            self.remove_dirs(os.path.join(self.logsdir, 'update-syscalls'))
+            configs = sorted(self.glibc_configs.keys())
+        for c in configs:
+            self.glibc_configs[c].update_syscalls()
+
     def load_versions_json(self):
         """Load information about source directory versions."""
         if not os.access(self.versions_json, os.F_OK):
@@ -921,7 +933,7 @@ class Context(object):
                 self.build_state = json.load(f)
         else:
             self.build_state = {}
-        for k in ('host-libraries', 'compilers', 'glibcs'):
+        for k in ('host-libraries', 'compilers', 'glibcs', 'update-syscalls'):
             if k not in self.build_state:
                 self.build_state[k] = {}
             if 'build-time' not in self.build_state[k]:
@@ -1169,6 +1181,16 @@ class LinuxHeadersPolicyForBuild(object):
         self.builddir = config.component_builddir('linux')
         self.headers_dir = os.path.join(config.sysroot, 'usr')
 
+class LinuxHeadersPolicyForUpdateSyscalls(object):
+    """Names and directories for Linux headers.  update-syscalls variant."""
+
+    def __init__(self, glibc, headers_dir):
+        self.arch = glibc.compiler.arch
+        self.srcdir = glibc.compiler.ctx.component_srcdir('linux')
+        self.builddir = glibc.ctx.component_builddir(
+            'update-syscalls', glibc.name, 'build-linux')
+        self.headers_dir = headers_dir
+
 def install_linux_headers(policy, cmdlist):
     """Install Linux kernel headers."""
     arch_map = {'aarch64': 'arm64',
@@ -1465,6 +1487,20 @@ class GlibcPolicyForBuild(GlibcPolicyDefault):
         cmdlist.add_command('check', ['make', 'check'])
         cmdlist.add_command('save-logs', [self.save_logs], always_run=True)
 
+class GlibcPolicyForUpdateSyscalls(GlibcPolicyDefault):
+    """Build policy for glibc during update-syscalls."""
+
+    def __init__(self, glibc):
+        super().__init__(glibc)
+        self.builddir = glibc.ctx.component_builddir(
+            'update-syscalls', glibc.name, 'glibc')
+        self.linuxdir = glibc.ctx.component_builddir(
+            'update-syscalls', glibc.name, 'linux')
+        self.linux_policy = LinuxHeadersPolicyForUpdateSyscalls(
+            glibc, self.linuxdir)
+        self.configure_args.insert(
+            0, '--with-headers=%s' % os.path.join(self.linuxdir, 'include'))
+        # self.installdir not set because installation is not supported
 
 class Glibc(object):
     """A configuration for building glibc."""
@@ -1535,6 +1571,28 @@ class Glibc(object):
         policy.extra_commands(cmdlist)
         cmdlist.cleanup_dir()
 
+    def update_syscalls(self):
+        if self.os == 'gnu':
+            # Hurd does not have system call tables that need updating.
+            return
+
+        policy = GlibcPolicyForUpdateSyscalls(self)
+        logsdir = os.path.join(self.ctx.logsdir, 'update-syscalls', self.name)
+        self.ctx.remove_recreate_dirs(policy.builddir, logsdir)
+        cmdlist = CommandList('update-syscalls-%s' % self.name, self.ctx.keep)
+        cmdlist.add_command('check-compilers',
+                            ['test', '-f',
+                             os.path.join(self.compiler.installdir, 'ok')])
+        cmdlist.use_path(self.compiler.bindir)
+
+        install_linux_headers(policy.linux_policy, cmdlist)
+
+        cmdlist.create_use_dir(policy.builddir)
+        policy.configure(cmdlist)
+        cmdlist.add_command('build', ['make', 'update-syscall-lists'])
+        cmdlist.cleanup_dir()
+        self.ctx.add_makefile_cmdlist('update-syscalls-%s' % self.name,
+                                      cmdlist, logsdir)
 
 class Command(object):
     """A command run in the build process."""
@@ -1702,7 +1760,8 @@ def get_parser():
     parser.add_argument('action',
                         help='What to do',
                         choices=('checkout', 'bot-cycle', 'bot',
-                                 'host-libraries', 'compilers', 'glibcs'))
+                                 'host-libraries', 'compilers', 'glibcs',
+                                 'update-syscalls'))
     parser.add_argument('configs',
                         help='Versions to check out or configurations to build',
                         nargs='*')
-- 
2.17.1


  parent reply	other threads:[~2020-01-06 15:58 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-06 15:57 [RFC PATCH glibc 00/13] Restartable Sequences enablement Mathieu Desnoyers
2020-01-06 15:57 ` [RFC PATCH glibc 01/13] Introduce <elf_machine_sym_no_match.h> Mathieu Desnoyers
2020-01-06 15:57 ` [RFC PATCH glibc 02/13] Implement __libc_early_init Mathieu Desnoyers
2020-01-06 15:57 ` [RFC PATCH glibc 03/13] nptl: Start new threads with all signals blocked [BZ #25098] Mathieu Desnoyers
2020-01-06 15:57 ` [RFC PATCH glibc 04/13] Linux: Add tables with system call numbers Mathieu Desnoyers
2020-01-06 15:57 ` [RFC PATCH glibc 05/13] Linux: Use system call tables during build Mathieu Desnoyers
2020-01-06 15:57 ` [RFC PATCH glibc 06/13] build-many-glibcs.py: Introduce LinuxHeadersPolicyForBuild Mathieu Desnoyers
2020-01-06 15:57 ` [RFC PATCH glibc 07/13] build-many-glibcs.py: Introduce glibc build policy classes Mathieu Desnoyers
2020-01-06 15:57 ` Mathieu Desnoyers [this message]
2020-01-06 15:57 ` [RFC PATCH glibc 09/13] glibc: Perform rseq(2) registration at C startup and thread creation (v13) Mathieu Desnoyers
2020-01-07 12:23   ` Florian Weimer
2020-01-07 20:44     ` Mathieu Desnoyers
2020-01-06 15:57 ` [RFC PATCH glibc 10/13] glibc: sched_getcpu(): use rseq cpu_id TLS on Linux (v5) Mathieu Desnoyers
2020-01-06 15:57 ` [RFC PATCH glibc 11/13] support record failure: allow use from constructor Mathieu Desnoyers
2020-01-06 15:57 ` [RFC PATCH glibc 12/13] support: implement xpthread key create/delete (v3) Mathieu Desnoyers
2020-01-06 15:57 ` [RFC PATCH glibc 13/13] rseq registration tests (v7) Mathieu Desnoyers
2020-01-07 12:25 ` [RFC PATCH glibc 00/13] Restartable Sequences enablement Florian Weimer
2020-01-07 20:45   ` Mathieu Desnoyers
  -- strict thread matches above, loose matches on Subject: below --
2019-12-20 21:36 Mathieu Desnoyers
2019-12-20 21:36 ` [RFC PATCH glibc 08/13] build-many-glibcs.py: Implement update-syscalls command Mathieu Desnoyers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/libc/involved.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200106155713.397-9-mathieu.desnoyers@efficios.com \
    --to=mathieu.desnoyers@efficios.com \
    --cc=carlos@redhat.com \
    --cc=fweimer@redhat.com \
    --cc=joseph@codesourcery.com \
    --cc=libc-alpha@sourceware.org \
    --cc=szabolcs.nagy@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).