* [PATCH 0/9] tools/nolibc: split out more headers
@ 2025-05-15 19:57 Thomas Weißschuh
2025-05-15 19:57 ` [PATCH 1/9] tools/nolibc: move ioctl() to sys/ioctl.h Thomas Weißschuh
` (9 more replies)
0 siblings, 10 replies; 19+ messages in thread
From: Thomas Weißschuh @ 2025-05-15 19:57 UTC (permalink / raw)
To: Willy Tarreau, Shuah Khan
Cc: linux-kernel, linux-kselftest, Thomas Weißschuh
Split out all headers which are used by nolibc-test.c.
This makes it easier to port existing applications to nolibc.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
Thomas Weißschuh (9):
tools/nolibc: move ioctl() to sys/ioctl.h
tools/nolibc: move mount() to sys/mount.h
tools/nolibc: move prctl() to sys/prctl.h
tools/nolibc: move reboot() to sys/reboot.h
tools/nolibc: move getrlimit() and friends to sys/resource.h
tools/nolibc: move makedev() and friends to sys/sysmacros.h
tools/nolibc: move uname() and friends to sys/utsname.h
tools/nolibc: move NULL and offsetof() to sys/stddef.h
selftests/nolibc: drop include guards around standard headers
tools/include/nolibc/Makefile | 8 ++
tools/include/nolibc/nolibc.h | 7 ++
tools/include/nolibc/std.h | 6 +-
tools/include/nolibc/stddef.h | 24 +++++
tools/include/nolibc/sys.h | 136 ---------------------------
tools/include/nolibc/sys/ioctl.h | 29 ++++++
tools/include/nolibc/sys/mount.h | 37 ++++++++
tools/include/nolibc/sys/prctl.h | 36 +++++++
tools/include/nolibc/sys/reboot.h | 34 +++++++
tools/include/nolibc/sys/resource.h | 53 +++++++++++
tools/include/nolibc/sys/sysmacros.h | 20 ++++
tools/include/nolibc/sys/utsname.h | 42 +++++++++
tools/include/nolibc/types.h | 11 ---
tools/testing/selftests/nolibc/nolibc-test.c | 5 -
14 files changed, 291 insertions(+), 157 deletions(-)
---
base-commit: 6a25f787912a73613f12e7eefbebd72ee3d43f85
change-id: 20250515-nolibc-sys-31a4fd76d897
Best regards,
--
Thomas Weißschuh <linux@weissschuh.net>
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 1/9] tools/nolibc: move ioctl() to sys/ioctl.h
2025-05-15 19:57 [PATCH 0/9] tools/nolibc: split out more headers Thomas Weißschuh
@ 2025-05-15 19:57 ` Thomas Weißschuh
2025-05-21 13:03 ` Mark Brown
2025-05-15 19:57 ` [PATCH 2/9] tools/nolibc: move mount() to sys/mount.h Thomas Weißschuh
` (8 subsequent siblings)
9 siblings, 1 reply; 19+ messages in thread
From: Thomas Weißschuh @ 2025-05-15 19:57 UTC (permalink / raw)
To: Willy Tarreau, Shuah Khan
Cc: linux-kernel, linux-kselftest, Thomas Weißschuh
This is the location regular userspace expects this definition.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
tools/include/nolibc/Makefile | 1 +
tools/include/nolibc/nolibc.h | 1 +
tools/include/nolibc/sys.h | 12 ------------
tools/include/nolibc/sys/ioctl.h | 29 +++++++++++++++++++++++++++++
4 files changed, 31 insertions(+), 12 deletions(-)
diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile
index 4c4b7b5ff605ac5dde11628331378489d76d4466..7d66847df91a94ca784c04ced278eb6d7099bab4 100644
--- a/tools/include/nolibc/Makefile
+++ b/tools/include/nolibc/Makefile
@@ -49,6 +49,7 @@ all_files := \
string.h \
sys.h \
sys/auxv.h \
+ sys/ioctl.h \
sys/mman.h \
sys/random.h \
sys/stat.h \
diff --git a/tools/include/nolibc/nolibc.h b/tools/include/nolibc/nolibc.h
index 51c423a36b5957e2528e94d717d88e2383230cba..d6048d1e9ea5d4b5d504e156aafc5651dcd6b8c1 100644
--- a/tools/include/nolibc/nolibc.h
+++ b/tools/include/nolibc/nolibc.h
@@ -97,6 +97,7 @@
#include "types.h"
#include "sys.h"
#include "sys/auxv.h"
+#include "sys/ioctl.h"
#include "sys/mman.h"
#include "sys/random.h"
#include "sys/stat.h"
diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h
index 5733fe54911dca44c7423951ff85fb166d95c06f..313c210173c804f728b0be4ab8e67542bb3a7219 100644
--- a/tools/include/nolibc/sys.h
+++ b/tools/include/nolibc/sys.h
@@ -517,18 +517,6 @@ uid_t getuid(void)
}
-/*
- * int ioctl(int fd, unsigned long cmd, ... arg);
- */
-
-static __attribute__((unused))
-long sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
- return my_syscall3(__NR_ioctl, fd, cmd, arg);
-}
-
-#define ioctl(fd, cmd, arg) __sysret(sys_ioctl(fd, cmd, (unsigned long)(arg)))
-
/*
* int kill(pid_t pid, int signal);
*/
diff --git a/tools/include/nolibc/sys/ioctl.h b/tools/include/nolibc/sys/ioctl.h
new file mode 100644
index 0000000000000000000000000000000000000000..cb34be92a5f96aa566afa53a0f19932c2d5fe1eb
--- /dev/null
+++ b/tools/include/nolibc/sys/ioctl.h
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: LGPL-2.1 OR MIT */
+/*
+ * Ioctl definitions for NOLIBC
+ * Copyright (C) 2017-2021 Willy Tarreau <w@1wt.eu>
+ */
+
+/* make sure to include all global symbols */
+#include "nolibc.h"
+
+#ifndef _NOLIBC_SYS_IOCTL_H
+#define _NOLIBC_SYS_IOCTL_H
+
+#include "../sys.h"
+
+#include <linux/ioctl.h>
+
+/*
+ * int ioctl(int fd, unsigned long cmd, ... arg);
+ */
+
+static __attribute__((unused))
+long sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
+{
+ return my_syscall3(__NR_ioctl, fd, cmd, arg);
+}
+
+#define ioctl(fd, cmd, arg) __sysret(sys_ioctl(fd, cmd, (unsigned long)(arg)))
+
+#endif /* _NOLIBC_SYS_IOCTL_H */
--
2.49.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 2/9] tools/nolibc: move mount() to sys/mount.h
2025-05-15 19:57 [PATCH 0/9] tools/nolibc: split out more headers Thomas Weißschuh
2025-05-15 19:57 ` [PATCH 1/9] tools/nolibc: move ioctl() to sys/ioctl.h Thomas Weißschuh
@ 2025-05-15 19:57 ` Thomas Weißschuh
2025-05-15 19:57 ` [PATCH 3/9] tools/nolibc: move prctl() to sys/prctl.h Thomas Weißschuh
` (7 subsequent siblings)
9 siblings, 0 replies; 19+ messages in thread
From: Thomas Weißschuh @ 2025-05-15 19:57 UTC (permalink / raw)
To: Willy Tarreau, Shuah Khan
Cc: linux-kernel, linux-kselftest, Thomas Weißschuh
This is the location regular userspace expects this definition.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
tools/include/nolibc/Makefile | 1 +
tools/include/nolibc/nolibc.h | 1 +
tools/include/nolibc/sys.h | 20 --------------------
tools/include/nolibc/sys/mount.h | 37 +++++++++++++++++++++++++++++++++++++
4 files changed, 39 insertions(+), 20 deletions(-)
diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile
index 7d66847df91a94ca784c04ced278eb6d7099bab4..aa14dfddd77deb5442a6be65dee5684b6d218da7 100644
--- a/tools/include/nolibc/Makefile
+++ b/tools/include/nolibc/Makefile
@@ -51,6 +51,7 @@ all_files := \
sys/auxv.h \
sys/ioctl.h \
sys/mman.h \
+ sys/mount.h \
sys/random.h \
sys/stat.h \
sys/syscall.h \
diff --git a/tools/include/nolibc/nolibc.h b/tools/include/nolibc/nolibc.h
index d6048d1e9ea5d4b5d504e156aafc5651dcd6b8c1..690368f8e46c33df37c824429cf89dd0e95bb806 100644
--- a/tools/include/nolibc/nolibc.h
+++ b/tools/include/nolibc/nolibc.h
@@ -99,6 +99,7 @@
#include "sys/auxv.h"
#include "sys/ioctl.h"
#include "sys/mman.h"
+#include "sys/mount.h"
#include "sys/random.h"
#include "sys/stat.h"
#include "sys/syscall.h"
diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h
index 313c210173c804f728b0be4ab8e67542bb3a7219..e66dd6e760557333353d98da2627b038dffe7f93 100644
--- a/tools/include/nolibc/sys.h
+++ b/tools/include/nolibc/sys.h
@@ -672,26 +672,6 @@ int mknod(const char *path, mode_t mode, dev_t dev)
return __sysret(sys_mknod(path, mode, dev));
}
-/*
- * int mount(const char *source, const char *target,
- * const char *fstype, unsigned long flags,
- * const void *data);
- */
-static __attribute__((unused))
-int sys_mount(const char *src, const char *tgt, const char *fst,
- unsigned long flags, const void *data)
-{
- return my_syscall5(__NR_mount, src, tgt, fst, flags, data);
-}
-
-static __attribute__((unused))
-int mount(const char *src, const char *tgt,
- const char *fst, unsigned long flags,
- const void *data)
-{
- return __sysret(sys_mount(src, tgt, fst, flags, data));
-}
-
/*
* int pipe2(int pipefd[2], int flags);
diff --git a/tools/include/nolibc/sys/mount.h b/tools/include/nolibc/sys/mount.h
new file mode 100644
index 0000000000000000000000000000000000000000..5129420e716d0a7e75c32a5bbc8f4e9f0e21b03b
--- /dev/null
+++ b/tools/include/nolibc/sys/mount.h
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: LGPL-2.1 OR MIT */
+/*
+ * Mount definitions for NOLIBC
+ * Copyright (C) 2017-2021 Willy Tarreau <w@1wt.eu>
+ */
+
+/* make sure to include all global symbols */
+#include "nolibc.h"
+
+#ifndef _NOLIBC_SYS_MOUNT_H
+#define _NOLIBC_SYS_MOUNT_H
+
+#include "../sys.h"
+
+#include <linux/mount.h>
+
+/*
+ * int mount(const char *source, const char *target,
+ * const char *fstype, unsigned long flags,
+ * const void *data);
+ */
+static __attribute__((unused))
+int sys_mount(const char *src, const char *tgt, const char *fst,
+ unsigned long flags, const void *data)
+{
+ return my_syscall5(__NR_mount, src, tgt, fst, flags, data);
+}
+
+static __attribute__((unused))
+int mount(const char *src, const char *tgt,
+ const char *fst, unsigned long flags,
+ const void *data)
+{
+ return __sysret(sys_mount(src, tgt, fst, flags, data));
+}
+
+#endif /* _NOLIBC_SYS_MOUNT_H */
--
2.49.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 3/9] tools/nolibc: move prctl() to sys/prctl.h
2025-05-15 19:57 [PATCH 0/9] tools/nolibc: split out more headers Thomas Weißschuh
2025-05-15 19:57 ` [PATCH 1/9] tools/nolibc: move ioctl() to sys/ioctl.h Thomas Weißschuh
2025-05-15 19:57 ` [PATCH 2/9] tools/nolibc: move mount() to sys/mount.h Thomas Weißschuh
@ 2025-05-15 19:57 ` Thomas Weißschuh
2025-05-15 19:57 ` [PATCH 4/9] tools/nolibc: move reboot() to sys/reboot.h Thomas Weißschuh
` (6 subsequent siblings)
9 siblings, 0 replies; 19+ messages in thread
From: Thomas Weißschuh @ 2025-05-15 19:57 UTC (permalink / raw)
To: Willy Tarreau, Shuah Khan
Cc: linux-kernel, linux-kselftest, Thomas Weißschuh
This is the location regular userspace expects this definition.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
tools/include/nolibc/Makefile | 1 +
tools/include/nolibc/nolibc.h | 1 +
tools/include/nolibc/sys.h | 21 ---------------------
tools/include/nolibc/sys/prctl.h | 36 ++++++++++++++++++++++++++++++++++++
4 files changed, 38 insertions(+), 21 deletions(-)
diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile
index aa14dfddd77deb5442a6be65dee5684b6d218da7..35cfbc84d499b0a57689bdfed95a45023904d256 100644
--- a/tools/include/nolibc/Makefile
+++ b/tools/include/nolibc/Makefile
@@ -52,6 +52,7 @@ all_files := \
sys/ioctl.h \
sys/mman.h \
sys/mount.h \
+ sys/prctl.h \
sys/random.h \
sys/stat.h \
sys/syscall.h \
diff --git a/tools/include/nolibc/nolibc.h b/tools/include/nolibc/nolibc.h
index 690368f8e46c33df37c824429cf89dd0e95bb806..1c159e32a248d46fa4d36a2c35e92eb9da91e9f6 100644
--- a/tools/include/nolibc/nolibc.h
+++ b/tools/include/nolibc/nolibc.h
@@ -100,6 +100,7 @@
#include "sys/ioctl.h"
#include "sys/mman.h"
#include "sys/mount.h"
+#include "sys/prctl.h"
#include "sys/random.h"
#include "sys/stat.h"
#include "sys/syscall.h"
diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h
index e66dd6e760557333353d98da2627b038dffe7f93..a17fe98968a29081661eaf235111482a543f87ba 100644
--- a/tools/include/nolibc/sys.h
+++ b/tools/include/nolibc/sys.h
@@ -23,7 +23,6 @@
#include <linux/auxvec.h>
#include <linux/fcntl.h> /* for O_* and AT_* */
#include <linux/stat.h> /* for statx() */
-#include <linux/prctl.h>
#include <linux/resource.h>
#include <linux/utsname.h>
@@ -697,26 +696,6 @@ int pipe(int pipefd[2])
}
-/*
- * int prctl(int option, unsigned long arg2, unsigned long arg3,
- * unsigned long arg4, unsigned long arg5);
- */
-
-static __attribute__((unused))
-int sys_prctl(int option, unsigned long arg2, unsigned long arg3,
- unsigned long arg4, unsigned long arg5)
-{
- return my_syscall5(__NR_prctl, option, arg2, arg3, arg4, arg5);
-}
-
-static __attribute__((unused))
-int prctl(int option, unsigned long arg2, unsigned long arg3,
- unsigned long arg4, unsigned long arg5)
-{
- return __sysret(sys_prctl(option, arg2, arg3, arg4, arg5));
-}
-
-
/*
* int pivot_root(const char *new, const char *old);
*/
diff --git a/tools/include/nolibc/sys/prctl.h b/tools/include/nolibc/sys/prctl.h
new file mode 100644
index 0000000000000000000000000000000000000000..778a6a868823ce496f0f5482a58a31d69afd6d30
--- /dev/null
+++ b/tools/include/nolibc/sys/prctl.h
@@ -0,0 +1,36 @@
+/* SPDX-License-Identifier: LGPL-2.1 OR MIT */
+/*
+ * Prctl definitions for NOLIBC
+ * Copyright (C) 2017-2021 Willy Tarreau <w@1wt.eu>
+ */
+
+/* make sure to include all global symbols */
+#include "nolibc.h"
+
+#ifndef _NOLIBC_SYS_PRCTL_H
+#define _NOLIBC_SYS_PRCTL_H
+
+#include "../sys.h"
+
+#include <linux/prctl.h>
+
+/*
+ * int prctl(int option, unsigned long arg2, unsigned long arg3,
+ * unsigned long arg4, unsigned long arg5);
+ */
+
+static __attribute__((unused))
+int sys_prctl(int option, unsigned long arg2, unsigned long arg3,
+ unsigned long arg4, unsigned long arg5)
+{
+ return my_syscall5(__NR_prctl, option, arg2, arg3, arg4, arg5);
+}
+
+static __attribute__((unused))
+int prctl(int option, unsigned long arg2, unsigned long arg3,
+ unsigned long arg4, unsigned long arg5)
+{
+ return __sysret(sys_prctl(option, arg2, arg3, arg4, arg5));
+}
+
+#endif /* _NOLIBC_SYS_PRCTL_H */
--
2.49.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 4/9] tools/nolibc: move reboot() to sys/reboot.h
2025-05-15 19:57 [PATCH 0/9] tools/nolibc: split out more headers Thomas Weißschuh
` (2 preceding siblings ...)
2025-05-15 19:57 ` [PATCH 3/9] tools/nolibc: move prctl() to sys/prctl.h Thomas Weißschuh
@ 2025-05-15 19:57 ` Thomas Weißschuh
2025-05-15 19:57 ` [PATCH 5/9] tools/nolibc: move getrlimit() and friends to sys/resource.h Thomas Weißschuh
` (5 subsequent siblings)
9 siblings, 0 replies; 19+ messages in thread
From: Thomas Weißschuh @ 2025-05-15 19:57 UTC (permalink / raw)
To: Willy Tarreau, Shuah Khan
Cc: linux-kernel, linux-kselftest, Thomas Weißschuh
This is the location regular userspace expects this definition.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
tools/include/nolibc/Makefile | 1 +
tools/include/nolibc/nolibc.h | 1 +
tools/include/nolibc/sys.h | 18 ------------------
tools/include/nolibc/sys/reboot.h | 34 ++++++++++++++++++++++++++++++++++
tools/include/nolibc/types.h | 1 -
5 files changed, 36 insertions(+), 19 deletions(-)
diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile
index 35cfbc84d499b0a57689bdfed95a45023904d256..4850501b8d53be6b603ecbb04d6f952cd5370cf0 100644
--- a/tools/include/nolibc/Makefile
+++ b/tools/include/nolibc/Makefile
@@ -54,6 +54,7 @@ all_files := \
sys/mount.h \
sys/prctl.h \
sys/random.h \
+ sys/reboot.h \
sys/stat.h \
sys/syscall.h \
sys/time.h \
diff --git a/tools/include/nolibc/nolibc.h b/tools/include/nolibc/nolibc.h
index 1c159e32a248d46fa4d36a2c35e92eb9da91e9f6..36ea7a02c7434cc006a7b12d413add04a2f85565 100644
--- a/tools/include/nolibc/nolibc.h
+++ b/tools/include/nolibc/nolibc.h
@@ -102,6 +102,7 @@
#include "sys/mount.h"
#include "sys/prctl.h"
#include "sys/random.h"
+#include "sys/reboot.h"
#include "sys/stat.h"
#include "sys/syscall.h"
#include "sys/time.h"
diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h
index a17fe98968a29081661eaf235111482a543f87ba..6c89dd0316dd0ebf03ebde6fa5c14273df6a0c62 100644
--- a/tools/include/nolibc/sys.h
+++ b/tools/include/nolibc/sys.h
@@ -730,24 +730,6 @@ ssize_t read(int fd, void *buf, size_t count)
}
-/*
- * int reboot(int cmd);
- * <cmd> is among LINUX_REBOOT_CMD_*
- */
-
-static __attribute__((unused))
-ssize_t sys_reboot(int magic1, int magic2, int cmd, void *arg)
-{
- return my_syscall4(__NR_reboot, magic1, magic2, cmd, arg);
-}
-
-static __attribute__((unused))
-int reboot(int cmd)
-{
- return __sysret(sys_reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, cmd, 0));
-}
-
-
/*
* int getrlimit(int resource, struct rlimit *rlim);
* int setrlimit(int resource, const struct rlimit *rlim);
diff --git a/tools/include/nolibc/sys/reboot.h b/tools/include/nolibc/sys/reboot.h
new file mode 100644
index 0000000000000000000000000000000000000000..727363fbfd8a6f8994a0cf13829b7347ced198bb
--- /dev/null
+++ b/tools/include/nolibc/sys/reboot.h
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: LGPL-2.1 OR MIT */
+/*
+ * Reboot definitions for NOLIBC
+ * Copyright (C) 2017-2021 Willy Tarreau <w@1wt.eu>
+ */
+
+/* make sure to include all global symbols */
+#include "nolibc.h"
+
+#ifndef _NOLIBC_SYS_REBOOT_H
+#define _NOLIBC_SYS_REBOOT_H
+
+#include "../sys.h"
+
+#include <linux/reboot.h>
+
+/*
+ * int reboot(int cmd);
+ * <cmd> is among LINUX_REBOOT_CMD_*
+ */
+
+static __attribute__((unused))
+ssize_t sys_reboot(int magic1, int magic2, int cmd, void *arg)
+{
+ return my_syscall4(__NR_reboot, magic1, magic2, cmd, arg);
+}
+
+static __attribute__((unused))
+int reboot(int cmd)
+{
+ return __sysret(sys_reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, cmd, 0));
+}
+
+#endif /* _NOLIBC_SYS_REBOOT_H */
diff --git a/tools/include/nolibc/types.h b/tools/include/nolibc/types.h
index 93da29fe7719c9f196fba38d1f3f31cad0fc02f1..74c7694b2d5e54f7a86854697ac32a2ea2b62e86 100644
--- a/tools/include/nolibc/types.h
+++ b/tools/include/nolibc/types.h
@@ -12,7 +12,6 @@
#include "std.h"
#include <linux/mman.h>
-#include <linux/reboot.h> /* for LINUX_REBOOT_* */
#include <linux/stat.h>
#include <linux/time.h>
#include <linux/wait.h>
--
2.49.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 5/9] tools/nolibc: move getrlimit() and friends to sys/resource.h
2025-05-15 19:57 [PATCH 0/9] tools/nolibc: split out more headers Thomas Weißschuh
` (3 preceding siblings ...)
2025-05-15 19:57 ` [PATCH 4/9] tools/nolibc: move reboot() to sys/reboot.h Thomas Weißschuh
@ 2025-05-15 19:57 ` Thomas Weißschuh
2025-05-15 19:57 ` [PATCH 6/9] tools/nolibc: move makedev() and friends to sys/sysmacros.h Thomas Weißschuh
` (4 subsequent siblings)
9 siblings, 0 replies; 19+ messages in thread
From: Thomas Weißschuh @ 2025-05-15 19:57 UTC (permalink / raw)
To: Willy Tarreau, Shuah Khan
Cc: linux-kernel, linux-kselftest, Thomas Weißschuh
This is the location regular userspace expects these definitions.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
tools/include/nolibc/Makefile | 1 +
tools/include/nolibc/nolibc.h | 1 +
tools/include/nolibc/sys.h | 38 --------------------------
tools/include/nolibc/sys/resource.h | 53 +++++++++++++++++++++++++++++++++++++
tools/include/nolibc/types.h | 1 -
5 files changed, 55 insertions(+), 39 deletions(-)
diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile
index 4850501b8d53be6b603ecbb04d6f952cd5370cf0..cc82399e940e53940061b60588566db51f2e191a 100644
--- a/tools/include/nolibc/Makefile
+++ b/tools/include/nolibc/Makefile
@@ -55,6 +55,7 @@ all_files := \
sys/prctl.h \
sys/random.h \
sys/reboot.h \
+ sys/resource.h \
sys/stat.h \
sys/syscall.h \
sys/time.h \
diff --git a/tools/include/nolibc/nolibc.h b/tools/include/nolibc/nolibc.h
index 36ea7a02c7434cc006a7b12d413add04a2f85565..7d151776e47a30080dc3d961bcdeacd6ab558629 100644
--- a/tools/include/nolibc/nolibc.h
+++ b/tools/include/nolibc/nolibc.h
@@ -103,6 +103,7 @@
#include "sys/prctl.h"
#include "sys/random.h"
#include "sys/reboot.h"
+#include "sys/resource.h"
#include "sys/stat.h"
#include "sys/syscall.h"
#include "sys/time.h"
diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h
index 6c89dd0316dd0ebf03ebde6fa5c14273df6a0c62..282909b1992d17d5292917fbabb0bd2a2dbfce88 100644
--- a/tools/include/nolibc/sys.h
+++ b/tools/include/nolibc/sys.h
@@ -23,7 +23,6 @@
#include <linux/auxvec.h>
#include <linux/fcntl.h> /* for O_* and AT_* */
#include <linux/stat.h> /* for statx() */
-#include <linux/resource.h>
#include <linux/utsname.h>
#include "errno.h"
@@ -730,43 +729,6 @@ ssize_t read(int fd, void *buf, size_t count)
}
-/*
- * int getrlimit(int resource, struct rlimit *rlim);
- * int setrlimit(int resource, const struct rlimit *rlim);
- */
-
-static __attribute__((unused))
-int sys_prlimit64(pid_t pid, int resource,
- const struct rlimit64 *new_limit, struct rlimit64 *old_limit)
-{
- return my_syscall4(__NR_prlimit64, pid, resource, new_limit, old_limit);
-}
-
-static __attribute__((unused))
-int getrlimit(int resource, struct rlimit *rlim)
-{
- struct rlimit64 rlim64;
- int ret;
-
- ret = __sysret(sys_prlimit64(0, resource, NULL, &rlim64));
- rlim->rlim_cur = rlim64.rlim_cur;
- rlim->rlim_max = rlim64.rlim_max;
-
- return ret;
-}
-
-static __attribute__((unused))
-int setrlimit(int resource, const struct rlimit *rlim)
-{
- struct rlimit64 rlim64 = {
- .rlim_cur = rlim->rlim_cur,
- .rlim_max = rlim->rlim_max,
- };
-
- return __sysret(sys_prlimit64(0, resource, &rlim64, NULL));
-}
-
-
/*
* int sched_yield(void);
*/
diff --git a/tools/include/nolibc/sys/resource.h b/tools/include/nolibc/sys/resource.h
new file mode 100644
index 0000000000000000000000000000000000000000..ac2705a67e8b3abacffa57f097095b98afa1469c
--- /dev/null
+++ b/tools/include/nolibc/sys/resource.h
@@ -0,0 +1,53 @@
+/* SPDX-License-Identifier: LGPL-2.1 OR MIT */
+/*
+ * Resource definitions for NOLIBC
+ * Copyright (C) 2017-2021 Willy Tarreau <w@1wt.eu>
+ */
+
+/* make sure to include all global symbols */
+#include "nolibc.h"
+
+#ifndef _NOLIBC_SYS_RESOURCE_H
+#define _NOLIBC_SYS_RESOURCE_H
+
+#include "../sys.h"
+
+#include <linux/resource.h>
+
+/*
+ * int getrlimit(int resource, struct rlimit *rlim);
+ * int setrlimit(int resource, const struct rlimit *rlim);
+ */
+
+static __attribute__((unused))
+int sys_prlimit64(pid_t pid, int resource,
+ const struct rlimit64 *new_limit, struct rlimit64 *old_limit)
+{
+ return my_syscall4(__NR_prlimit64, pid, resource, new_limit, old_limit);
+}
+
+static __attribute__((unused))
+int getrlimit(int resource, struct rlimit *rlim)
+{
+ struct rlimit64 rlim64;
+ int ret;
+
+ ret = __sysret(sys_prlimit64(0, resource, NULL, &rlim64));
+ rlim->rlim_cur = rlim64.rlim_cur;
+ rlim->rlim_max = rlim64.rlim_max;
+
+ return ret;
+}
+
+static __attribute__((unused))
+int setrlimit(int resource, const struct rlimit *rlim)
+{
+ struct rlimit64 rlim64 = {
+ .rlim_cur = rlim->rlim_cur,
+ .rlim_max = rlim->rlim_max,
+ };
+
+ return __sysret(sys_prlimit64(0, resource, &rlim64, NULL));
+}
+
+#endif /* _NOLIBC_SYS_RESOURCE_H */
diff --git a/tools/include/nolibc/types.h b/tools/include/nolibc/types.h
index 74c7694b2d5e54f7a86854697ac32a2ea2b62e86..2225c9388a46480a18e9ce603b08d846e5276bab 100644
--- a/tools/include/nolibc/types.h
+++ b/tools/include/nolibc/types.h
@@ -15,7 +15,6 @@
#include <linux/stat.h>
#include <linux/time.h>
#include <linux/wait.h>
-#include <linux/resource.h>
/* Only the generic macros and types may be defined here. The arch-specific
--
2.49.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 6/9] tools/nolibc: move makedev() and friends to sys/sysmacros.h
2025-05-15 19:57 [PATCH 0/9] tools/nolibc: split out more headers Thomas Weißschuh
` (4 preceding siblings ...)
2025-05-15 19:57 ` [PATCH 5/9] tools/nolibc: move getrlimit() and friends to sys/resource.h Thomas Weißschuh
@ 2025-05-15 19:57 ` Thomas Weißschuh
2025-05-15 19:57 ` [PATCH 7/9] tools/nolibc: move uname() and friends to sys/utsname.h Thomas Weißschuh
` (3 subsequent siblings)
9 siblings, 0 replies; 19+ messages in thread
From: Thomas Weißschuh @ 2025-05-15 19:57 UTC (permalink / raw)
To: Willy Tarreau, Shuah Khan
Cc: linux-kernel, linux-kselftest, Thomas Weißschuh
This is the location regular userspace expects these definitions.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
tools/include/nolibc/Makefile | 1 +
tools/include/nolibc/nolibc.h | 1 +
tools/include/nolibc/sys/sysmacros.h | 20 ++++++++++++++++++++
tools/include/nolibc/types.h | 5 -----
4 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile
index cc82399e940e53940061b60588566db51f2e191a..ae04de46cdfeb2080d95b60c3d16e1c9f3692c9c 100644
--- a/tools/include/nolibc/Makefile
+++ b/tools/include/nolibc/Makefile
@@ -58,6 +58,7 @@ all_files := \
sys/resource.h \
sys/stat.h \
sys/syscall.h \
+ sys/sysmacros.h \
sys/time.h \
sys/timerfd.h \
sys/types.h \
diff --git a/tools/include/nolibc/nolibc.h b/tools/include/nolibc/nolibc.h
index 7d151776e47a30080dc3d961bcdeacd6ab558629..182dcfce126638db1cc9fd3fa79ab99835b42c26 100644
--- a/tools/include/nolibc/nolibc.h
+++ b/tools/include/nolibc/nolibc.h
@@ -106,6 +106,7 @@
#include "sys/resource.h"
#include "sys/stat.h"
#include "sys/syscall.h"
+#include "sys/sysmacros.h"
#include "sys/time.h"
#include "sys/timerfd.h"
#include "sys/wait.h"
diff --git a/tools/include/nolibc/sys/sysmacros.h b/tools/include/nolibc/sys/sysmacros.h
new file mode 100644
index 0000000000000000000000000000000000000000..e7e24dda1dbb51df92307def00f3670459b2409c
--- /dev/null
+++ b/tools/include/nolibc/sys/sysmacros.h
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: LGPL-2.1 OR MIT */
+/*
+ * Sysmacro definitions for NOLIBC
+ * Copyright (C) 2017-2021 Willy Tarreau <w@1wt.eu>
+ */
+
+/* make sure to include all global symbols */
+#include "nolibc.h"
+
+#ifndef _NOLIBC_SYS_SYSMACROS_H
+#define _NOLIBC_SYS_SYSMACROS_H
+
+#include "../std.h"
+
+/* WARNING, it only deals with the 4096 first majors and 256 first minors */
+#define makedev(major, minor) ((dev_t)((((major) & 0xfff) << 8) | ((minor) & 0xff)))
+#define major(dev) ((unsigned int)(((dev) >> 8) & 0xfff))
+#define minor(dev) ((unsigned int)((dev) & 0xff))
+
+#endif /* _NOLIBC_SYS_SYSMACROS_H */
diff --git a/tools/include/nolibc/types.h b/tools/include/nolibc/types.h
index 2225c9388a46480a18e9ce603b08d846e5276bab..0071bfbc23154cf9b47b0bd747101fea4955018d 100644
--- a/tools/include/nolibc/types.h
+++ b/tools/include/nolibc/types.h
@@ -188,11 +188,6 @@ struct stat {
typedef __kernel_clockid_t clockid_t;
typedef int timer_t;
-/* WARNING, it only deals with the 4096 first majors and 256 first minors */
-#define makedev(major, minor) ((dev_t)((((major) & 0xfff) << 8) | ((minor) & 0xff)))
-#define major(dev) ((unsigned int)(((dev) >> 8) & 0xfff))
-#define minor(dev) ((unsigned int)((dev) & 0xff))
-
#ifndef offsetof
#define offsetof(TYPE, FIELD) ((size_t) &((TYPE *)0)->FIELD)
#endif
--
2.49.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 7/9] tools/nolibc: move uname() and friends to sys/utsname.h
2025-05-15 19:57 [PATCH 0/9] tools/nolibc: split out more headers Thomas Weißschuh
` (5 preceding siblings ...)
2025-05-15 19:57 ` [PATCH 6/9] tools/nolibc: move makedev() and friends to sys/sysmacros.h Thomas Weißschuh
@ 2025-05-15 19:57 ` Thomas Weißschuh
2025-05-15 19:57 ` [PATCH 8/9] tools/nolibc: move NULL and offsetof() to sys/stddef.h Thomas Weißschuh
` (2 subsequent siblings)
9 siblings, 0 replies; 19+ messages in thread
From: Thomas Weißschuh @ 2025-05-15 19:57 UTC (permalink / raw)
To: Willy Tarreau, Shuah Khan
Cc: linux-kernel, linux-kselftest, Thomas Weißschuh
This is the location regular userspace expects these definitions.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
tools/include/nolibc/Makefile | 1 +
tools/include/nolibc/nolibc.h | 1 +
tools/include/nolibc/sys.h | 27 ------------------------
tools/include/nolibc/sys/utsname.h | 42 ++++++++++++++++++++++++++++++++++++++
4 files changed, 44 insertions(+), 27 deletions(-)
diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile
index ae04de46cdfeb2080d95b60c3d16e1c9f3692c9c..0ff06374577df457b0611d91dcfe637a05476364 100644
--- a/tools/include/nolibc/Makefile
+++ b/tools/include/nolibc/Makefile
@@ -62,6 +62,7 @@ all_files := \
sys/time.h \
sys/timerfd.h \
sys/types.h \
+ sys/utsname.h \
sys/wait.h \
time.h \
types.h \
diff --git a/tools/include/nolibc/nolibc.h b/tools/include/nolibc/nolibc.h
index 182dcfce126638db1cc9fd3fa79ab99835b42c26..c199ade200c240ef4081f767a162698256f39677 100644
--- a/tools/include/nolibc/nolibc.h
+++ b/tools/include/nolibc/nolibc.h
@@ -109,6 +109,7 @@
#include "sys/sysmacros.h"
#include "sys/time.h"
#include "sys/timerfd.h"
+#include "sys/utsname.h"
#include "sys/wait.h"
#include "ctype.h"
#include "elf.h"
diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h
index 282909b1992d17d5292917fbabb0bd2a2dbfce88..9556c69a6ae1ff0f19d884f5022599fc31e04f1f 100644
--- a/tools/include/nolibc/sys.h
+++ b/tools/include/nolibc/sys.h
@@ -23,7 +23,6 @@
#include <linux/auxvec.h>
#include <linux/fcntl.h> /* for O_* and AT_* */
#include <linux/stat.h> /* for statx() */
-#include <linux/utsname.h>
#include "errno.h"
#include "stdarg.h"
@@ -894,32 +893,6 @@ int umount2(const char *path, int flags)
}
-/*
- * int uname(struct utsname *buf);
- */
-
-struct utsname {
- char sysname[65];
- char nodename[65];
- char release[65];
- char version[65];
- char machine[65];
- char domainname[65];
-};
-
-static __attribute__((unused))
-int sys_uname(struct utsname *buf)
-{
- return my_syscall1(__NR_uname, buf);
-}
-
-static __attribute__((unused))
-int uname(struct utsname *buf)
-{
- return __sysret(sys_uname(buf));
-}
-
-
/*
* int unlink(const char *path);
*/
diff --git a/tools/include/nolibc/sys/utsname.h b/tools/include/nolibc/sys/utsname.h
new file mode 100644
index 0000000000000000000000000000000000000000..3adda115085069403253c2a276de1e2ae9bb1ad3
--- /dev/null
+++ b/tools/include/nolibc/sys/utsname.h
@@ -0,0 +1,42 @@
+/* SPDX-License-Identifier: LGPL-2.1 OR MIT */
+/*
+ * Utsname definitions for NOLIBC
+ * Copyright (C) 2017-2021 Willy Tarreau <w@1wt.eu>
+ */
+
+/* make sure to include all global symbols */
+#include "nolibc.h"
+
+#ifndef _NOLIBC_SYS_UTSNAME_H
+#define _NOLIBC_SYS_UTSNAME_H
+
+#include "../sys.h"
+
+#include <linux/utsname.h>
+
+/*
+ * int uname(struct utsname *buf);
+ */
+
+struct utsname {
+ char sysname[65];
+ char nodename[65];
+ char release[65];
+ char version[65];
+ char machine[65];
+ char domainname[65];
+};
+
+static __attribute__((unused))
+int sys_uname(struct utsname *buf)
+{
+ return my_syscall1(__NR_uname, buf);
+}
+
+static __attribute__((unused))
+int uname(struct utsname *buf)
+{
+ return __sysret(sys_uname(buf));
+}
+
+#endif /* _NOLIBC_SYS_UTSNAME_H */
--
2.49.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 8/9] tools/nolibc: move NULL and offsetof() to sys/stddef.h
2025-05-15 19:57 [PATCH 0/9] tools/nolibc: split out more headers Thomas Weißschuh
` (6 preceding siblings ...)
2025-05-15 19:57 ` [PATCH 7/9] tools/nolibc: move uname() and friends to sys/utsname.h Thomas Weißschuh
@ 2025-05-15 19:57 ` Thomas Weißschuh
2025-05-15 19:57 ` [PATCH 9/9] selftests/nolibc: drop include guards around standard headers Thomas Weißschuh
2025-05-16 3:50 ` [PATCH 0/9] tools/nolibc: split out more headers Willy Tarreau
9 siblings, 0 replies; 19+ messages in thread
From: Thomas Weißschuh @ 2025-05-15 19:57 UTC (permalink / raw)
To: Willy Tarreau, Shuah Khan
Cc: linux-kernel, linux-kselftest, Thomas Weißschuh
This is the location regular userspace expects these definitions.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
tools/include/nolibc/Makefile | 1 +
tools/include/nolibc/std.h | 6 +-----
tools/include/nolibc/stddef.h | 24 ++++++++++++++++++++++++
tools/include/nolibc/types.h | 4 ----
4 files changed, 26 insertions(+), 9 deletions(-)
diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile
index 0ff06374577df457b0611d91dcfe637a05476364..c4615bed731ced75a00867fdeb455d72652a7e42 100644
--- a/tools/include/nolibc/Makefile
+++ b/tools/include/nolibc/Makefile
@@ -44,6 +44,7 @@ all_files := \
std.h \
stdarg.h \
stdbool.h \
+ stddef.h \
stdint.h \
stdlib.h \
string.h \
diff --git a/tools/include/nolibc/std.h b/tools/include/nolibc/std.h
index 933bc0be7e1c6be3b7909efc127f1d3b9c611135..adda7333d12e7d2c336938ede1aaf215b4b93165 100644
--- a/tools/include/nolibc/std.h
+++ b/tools/include/nolibc/std.h
@@ -13,12 +13,8 @@
* syscall-specific stuff, as this file is expected to be included very early.
*/
-/* note: may already be defined */
-#ifndef NULL
-#define NULL ((void *)0)
-#endif
-
#include "stdint.h"
+#include "stddef.h"
/* those are commonly provided by sys/types.h */
typedef unsigned int dev_t;
diff --git a/tools/include/nolibc/stddef.h b/tools/include/nolibc/stddef.h
new file mode 100644
index 0000000000000000000000000000000000000000..ecbd13eab1f5190fd0e90a07699c2f06dbde8916
--- /dev/null
+++ b/tools/include/nolibc/stddef.h
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: LGPL-2.1 OR MIT */
+/*
+ * Stddef definitions for NOLIBC
+ * Copyright (C) 2017-2021 Willy Tarreau <w@1wt.eu>
+ */
+
+/* make sure to include all global symbols */
+#include "nolibc.h"
+
+#ifndef _NOLIBC_STDDEF_H
+#define _NOLIBC_STDDEF_H
+
+#include "stdint.h"
+
+/* note: may already be defined */
+#ifndef NULL
+#define NULL ((void *)0)
+#endif
+
+#ifndef offsetof
+#define offsetof(TYPE, FIELD) ((size_t) &((TYPE *)0)->FIELD)
+#endif
+
+#endif /* _NOLIBC_STDDEF_H */
diff --git a/tools/include/nolibc/types.h b/tools/include/nolibc/types.h
index 0071bfbc23154cf9b47b0bd747101fea4955018d..30904be544ed01b212042ebc0f4dab610f64b216 100644
--- a/tools/include/nolibc/types.h
+++ b/tools/include/nolibc/types.h
@@ -188,10 +188,6 @@ struct stat {
typedef __kernel_clockid_t clockid_t;
typedef int timer_t;
-#ifndef offsetof
-#define offsetof(TYPE, FIELD) ((size_t) &((TYPE *)0)->FIELD)
-#endif
-
#ifndef container_of
#define container_of(PTR, TYPE, FIELD) ({ \
__typeof__(((TYPE *)0)->FIELD) *__FIELD_PTR = (PTR); \
--
2.49.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 9/9] selftests/nolibc: drop include guards around standard headers
2025-05-15 19:57 [PATCH 0/9] tools/nolibc: split out more headers Thomas Weißschuh
` (7 preceding siblings ...)
2025-05-15 19:57 ` [PATCH 8/9] tools/nolibc: move NULL and offsetof() to sys/stddef.h Thomas Weißschuh
@ 2025-05-15 19:57 ` Thomas Weißschuh
2025-05-16 3:50 ` [PATCH 0/9] tools/nolibc: split out more headers Willy Tarreau
9 siblings, 0 replies; 19+ messages in thread
From: Thomas Weißschuh @ 2025-05-15 19:57 UTC (permalink / raw)
To: Willy Tarreau, Shuah Khan
Cc: linux-kernel, linux-kselftest, Thomas Weißschuh
Nolibc now provides all the headers required by nolibc-test.c.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
tools/testing/selftests/nolibc/nolibc-test.c | 5 -----
1 file changed, 5 deletions(-)
diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c
index 0391c7d01380ea2f20d1d07497ea1964bcb6a9f4..dbe13000fb1ac153e9a89f627492daeb584a05d4 100644
--- a/tools/testing/selftests/nolibc/nolibc-test.c
+++ b/tools/testing/selftests/nolibc/nolibc-test.c
@@ -9,12 +9,9 @@
* $(CC) -nostdlib -I/path/to/nolibc/sysroot => _NOLIBC_* guards are present
* $(CC) with default libc => NOLIBC* never defined
*/
-#ifndef NOLIBC
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#ifndef _NOLIBC_STDIO_H
-/* standard libcs need more includes */
#include <sys/auxv.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
@@ -43,8 +40,6 @@
#include <unistd.h>
#include <limits.h>
#include <ctype.h>
-#endif
-#endif
#pragma GCC diagnostic ignored "-Wmissing-prototypes"
--
2.49.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH 0/9] tools/nolibc: split out more headers
2025-05-15 19:57 [PATCH 0/9] tools/nolibc: split out more headers Thomas Weißschuh
` (8 preceding siblings ...)
2025-05-15 19:57 ` [PATCH 9/9] selftests/nolibc: drop include guards around standard headers Thomas Weißschuh
@ 2025-05-16 3:50 ` Willy Tarreau
9 siblings, 0 replies; 19+ messages in thread
From: Willy Tarreau @ 2025-05-16 3:50 UTC (permalink / raw)
To: Thomas Weißschuh; +Cc: Shuah Khan, linux-kernel, linux-kselftest
On Thu, May 15, 2025 at 09:57:46PM +0200, Thomas Weißschuh wrote:
> Split out all headers which are used by nolibc-test.c.
> This makes it easier to port existing applications to nolibc.
Nice work, it's pleasant to no longer see #ifdef NOLIBC in the .c. I'll
eventually try to do the same in my init code once I'm in vacation, it's
likely that it will be sufficient as well now.
For the series: Acked-by: Willy Tarreau <w@1wt.eu>
Thanks!
Willy
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 1/9] tools/nolibc: move ioctl() to sys/ioctl.h
2025-05-15 19:57 ` [PATCH 1/9] tools/nolibc: move ioctl() to sys/ioctl.h Thomas Weißschuh
@ 2025-05-21 13:03 ` Mark Brown
2025-05-21 13:08 ` Thomas Weißschuh
0 siblings, 1 reply; 19+ messages in thread
From: Mark Brown @ 2025-05-21 13:03 UTC (permalink / raw)
To: Thomas Weißschuh
Cc: Willy Tarreau, Shuah Khan, linux-kernel, linux-kselftest
[-- Attachment #1: Type: text/plain, Size: 1558 bytes --]
On Thu, May 15, 2025 at 09:57:47PM +0200, Thomas Weißschuh wrote:
> This is the location regular userspace expects this definition.
>
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
This is in -next as b8c436bbef0f2a and breaks the build of all the arm64
selftests using nolibc:
clang --target=aarch64-linux-gnu -fintegrated-as -fno-asynchronous-unwind-tables -fno-ident -s -Os -nostdlib \
-static -include ../../../../include/nolibc/nolibc.h \
-ffreestanding -Wall tpidr2.c -o /home/broonie/git/bisect/tools/testing/selftests/arm64/abi/tpidr2 -lgcc
In file included from <built-in>:1:
In file included from ./../../../../include/nolibc/nolibc.h:100:
./../../../../include/nolibc/sys/ioctl.h:8:10: fatal error: 'nolibc.h' file not found
8 | #include "nolibc.h"
| ^~~~~~~~~~
1 error generated.
This happens because:
> +++ b/tools/include/nolibc/sys/ioctl.h
> @@ -0,0 +1,29 @@
> +/* SPDX-License-Identifier: LGPL-2.1 OR MIT */
> +/*
> + * Ioctl definitions for NOLIBC
> + * Copyright (C) 2017-2021 Willy Tarreau <w@1wt.eu>
> + */
> +
> +/* make sure to include all global symbols */
> +#include "nolibc.h"
assumes that the nolibc include directory is in the include path, or
otherwise set up with a -I path, previously you just had to include
nolibc.h with the includes that are there working due to being relative
to nolibc.h. I'll send a patch for the arm64 tests.
It looks like the RISC-V selftests are also impacted, I didn't spot any
other users that didn't already have an -I.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 1/9] tools/nolibc: move ioctl() to sys/ioctl.h
2025-05-21 13:03 ` Mark Brown
@ 2025-05-21 13:08 ` Thomas Weißschuh
2025-05-21 13:22 ` Mark Brown
0 siblings, 1 reply; 19+ messages in thread
From: Thomas Weißschuh @ 2025-05-21 13:08 UTC (permalink / raw)
To: Mark Brown; +Cc: Willy Tarreau, Shuah Khan, linux-kernel, linux-kselftest
On 2025-05-21 14:03:37+0100, Mark Brown wrote:
> On Thu, May 15, 2025 at 09:57:47PM +0200, Thomas Weißschuh wrote:
> > This is the location regular userspace expects this definition.
> >
> > Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
>
> This is in -next as b8c436bbef0f2a and breaks the build of all the arm64
> selftests using nolibc:
>
> clang --target=aarch64-linux-gnu -fintegrated-as -fno-asynchronous-unwind-tables -fno-ident -s -Os -nostdlib \
> -static -include ../../../../include/nolibc/nolibc.h \
> -ffreestanding -Wall tpidr2.c -o /home/broonie/git/bisect/tools/testing/selftests/arm64/abi/tpidr2 -lgcc
> In file included from <built-in>:1:
> In file included from ./../../../../include/nolibc/nolibc.h:100:
> ./../../../../include/nolibc/sys/ioctl.h:8:10: fatal error: 'nolibc.h' file not found
> 8 | #include "nolibc.h"
> | ^~~~~~~~~~
> 1 error generated.
>
> This happens because:
>
> > +++ b/tools/include/nolibc/sys/ioctl.h
> > @@ -0,0 +1,29 @@
> > +/* SPDX-License-Identifier: LGPL-2.1 OR MIT */
> > +/*
> > + * Ioctl definitions for NOLIBC
> > + * Copyright (C) 2017-2021 Willy Tarreau <w@1wt.eu>
> > + */
> > +
> > +/* make sure to include all global symbols */
> > +#include "nolibc.h"
>
> assumes that the nolibc include directory is in the include path, or
> otherwise set up with a -I path, previously you just had to include
> nolibc.h with the includes that are there working due to being relative
> to nolibc.h. I'll send a patch for the arm64 tests.
Thanks for the report.
Inside sys/ this should actually be #include "../nolibc.h".
I'll doublecheck all of sys/ and see why our new header checks didn't
catch this.
> It looks like the RISC-V selftests are also impacted, I didn't spot any
> other users that didn't already have an -I.
No changes to the selftests should be necessary.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 1/9] tools/nolibc: move ioctl() to sys/ioctl.h
2025-05-21 13:08 ` Thomas Weißschuh
@ 2025-05-21 13:22 ` Mark Brown
2025-05-21 13:45 ` Thomas Weißschuh
0 siblings, 1 reply; 19+ messages in thread
From: Mark Brown @ 2025-05-21 13:22 UTC (permalink / raw)
To: Thomas Weißschuh
Cc: Willy Tarreau, Shuah Khan, linux-kernel, linux-kselftest
[-- Attachment #1: Type: text/plain, Size: 1088 bytes --]
On Wed, May 21, 2025 at 03:08:05PM +0200, Thomas Weißschuh wrote:
> On 2025-05-21 14:03:37+0100, Mark Brown wrote:
> > > +/* make sure to include all global symbols */
> > > +#include "nolibc.h"
> > assumes that the nolibc include directory is in the include path, or
> > otherwise set up with a -I path, previously you just had to include
> > nolibc.h with the includes that are there working due to being relative
> > to nolibc.h. I'll send a patch for the arm64 tests.
> Thanks for the report.
> Inside sys/ this should actually be #include "../nolibc.h".
> I'll doublecheck all of sys/ and see why our new header checks didn't
> catch this.
Ah, you expect what's currently there to work - good. I noticed that
the vDSO tests had a -I for the nolibc directory which made me think it
was expected that it be there, it's the only user on most arches.
> > It looks like the RISC-V selftests are also impacted, I didn't spot any
> > other users that didn't already have an -I.
> No changes to the selftests should be necessary.
OK, that's easier for me!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 1/9] tools/nolibc: move ioctl() to sys/ioctl.h
2025-05-21 13:22 ` Mark Brown
@ 2025-05-21 13:45 ` Thomas Weißschuh
2025-05-21 13:58 ` Mark Brown
2025-05-21 18:49 ` Mark Brown
0 siblings, 2 replies; 19+ messages in thread
From: Thomas Weißschuh @ 2025-05-21 13:45 UTC (permalink / raw)
To: Mark Brown; +Cc: Willy Tarreau, Shuah Khan, linux-kernel, linux-kselftest
On 2025-05-21 14:22:30+0100, Mark Brown wrote:
> On Wed, May 21, 2025 at 03:08:05PM +0200, Thomas Weißschuh wrote:
> > On 2025-05-21 14:03:37+0100, Mark Brown wrote:
>
> > > > +/* make sure to include all global symbols */
> > > > +#include "nolibc.h"
>
> > > assumes that the nolibc include directory is in the include path, or
> > > otherwise set up with a -I path, previously you just had to include
> > > nolibc.h with the includes that are there working due to being relative
> > > to nolibc.h. I'll send a patch for the arm64 tests.
>
> > Thanks for the report.
> > Inside sys/ this should actually be #include "../nolibc.h".
> > I'll doublecheck all of sys/ and see why our new header checks didn't
> > catch this.
>
> Ah, you expect what's currently there to work - good. I noticed that
> the vDSO tests had a -I for the nolibc directory which made me think it
> was expected that it be there, it's the only user on most arches.
The -I is useful to compile applications without guarding the system
includes with #ifndef NOLIBC.
What do I have to do to cross-compile these selftests?
I get various compiler errors.
Or you could run your testsuite with the new nolibc for-next branch
which should be fixed now.
<snip>
Thomas
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 1/9] tools/nolibc: move ioctl() to sys/ioctl.h
2025-05-21 13:45 ` Thomas Weißschuh
@ 2025-05-21 13:58 ` Mark Brown
2025-05-21 18:49 ` Mark Brown
1 sibling, 0 replies; 19+ messages in thread
From: Mark Brown @ 2025-05-21 13:58 UTC (permalink / raw)
To: Thomas Weißschuh
Cc: Willy Tarreau, Shuah Khan, linux-kernel, linux-kselftest
[-- Attachment #1: Type: text/plain, Size: 946 bytes --]
On Wed, May 21, 2025 at 03:45:42PM +0200, Thomas Weißschuh wrote:
> On 2025-05-21 14:22:30+0100, Mark Brown wrote:
> > Ah, you expect what's currently there to work - good. I noticed that
> > the vDSO tests had a -I for the nolibc directory which made me think it
> > was expected that it be there, it's the only user on most arches.
> The -I is useful to compile applications without guarding the system
> includes with #ifndef NOLIBC.
These tests are all nolibc specific and so don't reference the system
headers, the whole point is to not use a real libc.
> What do I have to do to cross-compile these selftests?
> I get various compiler errors.
Any specific errors? It's just a standard selftest build, eg:
make -C tools/testing/selftests LLVM=1 ARCH=arm64 TARGETS=arm64
Unless you've got very current userspace headers you'll probably need
a headers_install too (that's generally needed for the selftests).
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 1/9] tools/nolibc: move ioctl() to sys/ioctl.h
2025-05-21 13:45 ` Thomas Weißschuh
2025-05-21 13:58 ` Mark Brown
@ 2025-05-21 18:49 ` Mark Brown
2025-05-23 8:33 ` Thomas Weißschuh
1 sibling, 1 reply; 19+ messages in thread
From: Mark Brown @ 2025-05-21 18:49 UTC (permalink / raw)
To: Thomas Weißschuh
Cc: Willy Tarreau, Shuah Khan, linux-kernel, linux-kselftest
[-- Attachment #1: Type: text/plain, Size: 354 bytes --]
On Wed, May 21, 2025 at 03:45:42PM +0200, Thomas Weißschuh wrote:
> Or you could run your testsuite with the new nolibc for-next branch
> which should be fixed now.
That seems to build with 869c788909b93a78ead1ca28c42b95eeb0779215 which
is the current HEAD of:
git://git.kernel.org/pub/scm/linux/kernel/git/nolibc/linux-nolibc.git for-next
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 1/9] tools/nolibc: move ioctl() to sys/ioctl.h
2025-05-21 18:49 ` Mark Brown
@ 2025-05-23 8:33 ` Thomas Weißschuh
2025-05-23 10:14 ` Mark Brown
0 siblings, 1 reply; 19+ messages in thread
From: Thomas Weißschuh @ 2025-05-23 8:33 UTC (permalink / raw)
To: Mark Brown; +Cc: Willy Tarreau, Shuah Khan, linux-kernel, linux-kselftest
On 2025-05-21 19:49:39+0100, Mark Brown wrote:
> On Wed, May 21, 2025 at 03:45:42PM +0200, Thomas Weißschuh wrote:
>
> > Or you could run your testsuite with the new nolibc for-next branch
> > which should be fixed now.
>
> That seems to build with 869c788909b93a78ead1ca28c42b95eeb0779215 which
> is the current HEAD of:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/nolibc/linux-nolibc.git for-next
Thanks for testing!
To be sure, was this your full test-run? Or did you do a full test-run
on linux-next in the meantime?
I'd like to get your confirmation before sending these changes to Linus.
Thomas
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 1/9] tools/nolibc: move ioctl() to sys/ioctl.h
2025-05-23 8:33 ` Thomas Weißschuh
@ 2025-05-23 10:14 ` Mark Brown
0 siblings, 0 replies; 19+ messages in thread
From: Mark Brown @ 2025-05-23 10:14 UTC (permalink / raw)
To: Thomas Weißschuh
Cc: Willy Tarreau, Shuah Khan, linux-kernel, linux-kselftest
[-- Attachment #1: Type: text/plain, Size: 956 bytes --]
On Fri, May 23, 2025 at 10:33:13AM +0200, Thomas Weißschuh wrote:
> On 2025-05-21 19:49:39+0100, Mark Brown wrote:
> > That seems to build with 869c788909b93a78ead1ca28c42b95eeb0779215 which
> > is the current HEAD of:
> > git://git.kernel.org/pub/scm/linux/kernel/git/nolibc/linux-nolibc.git for-next
> Thanks for testing!
> To be sure, was this your full test-run? Or did you do a full test-run
Just a build of the arm64 selftests (which are the only thing I build
that was affected).
> on linux-next in the meantime?
> I'd like to get your confirmation before sending these changes to Linus.
Today's -next appears to have built and be running the arm64 selftests
OK again in my personal CI:
https://lava.sirena.org.uk/scheduler/job/1419721#L2482
There shoud also be results (both build and runtime) from KernelCI:
https://dashboard.kernelci.org/
but there might be a bit more lag seeing the results there.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2025-05-23 10:14 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-15 19:57 [PATCH 0/9] tools/nolibc: split out more headers Thomas Weißschuh
2025-05-15 19:57 ` [PATCH 1/9] tools/nolibc: move ioctl() to sys/ioctl.h Thomas Weißschuh
2025-05-21 13:03 ` Mark Brown
2025-05-21 13:08 ` Thomas Weißschuh
2025-05-21 13:22 ` Mark Brown
2025-05-21 13:45 ` Thomas Weißschuh
2025-05-21 13:58 ` Mark Brown
2025-05-21 18:49 ` Mark Brown
2025-05-23 8:33 ` Thomas Weißschuh
2025-05-23 10:14 ` Mark Brown
2025-05-15 19:57 ` [PATCH 2/9] tools/nolibc: move mount() to sys/mount.h Thomas Weißschuh
2025-05-15 19:57 ` [PATCH 3/9] tools/nolibc: move prctl() to sys/prctl.h Thomas Weißschuh
2025-05-15 19:57 ` [PATCH 4/9] tools/nolibc: move reboot() to sys/reboot.h Thomas Weißschuh
2025-05-15 19:57 ` [PATCH 5/9] tools/nolibc: move getrlimit() and friends to sys/resource.h Thomas Weißschuh
2025-05-15 19:57 ` [PATCH 6/9] tools/nolibc: move makedev() and friends to sys/sysmacros.h Thomas Weißschuh
2025-05-15 19:57 ` [PATCH 7/9] tools/nolibc: move uname() and friends to sys/utsname.h Thomas Weißschuh
2025-05-15 19:57 ` [PATCH 8/9] tools/nolibc: move NULL and offsetof() to sys/stddef.h Thomas Weißschuh
2025-05-15 19:57 ` [PATCH 9/9] selftests/nolibc: drop include guards around standard headers Thomas Weißschuh
2025-05-16 3:50 ` [PATCH 0/9] tools/nolibc: split out more headers Willy Tarreau
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 NNTP newsgroup(s).