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 <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2026-01-29 13:11:23 +01:00
parent dacda5ab5d
commit a215747355
+5 -4
View File
@@ -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)
{