* [PATCH 0/3] tools/nolibc: hexagon support
@ 2026-08-19 6:31 Thomas Weißschuh
2026-08-19 6:31 ` [PATCH 1/3] tools/nolibc: split the architecture list into multiple lines Thomas Weißschuh
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Thomas Weißschuh @ 2026-08-19 6:31 UTC (permalink / raw)
To: Brian Cain, Willy Tarreau, Shuah Khan
Cc: linux-hexagon, linux-kernel, linux-kselftest,
Thomas Weißschuh
Add support for the hexagon architecture.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
Thomas Weißschuh (3):
tools/nolibc: split the architecture list into multiple lines
selftests/nolibc: prepare for clang-only architectures
tools/nolibc: add support for hexagon
tools/include/nolibc/Makefile | 18 ++-
tools/include/nolibc/arch-hexagon.h | 164 +++++++++++++++++++++++++
tools/include/nolibc/arch.h | 2 +
tools/testing/selftests/nolibc/Makefile.nolibc | 8 ++
tools/testing/selftests/nolibc/run-tests.sh | 20 ++-
5 files changed, 209 insertions(+), 3 deletions(-)
---
base-commit: b58afc8d1cf85688601b8d7e271125fff666f661
change-id: 20260511-nolibc-hexagon-3f8891f4c7fe
Best regards,
--
Thomas Weißschuh <linux@weissschuh.net>
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH 1/3] tools/nolibc: split the architecture list into multiple lines 2026-08-19 6:31 [PATCH 0/3] tools/nolibc: hexagon support Thomas Weißschuh @ 2026-08-19 6:31 ` Thomas Weißschuh 2026-08-19 6:31 ` [PATCH 2/3] selftests/nolibc: prepare for clang-only architectures Thomas Weißschuh ` (2 subsequent siblings) 3 siblings, 0 replies; 6+ messages in thread From: Thomas Weißschuh @ 2026-08-19 6:31 UTC (permalink / raw) To: Brian Cain, Willy Tarreau, Shuah Khan Cc: linux-hexagon, linux-kernel, linux-kselftest, Thomas Weißschuh The list is getting long, split it up for easier additions. Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> --- tools/include/nolibc/Makefile | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile index 6d213d372bf8..b5897b3964f8 100644 --- a/tools/include/nolibc/Makefile +++ b/tools/include/nolibc/Makefile @@ -17,7 +17,22 @@ endif # it defaults to this nolibc directory. OUTPUT ?= $(CURDIR)/ -architectures := alpha arm arm64 loongarch m68k mips openrisc parisc powerpc riscv s390 sh sparc x86 +architectures := \ + alpha \ + arm \ + arm64 \ + loongarch \ + m68k \ + mips \ + openrisc \ + parisc \ + powerpc \ + riscv \ + s390 \ + sh \ + sparc \ + x86 \ + arch_files := arch.h $(addsuffix .h, $(addprefix arch-, $(architectures))) all_files := \ alloca.h \ -- 2.55.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/3] selftests/nolibc: prepare for clang-only architectures 2026-08-19 6:31 [PATCH 0/3] tools/nolibc: hexagon support Thomas Weißschuh 2026-08-19 6:31 ` [PATCH 1/3] tools/nolibc: split the architecture list into multiple lines Thomas Weißschuh @ 2026-08-19 6:31 ` Thomas Weißschuh 2026-08-19 6:31 ` [PATCH 3/3] tools/nolibc: add support for hexagon Thomas Weißschuh 2026-08-19 14:18 ` [PATCH 0/3] tools/nolibc: hexagon support Brian Cain 3 siblings, 0 replies; 6+ messages in thread From: Thomas Weißschuh @ 2026-08-19 6:31 UTC (permalink / raw) To: Brian Cain, Willy Tarreau, Shuah Khan Cc: linux-hexagon, linux-kernel, linux-kselftest, Thomas Weißschuh Contrary to other architectures currently supported by nolibc, hexagon can only be built with clang. Prepare run-tests.sh to allow for this. Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> --- tools/testing/selftests/nolibc/run-tests.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/nolibc/run-tests.sh b/tools/testing/selftests/nolibc/run-tests.sh index dc0b1649c641..5732b956ead9 100755 --- a/tools/testing/selftests/nolibc/run-tests.sh +++ b/tools/testing/selftests/nolibc/run-tests.sh @@ -132,6 +132,12 @@ crosstool_abi() { esac } +need_gcc() { + case "$1" in + *) echo "1";; + esac +} + download_crosstool() { arch="$(crosstool_arch "$1")" abi="$(crosstool_abi "$1")" @@ -164,14 +170,18 @@ test_arch() { arch=$1 ct_arch=$(crosstool_arch "$arch") ct_abi=$(crosstool_abi "$1") + gcc="$(need_gcc "$1")" + cross_compile= - if [ ! -d "${download_location}gcc-${crosstool_version}-nolibc/${ct_arch}-${ct_abi}/bin/." ]; then + if [ -n "$gcc" ] && [ ! -d "${download_location}gcc-${crosstool_version}-nolibc/${ct_arch}-${ct_abi}/bin/." ]; then echo "No toolchain found in ${download_location}gcc-${crosstool_version}-nolibc/${ct_arch}-${ct_abi}." echo "Did you install the toolchains or set the correct arch ? Rerun with -h for help." return 1 fi - cross_compile=$(realpath "${download_location}gcc-${crosstool_version}-nolibc/${ct_arch}-${ct_abi}/bin/${ct_arch}-${ct_abi}-") + if [ -n "$gcc" ]; then + cross_compile=$(realpath "${download_location}gcc-${crosstool_version}-nolibc/${ct_arch}-${ct_abi}/bin/${ct_arch}-${ct_abi}-") + fi build_dir="${build_location}/${arch}" if [ "$werror" -ne 0 ]; then CFLAGS_EXTRA="$CFLAGS_EXTRA -Werror -Wl,--fatal-warnings" -- 2.55.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/3] tools/nolibc: add support for hexagon 2026-08-19 6:31 [PATCH 0/3] tools/nolibc: hexagon support Thomas Weißschuh 2026-08-19 6:31 ` [PATCH 1/3] tools/nolibc: split the architecture list into multiple lines Thomas Weißschuh 2026-08-19 6:31 ` [PATCH 2/3] selftests/nolibc: prepare for clang-only architectures Thomas Weißschuh @ 2026-08-19 6:31 ` Thomas Weißschuh 2026-08-19 7:12 ` Willy Tarreau 2026-08-19 14:18 ` [PATCH 0/3] tools/nolibc: hexagon support Brian Cain 3 siblings, 1 reply; 6+ messages in thread From: Thomas Weißschuh @ 2026-08-19 6:31 UTC (permalink / raw) To: Brian Cain, Willy Tarreau, Shuah Khan Cc: linux-hexagon, linux-kernel, linux-kselftest, Thomas Weißschuh A mostly straightforward new architecture with a few quirks: * Only qemu-user is supported for testing. * Clang is required for compilation. * -fsanitize=undefined is broken. Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> --- tools/include/nolibc/Makefile | 1 + tools/include/nolibc/arch-hexagon.h | 164 +++++++++++++++++++++++++ tools/include/nolibc/arch.h | 2 + tools/testing/selftests/nolibc/Makefile.nolibc | 8 ++ tools/testing/selftests/nolibc/run-tests.sh | 6 + 5 files changed, 181 insertions(+) diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile index b5897b3964f8..c4a0879e4140 100644 --- a/tools/include/nolibc/Makefile +++ b/tools/include/nolibc/Makefile @@ -21,6 +21,7 @@ architectures := \ alpha \ arm \ arm64 \ + hexagon \ loongarch \ m68k \ mips \ diff --git a/tools/include/nolibc/arch-hexagon.h b/tools/include/nolibc/arch-hexagon.h new file mode 100644 index 000000000000..2dcc69a47e9f --- /dev/null +++ b/tools/include/nolibc/arch-hexagon.h @@ -0,0 +1,164 @@ +/* SPDX-License-Identifier: LGPL-2.1 OR MIT */ +/* + * hexagon specific definitions for NOLIBC + * Copyright (C) 2026 Thomas Weißschuh <linux@weissschuh.net> + */ + +#ifndef _NOLIBC_ARCH_HEXAGON_H +#define _NOLIBC_ARCH_HEXAGON_H + +#include <linux/unistd.h> + +#include "compiler.h" +#include "crt.h" + +/* + * Syscalls for OpenRISC: + * - syscall number is passed in r6 + * - arguments are in r0, r1, r2, r3, r4, r5 + * - the system call is performed by calling trap0(#1) + * - syscall return value is in r0 + */ + +#define _NOLIBC_SYSCALL_CLOBBERLIST "memory" + +#define __nolibc_syscall0(num) \ +({ \ + register long _num __asm__ ("r6") = (num); \ + register long _arg1 __asm__ ("r0"); \ + \ + __asm__ volatile ( \ + "trap0(#1)\n" \ + : "=r"(_arg1) \ + : "r"(_num) \ + : _NOLIBC_SYSCALL_CLOBBERLIST \ + ); \ + _arg1; \ +}) + +#define __nolibc_syscall1(num, arg1) \ +({ \ + register long _num __asm__ ("r6") = (num); \ + register long _arg1 __asm__ ("r0") = (long)(arg1); \ + \ + __asm__ volatile ( \ + "trap0(#1)\n" \ + : "+r"(_arg1) \ + : "r"(_num) \ + : _NOLIBC_SYSCALL_CLOBBERLIST \ + ); \ + _arg1; \ +}) + +#define __nolibc_syscall2(num, arg1, arg2) \ +({ \ + register long _num __asm__ ("r6") = (num); \ + register long _arg1 __asm__ ("r0") = (long)(arg1); \ + register long _arg2 __asm__ ("r1") = (long)(arg2); \ + \ + __asm__ volatile ( \ + "trap0(#1)\n" \ + : "+r"(_arg1) \ + : "r"(_arg2), \ + "r"(_num) \ + : _NOLIBC_SYSCALL_CLOBBERLIST \ + ); \ + _arg1; \ +}) + +#define __nolibc_syscall3(num, arg1, arg2, arg3) \ +({ \ + register long _num __asm__ ("r6") = (num); \ + register long _arg1 __asm__ ("r0") = (long)(arg1); \ + register long _arg2 __asm__ ("r1") = (long)(arg2); \ + register long _arg3 __asm__ ("r2") = (long)(arg3); \ + \ + __asm__ volatile ( \ + "trap0(#1)\n" \ + : "+r"(_arg1) \ + : "r"(_arg2), "r"(_arg3), \ + "r"(_num) \ + : _NOLIBC_SYSCALL_CLOBBERLIST \ + ); \ + _arg1; \ +}) + +#define __nolibc_syscall4(num, arg1, arg2, arg3, arg4) \ +({ \ + register long _num __asm__ ("r6") = (num); \ + register long _arg1 __asm__ ("r0") = (long)(arg1); \ + register long _arg2 __asm__ ("r1") = (long)(arg2); \ + register long _arg3 __asm__ ("r2") = (long)(arg3); \ + register long _arg4 __asm__ ("r3") = (long)(arg4); \ + \ + __asm__ volatile ( \ + "trap0(#1)\n" \ + : "+r"(_arg1) \ + : "r"(_arg2), "r"(_arg3), "r"(_arg4), \ + "r"(_num) \ + : _NOLIBC_SYSCALL_CLOBBERLIST \ + ); \ + _arg1; \ +}) + +#define __nolibc_syscall5(num, arg1, arg2, arg3, arg4, arg5) \ +({ \ + register long _num __asm__ ("r6") = (num); \ + register long _arg1 __asm__ ("r0") = (long)(arg1); \ + register long _arg2 __asm__ ("r1") = (long)(arg2); \ + register long _arg3 __asm__ ("r2") = (long)(arg3); \ + register long _arg4 __asm__ ("r3") = (long)(arg4); \ + register long _arg5 __asm__ ("r4") = (long)(arg5); \ + \ + __asm__ volatile ( \ + "trap0(#1)\n" \ + : "+r"(_arg1) \ + : "r"(_arg2), "r"(_arg3), "r"(_arg4), "r"(_arg5), \ + "r"(_num) \ + : _NOLIBC_SYSCALL_CLOBBERLIST \ + ); \ + _arg1; \ +}) + +#define __nolibc_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6) \ +({ \ + register long _num __asm__ ("r6") = (num); \ + register long _arg1 __asm__ ("r0") = (long)(arg1); \ + register long _arg2 __asm__ ("r1") = (long)(arg2); \ + register long _arg3 __asm__ ("r2") = (long)(arg3); \ + register long _arg4 __asm__ ("r3") = (long)(arg4); \ + register long _arg5 __asm__ ("r4") = (long)(arg5); \ + register long _arg6 __asm__ ("r5") = (long)(arg6); \ + \ + __asm__ volatile ( \ + "trap0(#1)\n" \ + : "+r"(_arg1) \ + : "r"(_arg2), "r"(_arg3), "r"(_arg4), "r"(_arg5), "r"(_arg6), \ + "r"(_num) \ + : _NOLIBC_SYSCALL_CLOBBERLIST \ + ); \ + _arg1; \ +}) + +#ifndef NOLIBC_NO_RUNTIME +/* startup code */ +void __attribute__((weak, noreturn)) +__nolibc_entrypoint __nolibc_no_stack_protector +_start(void) +{ + __asm__ volatile ( + "r0 = sp\n" /* save stack pointer to r0, as arg1 of _start_c */ + "call _start_c\n" /* transfer to c runtime */ + ); + __nolibc_entrypoint_epilogue(); +} +#endif /* NOLIBC_NO_RUNTIME */ + +static __attribute__((unused)) +int _sys_ftruncate64(int fd, uint32_t length0, uint32_t length1) +{ + return __nolibc_syscall4(__NR_ftruncate64, fd, 0, length0, length1); +} +#define _sys_ftruncate64 _sys_ftruncate64 + +#endif /* _NOLIBC_ARCH_HEXAGON_H */ diff --git a/tools/include/nolibc/arch.h b/tools/include/nolibc/arch.h index 06cc2dbe7a33..24e0ec4fb2db 100644 --- a/tools/include/nolibc/arch.h +++ b/tools/include/nolibc/arch.h @@ -34,6 +34,8 @@ #include "arch-parisc.h" #elif defined(__alpha__) #include "arch-alpha.h" +#elif defined(__hexagon__) +#include "arch-hexagon.h" #else #error Unsupported Architecture #endif diff --git a/tools/testing/selftests/nolibc/Makefile.nolibc b/tools/testing/selftests/nolibc/Makefile.nolibc index f70c8dfca018..439677cbc5cf 100644 --- a/tools/testing/selftests/nolibc/Makefile.nolibc +++ b/tools/testing/selftests/nolibc/Makefile.nolibc @@ -206,6 +206,8 @@ CFLAGS_mips64be = -EB -mabi=64 -march=mips64r2 CFLAGS_loongarch = $(if $(LLVM),-fuse-ld=lld) CFLAGS_sparc32 = $(call cc-option,-m32) -mcpu=v8 CFLAGS_sh4 = -ml -m4 +# github.com/llvm/llvm-project/issues/216765 +CFLAGS_hexagon = -fno-sanitize=undefined ifeq ($(origin XARCH),command line) CFLAGS_XARCH = $(CFLAGS_$(XARCH)) endif @@ -222,6 +224,12 @@ LDFLAGS := # Modify CFLAGS based on LLVM= include $(srctree)/tools/scripts/Makefile.include +ifeq ($(ARCH),hexagon) +# tools/scripts/Makefile.include requires CROSS_COMPILE which does not exist for hexagon +CFLAGS += --target=hexagon-linux-musl +CLANG_CROSS_FLAGS += --target=hexagon-linux-musl +endif + REPORT ?= awk '/\[OK\][\r]*$$/{p++} /\[FAIL\][\r]*$$/{if (!f) printf("\n"); f++; print;} /\[SKIPPED\][\r]*$$/{s++} \ /^Total number of errors:/{done++} \ END{ printf("\n%3d test(s): %3d passed, %3d skipped, %3d failed => status: ", p+s+f, p, s, f); \ diff --git a/tools/testing/selftests/nolibc/run-tests.sh b/tools/testing/selftests/nolibc/run-tests.sh index 5732b956ead9..3da806e2b302 100755 --- a/tools/testing/selftests/nolibc/run-tests.sh +++ b/tools/testing/selftests/nolibc/run-tests.sh @@ -31,6 +31,7 @@ all_archs=( sh4 parisc32 alpha + hexagon ) archs="${all_archs[@]}" @@ -134,6 +135,7 @@ crosstool_abi() { need_gcc() { case "$1" in + hexagon);; *) echo "1";; esac } @@ -212,6 +214,10 @@ test_arch() { echo "Unsupported configuration" return fi + if [ "$arch" = "hexagon" ] && [ -z "$llvm" -o "$test_mode" = "system" ]; then + echo "Unsupported configuration" + return + fi mkdir -p "$build_dir" swallow_output "${MAKE[@]}" defconfig -- 2.55.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 3/3] tools/nolibc: add support for hexagon 2026-08-19 6:31 ` [PATCH 3/3] tools/nolibc: add support for hexagon Thomas Weißschuh @ 2026-08-19 7:12 ` Willy Tarreau 0 siblings, 0 replies; 6+ messages in thread From: Willy Tarreau @ 2026-08-19 7:12 UTC (permalink / raw) To: Thomas Weißschuh Cc: Brian Cain, Shuah Khan, linux-hexagon, linux-kernel, linux-kselftest Hi Thomas, On Wed, Aug 19, 2026 at 08:31:53AM +0200, Thomas Weißschuh wrote: > +++ b/tools/include/nolibc/arch-hexagon.h > @@ -0,0 +1,164 @@ > +/* SPDX-License-Identifier: LGPL-2.1 OR MIT */ > +/* > + * hexagon specific definitions for NOLIBC > + * Copyright (C) 2026 Thomas Weißschuh <linux@weissschuh.net> > + */ > + > +#ifndef _NOLIBC_ARCH_HEXAGON_H > +#define _NOLIBC_ARCH_HEXAGON_H > + > +#include <linux/unistd.h> > + > +#include "compiler.h" > +#include "crt.h" > + > +/* > + * Syscalls for OpenRISC: > + * - syscall number is passed in r6 > + * - arguments are in r0, r1, r2, r3, r4, r5 > + * - the system call is performed by calling trap0(#1) > + * - syscall return value is in r0 > + */ I'm not familiar with hexagon, but the file is named hexagon and the comment speaks about openrisc. Is this a leftover from a copy-paste, or is there an untold relation between the two, that would then deserve at least an extra line to explain to those who don't know when passing by ? Other than this detail, while I can't judge for the syscall instructions for this arch, I'm fine with the rest of the patch and the series, so feel free to add: Acked-by: Willy Tarreau <w@1wt.eu> Thanks, Willy ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/3] tools/nolibc: hexagon support 2026-08-19 6:31 [PATCH 0/3] tools/nolibc: hexagon support Thomas Weißschuh ` (2 preceding siblings ...) 2026-08-19 6:31 ` [PATCH 3/3] tools/nolibc: add support for hexagon Thomas Weißschuh @ 2026-08-19 14:18 ` Brian Cain 3 siblings, 0 replies; 6+ messages in thread From: Brian Cain @ 2026-08-19 14:18 UTC (permalink / raw) To: Thomas Weißschuh, Brian Cain, Willy Tarreau, Shuah Khan Cc: linux-hexagon, linux-kernel, linux-kselftest On 8/19/2026 1:31 AM, Thomas Weißschuh wrote: > Add support for the hexagon architecture. > > Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> > --- Thanks, Thomas! I've got similar nolibc patches in my tree that I have been sitting on - but I like yours better. Aside from the copy/paste error Willy identified, LGTM: Reviewed-by: Brian Cain <brian.cain@oss.qualcomm.com> > Thomas Weißschuh (3): > tools/nolibc: split the architecture list into multiple lines > selftests/nolibc: prepare for clang-only architectures > tools/nolibc: add support for hexagon > > tools/include/nolibc/Makefile | 18 ++- > tools/include/nolibc/arch-hexagon.h | 164 +++++++++++++++++++++++++ > tools/include/nolibc/arch.h | 2 + > tools/testing/selftests/nolibc/Makefile.nolibc | 8 ++ > tools/testing/selftests/nolibc/run-tests.sh | 20 ++- > 5 files changed, 209 insertions(+), 3 deletions(-) > --- > base-commit: b58afc8d1cf85688601b8d7e271125fff666f661 > change-id: 20260511-nolibc-hexagon-3f8891f4c7fe > > Best regards, > -- > Thomas Weißschuh <linux@weissschuh.net> > ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-08-19 14:18 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-08-19 6:31 [PATCH 0/3] tools/nolibc: hexagon support Thomas Weißschuh 2026-08-19 6:31 ` [PATCH 1/3] tools/nolibc: split the architecture list into multiple lines Thomas Weißschuh 2026-08-19 6:31 ` [PATCH 2/3] selftests/nolibc: prepare for clang-only architectures Thomas Weißschuh 2026-08-19 6:31 ` [PATCH 3/3] tools/nolibc: add support for hexagon Thomas Weißschuh 2026-08-19 7:12 ` Willy Tarreau 2026-08-19 14:18 ` [PATCH 0/3] tools/nolibc: hexagon support Brian Cain
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox