* [PATCH 0/2] tools/nolibc: add x32 support
@ 2025-07-12 9:00 Thomas Weißschuh
2025-07-12 9:00 ` [PATCH 1/2] tools/nolibc: define time_t in terms of __kernel_old_time_t Thomas Weißschuh
2025-07-12 9:00 ` [PATCH 2/2] selftests/nolibc: add x32 test configuration Thomas Weißschuh
0 siblings, 2 replies; 4+ messages in thread
From: Thomas Weißschuh @ 2025-07-12 9:00 UTC (permalink / raw)
To: Willy Tarreau, Shuah Khan
Cc: linux-kernel, linux-kselftest, Thomas Weißschuh
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
Thomas Weißschuh (2):
tools/nolibc: define time_t in terms of __kernel_old_time_t
selftests/nolibc: add x32 test configuration
tools/include/nolibc/std.h | 4 +++-
tools/testing/selftests/nolibc/Makefile.nolibc | 12 ++++++++++++
tools/testing/selftests/nolibc/run-tests.sh | 7 ++++++-
3 files changed, 21 insertions(+), 2 deletions(-)
---
base-commit: 750aef513c610a37a13732ec64902428b839715e
change-id: 20250712-nolibc-x32-796a9da4c9ed
Best regards,
--
Thomas Weißschuh <linux@weissschuh.net>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] tools/nolibc: define time_t in terms of __kernel_old_time_t
2025-07-12 9:00 [PATCH 0/2] tools/nolibc: add x32 support Thomas Weißschuh
@ 2025-07-12 9:00 ` Thomas Weißschuh
2025-07-13 13:42 ` Willy Tarreau
2025-07-12 9:00 ` [PATCH 2/2] selftests/nolibc: add x32 test configuration Thomas Weißschuh
1 sibling, 1 reply; 4+ messages in thread
From: Thomas Weißschuh @ 2025-07-12 9:00 UTC (permalink / raw)
To: Willy Tarreau, Shuah Khan
Cc: linux-kernel, linux-kselftest, Thomas Weißschuh
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>
---
tools/include/nolibc/std.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/tools/include/nolibc/std.h b/tools/include/nolibc/std.h
index adda7333d12e7d2c336938ede1aaf215b4b93165..ba950f0e7338438823b4ee8c68a067391c719823 100644
--- a/tools/include/nolibc/std.h
+++ b/tools/include/nolibc/std.h
@@ -16,6 +16,8 @@
#include "stdint.h"
#include "stddef.h"
+#include <linux/types.h>
+
/* those are commonly provided by sys/types.h */
typedef unsigned int dev_t;
typedef unsigned long ino_t;
@@ -27,6 +29,6 @@ typedef unsigned long nlink_t;
typedef signed long off_t;
typedef signed long blksize_t;
typedef signed long blkcnt_t;
-typedef signed long time_t;
+typedef __kernel_old_time_t time_t;
#endif /* _NOLIBC_STD_H */
--
2.50.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] selftests/nolibc: add x32 test configuration
2025-07-12 9:00 [PATCH 0/2] tools/nolibc: add x32 support Thomas Weißschuh
2025-07-12 9:00 ` [PATCH 1/2] tools/nolibc: define time_t in terms of __kernel_old_time_t Thomas Weißschuh
@ 2025-07-12 9:00 ` Thomas Weißschuh
1 sibling, 0 replies; 4+ messages in thread
From: Thomas Weißschuh @ 2025-07-12 9:00 UTC (permalink / raw)
To: Willy Tarreau, Shuah Khan
Cc: linux-kernel, linux-kselftest, Thomas Weißschuh
Nolibc supports the x32 ABI on x86.
Add a testcase to make sure the support stays functional.
QEMU user does not have support for x32, so skip the test there.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
tools/testing/selftests/nolibc/Makefile.nolibc | 12 ++++++++++++
tools/testing/selftests/nolibc/run-tests.sh | 7 ++++++-
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/nolibc/Makefile.nolibc b/tools/testing/selftests/nolibc/Makefile.nolibc
index 51ba853dd97eebed32f9808b0979460071f2514f..0fb759ba992ee6b1693b88f1b2e77463afa9f38b 100644
--- a/tools/testing/selftests/nolibc/Makefile.nolibc
+++ b/tools/testing/selftests/nolibc/Makefile.nolibc
@@ -47,6 +47,7 @@ XARCH_riscv = riscv64
XARCH = $(or $(XARCH_$(ARCH)),$(ARCH))
# map from user input variants to their kernel supported architectures
+ARCH_x32 = x86
ARCH_armthumb = arm
ARCH_ppc = powerpc
ARCH_ppc64 = powerpc
@@ -68,6 +69,7 @@ ARCH := $(or $(ARCH_$(XARCH)),$(XARCH))
# kernel image names by architecture
IMAGE_i386 = arch/x86/boot/bzImage
IMAGE_x86_64 = arch/x86/boot/bzImage
+IMAGE_x32 = arch/x86/boot/bzImage
IMAGE_x86 = arch/x86/boot/bzImage
IMAGE_arm64 = arch/arm64/boot/Image
IMAGE_arm = arch/arm/boot/zImage
@@ -97,6 +99,7 @@ IMAGE_NAME = $(notdir $(IMAGE))
# default kernel configurations that appear to be usable
DEFCONFIG_i386 = defconfig
DEFCONFIG_x86_64 = defconfig
+DEFCONFIG_x32 = defconfig
DEFCONFIG_x86 = defconfig
DEFCONFIG_arm64 = defconfig
DEFCONFIG_arm = multi_v7_defconfig
@@ -122,6 +125,7 @@ DEFCONFIG_m68k = virt_defconfig
DEFCONFIG_sh4 = rts7751r2dplus_defconfig
DEFCONFIG = $(DEFCONFIG_$(XARCH))
+EXTRACONFIG_x32 = -e CONFIG_X86_X32_ABI
EXTRACONFIG_arm = -e CONFIG_NAMESPACES
EXTRACONFIG_armthumb = -e CONFIG_NAMESPACES
EXTRACONFIG_m68k = -e CONFIG_BLK_DEV_INITRD
@@ -134,6 +138,7 @@ TEST =
# QEMU_ARCH: arch names used by qemu
QEMU_ARCH_i386 = i386
QEMU_ARCH_x86_64 = x86_64
+QEMU_ARCH_x32 = x86_64
QEMU_ARCH_x86 = x86_64
QEMU_ARCH_arm64 = aarch64
QEMU_ARCH_arm = arm
@@ -174,6 +179,7 @@ endif
# QEMU_ARGS : some arch-specific args to pass to qemu
QEMU_ARGS_i386 = -M pc -append "console=ttyS0,9600 i8042.noaux panic=-1 $(TEST:%=NOLIBC_TEST=%)"
QEMU_ARGS_x86_64 = -M pc -append "console=ttyS0,9600 i8042.noaux panic=-1 $(TEST:%=NOLIBC_TEST=%)"
+QEMU_ARGS_x32 = -M pc -append "console=ttyS0,9600 i8042.noaux panic=-1 $(TEST:%=NOLIBC_TEST=%)"
QEMU_ARGS_x86 = -M pc -append "console=ttyS0,9600 i8042.noaux panic=-1 $(TEST:%=NOLIBC_TEST=%)"
QEMU_ARGS_arm64 = -M virt -cpu cortex-a53 -append "panic=-1 $(TEST:%=NOLIBC_TEST=%)"
QEMU_ARGS_arm = -M virt -append "panic=-1 $(TEST:%=NOLIBC_TEST=%)"
@@ -210,6 +216,7 @@ Q=@
endif
CFLAGS_i386 = $(call cc-option,-m32)
+CFLAGS_x32 = -mx32
CFLAGS_arm = -marm
CFLAGS_armthumb = -mthumb -march=armv6t2
CFLAGS_ppc = -m32 -mbig-endian -mno-vsx $(call cc-option,-mmultiple)
@@ -236,6 +243,11 @@ LDFLAGS :=
LIBGCC := -lgcc
+ifeq ($(ARCH),x86)
+# Not needed on x86, probably not present for x32
+LIBGCC :=
+endif
+
ifneq ($(LLVM),)
# Not needed for clang
LIBGCC :=
diff --git a/tools/testing/selftests/nolibc/run-tests.sh b/tools/testing/selftests/nolibc/run-tests.sh
index 43eb30be316ae7bac7f0ba2c38b494a283833bec..e8af1fb505cf3573b4a6b37228dee764fe2e5277 100755
--- a/tools/testing/selftests/nolibc/run-tests.sh
+++ b/tools/testing/selftests/nolibc/run-tests.sh
@@ -18,7 +18,7 @@ test_mode=system
werror=1
llvm=
all_archs=(
- i386 x86_64
+ i386 x86_64 x32
arm64 arm armthumb
mips32le mips32be mipsn32le mipsn32be mips64le mips64be
ppc ppc64 ppc64le
@@ -115,6 +115,7 @@ crosstool_arch() {
mips*) echo mips;;
s390*) echo s390;;
sparc*) echo sparc64;;
+ x32*) echo x86_64;;
*) echo "$1";;
esac
}
@@ -192,6 +193,10 @@ test_arch() {
echo "Unsupported configuration"
return
fi
+ if [ "$arch" = "x32" ] && [ "$test_mode" = "user" ]; then
+ echo "Unsupported configuration"
+ return
+ fi
mkdir -p "$build_dir"
swallow_output "${MAKE[@]}" defconfig
--
2.50.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] tools/nolibc: define time_t in terms of __kernel_old_time_t
2025-07-12 9:00 ` [PATCH 1/2] tools/nolibc: define time_t in terms of __kernel_old_time_t Thomas Weißschuh
@ 2025-07-13 13:42 ` Willy Tarreau
0 siblings, 0 replies; 4+ messages in thread
From: Willy Tarreau @ 2025-07-13 13:42 UTC (permalink / raw)
To: Thomas Weißschuh; +Cc: Shuah Khan, linux-kernel, linux-kselftest
On Sat, Jul 12, 2025 at 11:00:55AM +0200, Thomas Weißschuh wrote:
> 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>
Great! I didn't know we could support x32 and thought it was phased out.
But if it works it can be convenient for those seeking smaller binaries.
Both patches look good to me, for the whole series:
Acked-by: Willy Tarreau <w@1wt.eu>
Thanks!
Willy
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-07-13 13:42 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-12 9:00 [PATCH 0/2] tools/nolibc: add x32 support Thomas Weißschuh
2025-07-12 9:00 ` [PATCH 1/2] tools/nolibc: define time_t in terms of __kernel_old_time_t Thomas Weißschuh
2025-07-13 13:42 ` Willy Tarreau
2025-07-12 9:00 ` [PATCH 2/2] selftests/nolibc: add x32 test configuration Thomas Weißschuh
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).