Greg Thelen
2026-Feb-01 01:14 UTC
[klibc] [PATCH 1/2] explicitly close arm64 syscall stub generator output
The output of syscalls.pl pass 2 includes:
1) A makefile fragment written to stdout. This is redirected by the
caller to syscalls.mk. The format is:
syscall-objs := <list of per syscall .o files, like recvmsg.o)
2) Syscall stub files such as recvmsg.S. These are written using
per-arch stubs generator, e.g., usr/klibc/arch/arm64/sysstub.ph.
The usr/klibc/syscalls/Kbuild makefile:
- includes syscalls.mk
- defines syscalls.mk to depend on .S files for each
syscall-objs, e.g., recvmsg.S
The dependency graph is thus:
Kbuild -> syscalls.mk -> recvmsg.S
make rexecutes a toplevel makefile if any included makefile is updated
or created during the processing of that toplevel makefile. The
assumption is that warmup passes may be needed to generate build
rules. After warmup make can then create all outputs.
Specifically in klibc, if syscalls.mk is older than recvmsg.S then
syscalls.pl will regenerate both syscalls.mk and recvmsg.S. An updated
syscalls.mk will trigger re-execution of Kbuild. So it's important that
the syscalls.mk timestamp is not older than recvmsg.S, otherwise this
will loop forever.
In perl output files are implicitly flushed and closed on process exit.
In syscalls.pl such implicit closes can occur after the syscalls.pl
stdout is written. Depending on process exit to implicitly flush stub
file output means the stub file may have a newer mtime than syscalls.mk.
Most per arch stub generators explicitly close their output. But arm and
arm64 are exceptions. Make the arm64 generator do the same.
Tested:
- Before this change builds are slow and have high variability:
31 samples: mean 0:05:27.322581 stddev 48.745%
- After this change build time is faster and consistent:
31 samples: mean 0:03:25.322581 stddev 1.130%
Incidentally, it does not look like syscalls.mk actually depends on stub
.S files. Removing that dependency also avoids the above
looping. Removal of this seemingly extraneous dependency will be
proposed in a later change.
Fixes: e4a2c914446b ("[klibc] arm64: Add arm64 support")
Signed-off-by: Greg Thelen <gthelen at google.com>
---
usr/klibc/arch/arm64/sysstub.ph | 1 +
1 file changed, 1 insertion(+)
diff --git a/usr/klibc/arch/arm64/sysstub.ph b/usr/klibc/arch/arm64/sysstub.ph
index 095b1e83a872..e4f009b5379d 100644
--- a/usr/klibc/arch/arm64/sysstub.ph
+++ b/usr/klibc/arch/arm64/sysstub.ph
@@ -19,6 +19,7 @@ sub make_sysstub($$$$$@) {
print OUT " svc 0\n";
print OUT " b __syscall_common\n";
print OUT " .size ${fname},.-${fname}\n";
+ close(OUT);
}
1;
--
2.53.0.rc1.225.gd81095ad13-goog
Greg Thelen
2026-Feb-01 01:14 UTC
[klibc] [PATCH 2/2] explicitly close arm syscall stub generator output
Most per arch stub generators already explicitly close their
output. Make the arm generator do the same.
Fixes: 019eba37ffbd ("Make ARM work again with the new system call stub
setup")
Signed-off-by: Greg Thelen <gthelen at google.com>
---
usr/klibc/arch/arm/sysstub.ph | 1 +
1 file changed, 1 insertion(+)
diff --git a/usr/klibc/arch/arm/sysstub.ph b/usr/klibc/arch/arm/sysstub.ph
index 1a4eca05adde..dd0c0633c90d 100644
--- a/usr/klibc/arch/arm/sysstub.ph
+++ b/usr/klibc/arch/arm/sysstub.ph
@@ -53,6 +53,7 @@ sub make_sysstub($$$$$@) {
print OUT "#endif /* __thumb__*/\n";
print OUT " .size ${fname},.-${fname}\n";
+ close(OUT);
}
1;
--
2.53.0.rc1.225.gd81095ad13-goog
Greg Thelen
2026-Feb-01 01:21 UTC
[klibc] [PATCH 1/2] explicitly close arm64 syscall stub generator output
On Sat, Jan 31, 2026 at 5:15?PM Greg Thelen <gthelen at google.com> wrote:> > The output of syscalls.pl pass 2 includes: > 1) A makefile fragment written to stdout. This is redirected by the > caller to syscalls.mk. The format is: > syscall-objs := <list of per syscall .o files, like recvmsg.o) > 2) Syscall stub files such as recvmsg.S. These are written using > per-arch stubs generator, e.g., usr/klibc/arch/arm64/sysstub.ph. > > The usr/klibc/syscalls/Kbuild makefile: > - includes syscalls.mk > - defines syscalls.mk to depend on .S files for each > syscall-objs, e.g., recvmsg.S > > The dependency graph is thus: > Kbuild -> syscalls.mk -> recvmsg.S > > make rexecutes a toplevel makefile if any included makefile is updated > or created during the processing of that toplevel makefile. The > assumption is that warmup passes may be needed to generate build > rules. After warmup make can then create all outputs.Fix typo: s/make rexecutes/make re-executes/> Specifically in klibc, if syscalls.mk is older than recvmsg.S then > syscalls.pl will regenerate both syscalls.mk and recvmsg.S. An updated > syscalls.mk will trigger re-execution of Kbuild. So it's important that > the syscalls.mk timestamp is not older than recvmsg.S, otherwise this > will loop forever. > > In perl output files are implicitly flushed and closed on process exit. > In syscalls.pl such implicit closes can occur after the syscalls.pl > stdout is written. Depending on process exit to implicitly flush stub > file output means the stub file may have a newer mtime than syscalls.mk. > > Most per arch stub generators explicitly close their output. But arm and > arm64 are exceptions. Make the arm64 generator do the same. > > Tested: > - Before this change builds are slow and have high variability: > 31 samples: mean 0:05:27.322581 stddev 48.745% > - After this change build time is faster and consistent: > 31 samples: mean 0:03:25.322581 stddev 1.130% > > Incidentally, it does not look like syscalls.mk actually depends on stub > .S files. Removing that dependency also avoids the above > looping. Removal of this seemingly extraneous dependency will be > proposed in a later change. > > Fixes: e4a2c914446b ("[klibc] arm64: Add arm64 support") > Signed-off-by: Greg Thelen <gthelen at google.com> > --- > usr/klibc/arch/arm64/sysstub.ph | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/usr/klibc/arch/arm64/sysstub.ph b/usr/klibc/arch/arm64/sysstub.ph > index 095b1e83a872..e4f009b5379d 100644 > --- a/usr/klibc/arch/arm64/sysstub.ph > +++ b/usr/klibc/arch/arm64/sysstub.ph > @@ -19,6 +19,7 @@ sub make_sysstub($$$$$@) { > print OUT " svc 0\n"; > print OUT " b __syscall_common\n"; > print OUT " .size ${fname},.-${fname}\n"; > + close(OUT); > } > > 1; > -- > 2.53.0.rc1.225.gd81095ad13-goog >
Ben Hutchings
2026-Feb-03 16:35 UTC
[klibc] [PATCH 1/2] explicitly close arm64 syscall stub generator output
On Sat, 2026-01-31 at 17:14 -0800, Greg Thelen wrote:> The output of syscalls.pl pass 2 includes: > 1) A makefile fragment written to stdout. This is redirected by the > caller to syscalls.mk. The format is: > syscall-objs := <list of per syscall .o files, like recvmsg.o) > 2) Syscall stub files such as recvmsg.S. These are written using > per-arch stubs generator, e.g., usr/klibc/arch/arm64/sysstub.ph. > > The usr/klibc/syscalls/Kbuild makefile: > - includes syscalls.mk > - defines syscalls.mk to depend on .S files for each > syscall-objs, e.g., recvmsg.S[...] This shouldn't be true after your patch "[klibc] remove unneeded syscalls.mk dependencies", so are these 2 really still needed? Ben. -- Ben Hutchings Any sufficiently advanced bug is indistinguishable from a feature. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: This is a digitally signed message part URL: <https://lists.zytor.com/archives/klibc/attachments/20260203/23171868/attachment.sig>