From a21574735503d6ffcf2bfa2fbbb6fc2bd4dff900 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Thu, 29 Jan 2026 13:11:23 +0100 Subject: [PATCH] Fix clone3 build failure with older toolchain kernel headers Define __NR_clone3 (435) ourselves when not provided by the toolchain headers. The syscall number is stable kernel ABI and the same on all architectures since Linux 5.3. The existing runtime fallback to fork() handles older kernels that don't support the syscall. Signed-off-by: Joachim Wiberg --- src/clone3.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/clone3.c b/src/clone3.c index e990adf9..8170f2c3 100644 --- a/src/clone3.c +++ b/src/clone3.c @@ -37,6 +37,11 @@ #include "finit.h" #include "log.h" +/* clone3() was added in Linux 5.3, syscall number 435 on all archs */ +#ifndef __NR_clone3 +#define __NR_clone3 435 +#endif + /* Clone3 flags from linux/sched.h */ #ifndef CLONE_INTO_CGROUP #define CLONE_INTO_CGROUP 0x200000000ULL @@ -57,11 +62,7 @@ struct clone3_args { uint64_t cgroup; /* Cgroup file descriptor */ } __attribute__((aligned(8))); -#ifdef __NR_clone3 static int use_clone3 = 1; -#else -static int use_clone3 = 0; -#endif int has_clone3(void) {