| 2d965c1a | 25-Sep-2025 |
André Almeida <andrealmeid@igalia.com> |
tools/nolibc: add stdbool.h to nolibc includes
Otherwise tests compiled with only "-include nolibc.h" will fail with "error: unknown type name 'bool'", even though a stdbool.h is available from noli
tools/nolibc: add stdbool.h to nolibc includes
Otherwise tests compiled with only "-include nolibc.h" will fail with "error: unknown type name 'bool'", even though a stdbool.h is available from nolibc.
Fixes: ae1f550efc11 ("tools/nolibc: add stdbool.h header") Fixes: f2662ec26b26 ("selftests: kselftest: Create ksft_print_dbg_msg()") Reported-by: Mark Brown <broonie@kernel.org> Closes: https://lore.kernel.org/lkml/833f5ae5-190e-47ec-9ad9-127ad166c80c@sirena.org.uk/ Signed-off-by: André Almeida <andrealmeid@igalia.com> [Thomas: add Fixes tags and massage commit message a bit] Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
show more ...
|
| 0ff52df6 | 19-Sep-2025 |
Zhouyi Zhou <zhouzhouyi@gmail.com> |
tools/nolibc: make time_t robust if __kernel_old_time_t is missing in host headers
Commit d5094bcb5bfd ("tools/nolibc: define time_t in terms of __kernel_old_time_t") made nolibc use the kernel's ti
tools/nolibc: make time_t robust if __kernel_old_time_t is missing in host headers
Commit d5094bcb5bfd ("tools/nolibc: define time_t in terms of __kernel_old_time_t") made nolibc use the kernel's time type so that `time_t` matches `timespec::tv_sec` on all ABIs (notably x32).
But since __kernel_old_time_t is fairly new, notably from 2020 in commit 94c467ddb273 ("y2038: add __kernel_old_timespec and __kernel_old_time_t"), nolibc builds that rely on host headers may fail.
Switch to __kernel_time_t, which is the same as __kernel_old_time_t and has existed for longer.
Tested in PPC VM of Open Source Lab of Oregon State University (./tools/testing/selftests/rcutorture/bin/mkinitrd.sh)
Fixes: d5094bcb5bfd ("tools/nolibc: define time_t in terms of __kernel_old_time_t") Signed-off-by: Zhouyi Zhou <zhouzhouyi@gmail.com> [Thomas: Reformat commit and its message a bit] Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
show more ...
|
| 4c2ef951 | 21-Aug-2025 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: drop wait4() support
Not all architectures implement the wait4() syscall. It can be implemented in terms of the waitid() syscall, but that would require some rework of the other wait-r
tools/nolibc: drop wait4() support
Not all architectures implement the wait4() syscall. It can be implemented in terms of the waitid() syscall, but that would require some rework of the other wait-related functions in wait.h.
As wait4() is non-standard and deprecated, remove it.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Acked-by: Willy Tarreau <w@1wt.eu> Link: https://lore.kernel.org/r/20250821-nolibc-enosys-v1-7-4b63f2caaa89@weissschuh.net
show more ...
|
| f11e156e | 21-Aug-2025 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: fold llseek fallback into lseek()
Align the implementation of the fallback handling inside sys_lseek() with the rest of nolibc.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
tools/nolibc: fold llseek fallback into lseek()
Align the implementation of the fallback handling inside sys_lseek() with the rest of nolibc.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Acked-by: Willy Tarreau <w@1wt.eu> Link: https://lore.kernel.org/r/20250821-nolibc-enosys-v1-5-4b63f2caaa89@weissschuh.net
show more ...
|
| fbd47de7 | 21-Aug-2025 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: remove __nolibc_enosys() fallback from fork functions
All architectures have one of the real functions available. The additional fallback to __nolibc_enosys() is superfluous.
Signed-o
tools/nolibc: remove __nolibc_enosys() fallback from fork functions
All architectures have one of the real functions available. The additional fallback to __nolibc_enosys() is superfluous.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Acked-by: Willy Tarreau <w@1wt.eu> Link: https://lore.kernel.org/r/20250821-nolibc-enosys-v1-4-4b63f2caaa89@weissschuh.net
show more ...
|
| 09adec1f | 21-Aug-2025 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: remove __nolibc_enosys() fallback from dup2()
All architectures have one of the real functions available. The additional fallback to __nolibc_enosys() is superfluous.
Signed-off-by: T
tools/nolibc: remove __nolibc_enosys() fallback from dup2()
All architectures have one of the real functions available. The additional fallback to __nolibc_enosys() is superfluous.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Acked-by: Willy Tarreau <w@1wt.eu> Link: https://lore.kernel.org/r/20250821-nolibc-enosys-v1-3-4b63f2caaa89@weissschuh.net
show more ...
|
| 4b6ffb2d | 21-Aug-2025 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: remove __nolibc_enosys() fallback from *at() functions
All architectures have had one of the real functions available since Linux 2.6.12. The additional fallback to __nolibc_enosys() i
tools/nolibc: remove __nolibc_enosys() fallback from *at() functions
All architectures have had one of the real functions available since Linux 2.6.12. The additional fallback to __nolibc_enosys() is superfluous.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Acked-by: Willy Tarreau <w@1wt.eu> Link: https://lore.kernel.org/r/20250821-nolibc-enosys-v1-2-4b63f2caaa89@weissschuh.net
show more ...
|
| e6366101 | 21-Aug-2025 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: remove __nolibc_enosys() fallback from time64-related functions
These fallbacks where added when no explicit fallbacks for time64 was implemented. Now that these fallbacks are in place
tools/nolibc: remove __nolibc_enosys() fallback from time64-related functions
These fallbacks where added when no explicit fallbacks for time64 was implemented. Now that these fallbacks are in place, the additional fallback to __nolibc_enosys() is superfluous.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Acked-by: Willy Tarreau <w@1wt.eu> Link: https://lore.kernel.org/r/20250821-nolibc-enosys-v1-1-4b63f2caaa89@weissschuh.net
show more ...
|
| d1ff0e2d | 20-Aug-2025 |
Thomas Weißschuh <thomas.weissschuh@linutronix.de> |
tools/nolibc: avoid error in dup2() if old fd equals new fd
dup2() allows both 'old' and 'new' to have the same value, which dup3() does not. If libc dup2() is implemented through the dup3() system
tools/nolibc: avoid error in dup2() if old fd equals new fd
dup2() allows both 'old' and 'new' to have the same value, which dup3() does not. If libc dup2() is implemented through the dup3() system call, then it would incorrectly fail in this case.
Avoid the error by handling old == new explicitly.
Fixes: 30ca20517ac1 ("tools headers: Move the nolibc header from rcutorture to tools/include/nolibc/") Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de> Acked-by: Willy Tarreau <w@1wt.eu> Link: https://lore.kernel.org/r/20250820-nolibc-dup2-einval-v2-1-807185a45c56@linutronix.de Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
show more ...
|
| d5094bcb | 12-Jul-2025 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: define time_t in terms of __kernel_old_time_t
Nolibc assumes that the kernel ABI is using a time values that are as large as a long integer. For most ABIs this holds true. But for x32
tools/nolibc: define time_t in terms of __kernel_old_time_t
Nolibc assumes that the kernel ABI is using a time values that are as large as a long integer. For most ABIs this holds true. But for x32 this is not correct, as it uses 32bit longs but 64bit times.
Also the 'struct stat' implementation of nolibc relies on timespec::tv_sec and time_t being the same type. While timespec::tv_sec comes from the kernel and is of type __kernel_old_time_t, time_t is defined within nolibc.
Switch to the __kernel_old_time_t to always get the correct type.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Link: https://lore.kernel.org/r/20250712-nolibc-x32-v1-1-6d81cb798710@weissschuh.net Acked-by: Willy Tarreau <w@1wt.eu>
show more ...
|
| f6f6be0c | 20-Jun-2025 |
Thomas Weißschuh <thomas.weissschuh@linutronix.de> |
tools/nolibc: drop s390 clang target override
tools/scripts/Makefile.include now has the same override, removing the need for the one in the nolibc Makefile.
Drop the superfluous custom override.
tools/nolibc: drop s390 clang target override
tools/scripts/Makefile.include now has the same override, removing the need for the one in the nolibc Makefile.
Drop the superfluous custom override.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de> Link: https://lore.kernel.org/r/20250620-tools-cross-s390-v2-2-ecda886e00e5@linutronix.de Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
show more ...
|
| 31db7b6a | 07-Jul-2025 |
Thomas Weißschuh <thomas.weissschuh@linutronix.de> |
tools/nolibc: avoid false-positive -Wmaybe-uninitialized through waitpid()
The compiler does not know that waitid() will only ever return 0 or -1. If waitid() would return a positive value than wait
tools/nolibc: avoid false-positive -Wmaybe-uninitialized through waitpid()
The compiler does not know that waitid() will only ever return 0 or -1. If waitid() would return a positive value than waitpid() would return that same value and *status would not be initialized. However users calling waitpid() know that the only possible return values of it are 0 or -1. They therefore might check for errors with 'ret == -1' or 'ret < 0' and use *status otherwise. The compiler will then warn about the usage of a potentially uninitialized variable.
Example:
$ cat test.c #include <stdio.h> #include <unistd.h>
int main(void) { int ret, status;
ret = waitpid(0, &status, 0); if (ret == -1) return 0;
printf("status %x\n", status);
return 0; }
$ gcc --version gcc (GCC) 15.1.1 20250425
$ gcc -Wall -Os -Werror -nostdlib -nostdinc -static -Iusr/include -Itools/include/nolibc/ -o /dev/null test.c test.c: In function ‘main’: test.c:12:9: error: ‘status’ may be used uninitialized [-Werror=maybe-uninitialized] 12 | printf("status %x\n", status); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ test.c:6:18: note: ‘status’ was declared here 6 | int ret, status; | ^~~~~~ cc1: all warnings being treated as errors
Avoid the warning by normalizing waitid() errors to '-1' in waitpid().
Fixes: 0c89abf5ab3f ("tools/nolibc: implement waitpid() in terms of waitid()") Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de> Acked-by: Willy Tarreau <w@1wt.eu> Link: https://lore.kernel.org/r/20250707-nolibc-waitpid-uninitialized-v1-1-dcd4e70bcd8f@linutronix.de Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
show more ...
|
| 4a401290 | 04-Jul-2025 |
Thomas Weißschuh <thomas.weissschuh@linutronix.de> |
selftests/nolibc: correctly report errors from printf() and friends
When an error is encountered by printf() it needs to be reported. errno() is already set by the callback.
sprintf() is different,
selftests/nolibc: correctly report errors from printf() and friends
When an error is encountered by printf() it needs to be reported. errno() is already set by the callback.
sprintf() is different, but that keeps working and is already tested.
Also add a new test.
Fixes: 7e4346f4a3a6 ("tools/nolibc/stdio: add a minimal [vf]printf() implementation") Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de> Acked-by: Willy Tarreau <w@1wt.eu> Link: https://lore.kernel.org/r/20250704-nolibc-printf-error-v1-2-74b7a092433b@linutronix.de Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
show more ...
|
| fb476dfb | 03-Jul-2025 |
Mark Brown <broonie@kernel.org> |
tools/nolibc: Provide vfork()
To allow testing of vfork() support in the arm64 basic-gcs test provide an implementation for nolibc, using the vfork() syscall if one is available and otherwise clone3
tools/nolibc: Provide vfork()
To allow testing of vfork() support in the arm64 basic-gcs test provide an implementation for nolibc, using the vfork() syscall if one is available and otherwise clone3(). We implement in terms of clone3() since the order of the arguments for clone() varies between architectures.
As for fork() SPARC returns the parent PID rather than 0 in the child for vfork() so needs custom handling.
Signed-off-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20250703-arm64-gcs-vfork-exit-v3-2-1e9a9d2ddbbe@kernel.org Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
show more ...
|
| 8c11625a | 03-Jul-2025 |
Mark Brown <broonie@kernel.org> |
tools/nolibc: Replace ifdef with if defined() in sys.h
Thomas has requested that if defined() be used in place of ifdef but currently ifdef is used consistently in sys.h. Update all the instances of
tools/nolibc: Replace ifdef with if defined() in sys.h
Thomas has requested that if defined() be used in place of ifdef but currently ifdef is used consistently in sys.h. Update all the instances of ifdef to if defined().
Suggested-by: Thomas Weißschuh <linux@weissschuh.net> Signed-off-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20250703-arm64-gcs-vfork-exit-v3-1-1e9a9d2ddbbe@kernel.org Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
show more ...
|
| 02217ad4 | 23-Jun-2025 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: add support for SuperH
Add support for SuperH/"sh" to nolibc. Only sh4 is tested for now.
The startup code is special:
__nolibc_entrypoint_epilogue() calls __builtin_unreachable() wh
tools/nolibc: add support for SuperH
Add support for SuperH/"sh" to nolibc. Only sh4 is tested for now.
The startup code is special:
__nolibc_entrypoint_epilogue() calls __builtin_unreachable() which emits a call to abort(). To make this work a function prologue is generated to set up a GOT pointer which corrupts "sp". __builtin_unreachable() is necessary for __attribute__((noreturn)). Also depending on compiler flags (for example -fPIC) even more prologue is generated.
Work around this by defining a nested function in asm.
Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70216 Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Acked-by: Willy Tarreau <w@1wt.eu> Acked-by: Rob Landley <rob@landley.net> Acked-by: D. Jeff Dionne <jeff@coresemi.io> Tested-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de> Link: https://lore.kernel.org/r/20250623-nolibc-sh-v2-3-0f5b4b303025@weissschuh.net
show more ...
|
| a6a2a8a4 | 23-Jun-2025 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: MIPS: add support for N64 and N32 ABIs
Add support for the MIPS 64bit N64 and ILP32 N32 ABIs.
In addition to different byte orders and ABIs there are also different releases of the MI
tools/nolibc: MIPS: add support for N64 and N32 ABIs
Add support for the MIPS 64bit N64 and ILP32 N32 ABIs.
In addition to different byte orders and ABIs there are also different releases of the MIPS architecture. To avoid blowing up the test matrix, only add a subset of all possible test combinations.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Tested-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc> Link: https://lore.kernel.org/r/20250623-nolibc-mips-n32-v3-4-6ae2d89f4259@weissschuh.net
show more ...
|
| 69891dca | 23-Jun-2025 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: MIPS: drop noreorder option
There are no more statements in the assembly code which would require the usage of ".set noreorder".
Remove the option.
This also allows removal of the ma
tools/nolibc: MIPS: drop noreorder option
There are no more statements in the assembly code which would require the usage of ".set noreorder".
Remove the option.
This also allows removal of the manual "nop" instruction in the delay slot.
Suggested-by: Maciej W. Rozycki <macro@orcam.me.uk> Link: https://lore.kernel.org/lkml/alpine.DEB.2.21.2502172208570.65342@angie.orcam.me.uk/ Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Tested-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc> Link: https://lore.kernel.org/r/20250623-nolibc-mips-n32-v3-3-6ae2d89f4259@weissschuh.net
show more ...
|
| 36aab169 | 23-Jun-2025 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: MIPS: drop manual stack pointer alignment
The stack pointer is already aligned by the kernel to a multiple of 16. All modifications of the register have been removed from the entrypoin
tools/nolibc: MIPS: drop manual stack pointer alignment
The stack pointer is already aligned by the kernel to a multiple of 16. All modifications of the register have been removed from the entrypoint, so the manual realignment is unnecessary.
Drop the manual alignment.
Suggested-by: Maciej W. Rozycki <macro@orcam.me.uk> Link: https://lore.kernel.org/lkml/alpine.DEB.2.21.2502161523290.65342@angie.orcam.me.uk/ Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Tested-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc> Link: https://lore.kernel.org/r/20250623-nolibc-mips-n32-v3-2-6ae2d89f4259@weissschuh.net
show more ...
|
| f1e30334 | 23-Jun-2025 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: MIPS: drop $gp setup
The setup of the global pointer "$gp" register was necessary when the C entrypoint was called through "jal <symbol>". However since commit 0daf8c86a451 ("tools/nol
tools/nolibc: MIPS: drop $gp setup
The setup of the global pointer "$gp" register was necessary when the C entrypoint was called through "jal <symbol>". However since commit 0daf8c86a451 ("tools/nolibc: mips: load current function to $t9") "jalr" is used instead which does not require "$gp".
Remove the unnecessary $gp setup, simplifying the code and opening the road for some other cleanups.
Suggested-by: Maciej W. Rozycki <macro@orcam.me.uk> Link: https://lore.kernel.org/lkml/alpine.DEB.2.21.2502172208570.65342@angie.orcam.me.uk/ Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Tested-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc> Link: https://lore.kernel.org/r/20250623-nolibc-mips-n32-v3-1-6ae2d89f4259@weissschuh.net
show more ...
|
| 01e8a6d0 | 23-Jun-2025 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: use arm64 name over aarch64
Nolibc generally uses the kernel's architecture names. aarch64 is the only exception.
Remove the special case. Nothing changes for the users.
Acked-by: Wi
tools/nolibc: use arm64 name over aarch64
Nolibc generally uses the kernel's architecture names. aarch64 is the only exception.
Remove the special case. Nothing changes for the users.
Acked-by: Willy Tarreau <w@1wt.eu> Link: https://lore.kernel.org/r/20250623-nolibc-aarch64-arm64-v1-1-a2892f1c1b27@weissschuh.net Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
show more ...
|