From nobody Mon Sep 28 19:24:48 2026 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DC5A53BBA04; Wed, 19 Aug 2026 06:32:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787121123; cv=none; b=B9gnU5Y0+j2sW9C1zW0++vrSup64Kw27u8/KmM+qZp5toUIhq3zwub4hfKGuJFXIhH8GscZ1nuI+PjGnMv0Yu0rsHrDoOhWuK0nVHbXIYj483q/JHSH3WE0Q5OLyNzIi5T5wiLE4hvFzeMnMNivAwZnjraZ2k8zmh0x3hnSZMNU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787121123; c=relaxed/simple; bh=ALQgJA8GzlWNdWB83Ze5vhtNM5ea+XJx7aEj3bOV6oc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=td78JiqsgxEHsmNuWFyIiDOp5J1Uu/61yQ75W9HyOmjutYc/r9+HR28I7TTpHlOCkVZK/v2afG8reJVdL4y4mW/emcHNLsLa0gYpxl+vrCfzLQ1YezOOW3uPRZzUbFvSuJwD2Z2Lj205X0EQs5PrFPc2Gc8g7rNbukRMnVcaaOU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=VhqNCtJx; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="VhqNCtJx" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1787121118; bh=ALQgJA8GzlWNdWB83Ze5vhtNM5ea+XJx7aEj3bOV6oc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=VhqNCtJxosEXzyDkWeNhz6BZWCnT7JNbTDPsj3ZQzPOmGL8YpN7mwowGqVrWu3woh zcDVj4lddiIVFnWuocg0Ryy9oCSZwdXLkB44C/QBM+xju/D5nAyI7lJsFxusclBWUU 40I2HgbwERv14Vih/s67OcQl8KP4AbC77+g3+xeQ= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Wed, 19 Aug 2026 08:31:51 +0200 Subject: [PATCH 1/3] tools/nolibc: split the architecture list into multiple lines Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260819-nolibc-hexagon-v1-1-6bc3be591f09@weissschuh.net> References: <20260819-nolibc-hexagon-v1-0-6bc3be591f09@weissschuh.net> In-Reply-To: <20260819-nolibc-hexagon-v1-0-6bc3be591f09@weissschuh.net> To: Brian Cain , Willy Tarreau , Shuah Khan Cc: linux-hexagon@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1787121117; l=936; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=ALQgJA8GzlWNdWB83Ze5vhtNM5ea+XJx7aEj3bOV6oc=; b=mvICwTAr6jhekqOis35OBD+XVlEOwxnVNRGJc/qaeybGqqjjSTaxGnaa9YdxgsNHolC1E3fiA 0oXrx6HsIvOB+2vuGFq1PH85VXNO/vPMf7zY0+MX6xTMpDcR5YhQYsw X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The list is getting long, split it up for easier additions. Signed-off-by: Thomas Wei=C3=9Fschuh Reviewed-by: Brian Cain --- 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 ?=3D $(CURDIR)/ =20 -architectures :=3D alpha arm arm64 loongarch m68k mips openrisc parisc pow= erpc riscv s390 sh sparc x86 +architectures :=3D \ + alpha \ + arm \ + arm64 \ + loongarch \ + m68k \ + mips \ + openrisc \ + parisc \ + powerpc \ + riscv \ + s390 \ + sh \ + sparc \ + x86 \ + arch_files :=3D arch.h $(addsuffix .h, $(addprefix arch-, $(architectures)= )) all_files :=3D \ alloca.h \ --=20 2.55.0 From nobody Mon Sep 28 19:24:48 2026 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DC7E53D16E2; Wed, 19 Aug 2026 06:32:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787121122; cv=none; b=lKh6+eRWfr+jy7UcDp590Cur74Se7ncpNZCoCThU4rh41u4RdxaIzlTKYHarDTkW4GdIvcxhg1HyyQyZaJYDr38SFFZRCgfVgYBakZj7HvJVUvHmi58Ab0+7gyd3v4OTU+z2nAF/T60oiUGQofBzAv2U0YYGmWIkdhJ6oIKhST0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787121122; c=relaxed/simple; bh=1EKQ0vma0RFWhPJizZPAaqpdxg6Ql4yO7eDuDs08Ylg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=X/KHgmYYaPKNQV9KNqxix0Dn4p+dDs1qIqagRYQ7h62zbo1MWfhPj4WOFCKwxQin9Lck10rLS9GTrfE0TI3Qj/YgxHsMciec0/serbQje2jTvLKiWio/yQ3S0J9aGZgfOcSL/T1uwJ7g3skMZW2LgqE57t4s7fe+YH4nm8fC6wI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=EYX/hxNL; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="EYX/hxNL" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1787121118; bh=1EKQ0vma0RFWhPJizZPAaqpdxg6Ql4yO7eDuDs08Ylg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=EYX/hxNLFEcSQDIERAyFFLy3lH+5X5cUeq0KKVeQANM5IHu3aY/+fhOnn4Qytt48x MECisRKzscv63lr90cfaGsD9FE+7X22XrNkQukT4oWzYyRzT7d1Kwy7yOR+KtOR/1I PUGSjJ6LHALG5CUKU8jvsCv+bfOoiHYKpT13odZU= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Wed, 19 Aug 2026 08:31:52 +0200 Subject: [PATCH 2/3] selftests/nolibc: prepare for clang-only architectures Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260819-nolibc-hexagon-v1-2-6bc3be591f09@weissschuh.net> References: <20260819-nolibc-hexagon-v1-0-6bc3be591f09@weissschuh.net> In-Reply-To: <20260819-nolibc-hexagon-v1-0-6bc3be591f09@weissschuh.net> To: Brian Cain , Willy Tarreau , Shuah Khan Cc: linux-hexagon@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1787121117; l=1830; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=1EKQ0vma0RFWhPJizZPAaqpdxg6Ql4yO7eDuDs08Ylg=; b=nWvHzVxyVY4C/J0RaB6Z7vNnijwaFoSfmfDeewJLfgxXEAwZpvDIg9E6A3OaDtnGgaglGJFi8 aKVt8Ka8AcjAIMRtD4TlTaCzZNqZOxcDSjyOQPcbAHGttL5STqcYFJR X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= 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=C3=9Fschuh Reviewed-by: Brian Cain --- 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/se= lftests/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 } =20 +need_gcc() { + case "$1" in + *) echo "1";; + esac +} + download_crosstool() { arch=3D"$(crosstool_arch "$1")" abi=3D"$(crosstool_abi "$1")" @@ -164,14 +170,18 @@ test_arch() { arch=3D$1 ct_arch=3D$(crosstool_arch "$arch") ct_abi=3D$(crosstool_abi "$1") + gcc=3D"$(need_gcc "$1")" + cross_compile=3D =20 - 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 wit= h -h for help." return 1 fi =20 - cross_compile=3D$(realpath "${download_location}gcc-${crosstool_version}-= nolibc/${ct_arch}-${ct_abi}/bin/${ct_arch}-${ct_abi}-") + if [ -n "$gcc" ]; then + cross_compile=3D$(realpath "${download_location}gcc-${crosstool_version}= -nolibc/${ct_arch}-${ct_abi}/bin/${ct_arch}-${ct_abi}-") + fi build_dir=3D"${build_location}/${arch}" if [ "$werror" -ne 0 ]; then CFLAGS_EXTRA=3D"$CFLAGS_EXTRA -Werror -Wl,--fatal-warnings" --=20 2.55.0 From nobody Mon Sep 28 19:24:48 2026 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DC6443CF1FC; Wed, 19 Aug 2026 06:32:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787121123; cv=none; b=e/QpCUwy7z9iSviEQpEcPJOjsXQRhv8nTCFD70Ro/6quEkv0mDyAiGky6rTk4ursggkw2YN9LZqYxs0YULuudR/Bb8fB0xbDKbSNAnWiXxntNddPjmwLh598YLSDjErB5Nu60zlW/jCcEHVTqh+FHnJvgvh9ycy6VD8tQ93v2XI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787121123; c=relaxed/simple; bh=DVViftVIIdCuHyyNK4ea0Py1AfEXtBP0DSlioEFw/1k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SqodRIRRQwj7CpLLPTlHpY85spPxVh86IBDvAEgLYAycKxoBecA1/QFB/c9CAS46DeC89uCdi/CUjXYs2hvpbcGL4KScrpu5t5WxA07QUdwmw+AS26Xv4xMzgTcekN37AQIOZTscQT5FECD8Rf9XHIqc9eGOBzQkNLHk2V9Ffuc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=HHjSu6G3; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="HHjSu6G3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1787121118; bh=DVViftVIIdCuHyyNK4ea0Py1AfEXtBP0DSlioEFw/1k=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=HHjSu6G3vaqad+kU8jd0/y9t8h3HmfoOzsjk3JsKGvT7DCXpRr66dIvzAJdmaVI1R 6JGmsfyWV9xBU4seRstN+cOs6a4KQ0b5wwiDiYk55PuhBoamLCfsQQKVjB47DkKja1 7pypwgeNCFCPPk4Z3eJVOetQxiAsjQuy4Tj6zhRo= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Wed, 19 Aug 2026 08:31:53 +0200 Subject: [PATCH 3/3] tools/nolibc: add support for hexagon Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260819-nolibc-hexagon-v1-3-6bc3be591f09@weissschuh.net> References: <20260819-nolibc-hexagon-v1-0-6bc3be591f09@weissschuh.net> In-Reply-To: <20260819-nolibc-hexagon-v1-0-6bc3be591f09@weissschuh.net> To: Brian Cain , Willy Tarreau , Shuah Khan Cc: linux-hexagon@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1787121117; l=12136; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=DVViftVIIdCuHyyNK4ea0Py1AfEXtBP0DSlioEFw/1k=; b=rwGFoW39W3+QZP1ITSeRzyjfQvu/GtlICU8m2owm5tCLuzN582QHMdaLUdsTZXvTVQ56TsAdR GITDWY4iEoKAfQfubv27d8t2/AiTK1bduN1HKlSf02Ux8nS7McRnhRC X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= A mostly straightforward new architecture with a few quirks: * Only qemu-user is supported for testing. * Clang is required for compilation. * -fsanitize=3Dundefined is broken. Signed-off-by: Thomas Wei=C3=9Fschuh Acked-by: Willy Tarreau Reviewed-by: Brian Cain --- 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 :=3D \ alpha \ arm \ arm64 \ + hexagon \ loongarch \ m68k \ mips \ diff --git a/tools/include/nolibc/arch-hexagon.h b/tools/include/nolibc/arc= h-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=C3=9Fschuh + */ + +#ifndef _NOLIBC_ARCH_HEXAGON_H +#define _NOLIBC_ARCH_HEXAGON_H + +#include + +#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") =3D (num); \ + register long _arg1 __asm__ ("r0"); \ + \ + __asm__ volatile ( \ + "trap0(#1)\n" \ + : "=3Dr"(_arg1) \ + : "r"(_num) \ + : _NOLIBC_SYSCALL_CLOBBERLIST \ + ); \ + _arg1; \ +}) + +#define __nolibc_syscall1(num, arg1) = \ +({ = \ + register long _num __asm__ ("r6") =3D (num); \ + register long _arg1 __asm__ ("r0") =3D (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") =3D (num); \ + register long _arg1 __asm__ ("r0") =3D (long)(arg1); \ + register long _arg2 __asm__ ("r1") =3D (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") =3D (num); \ + register long _arg1 __asm__ ("r0") =3D (long)(arg1); \ + register long _arg2 __asm__ ("r1") =3D (long)(arg2); \ + register long _arg3 __asm__ ("r2") =3D (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") =3D (num); \ + register long _arg1 __asm__ ("r0") =3D (long)(arg1); \ + register long _arg2 __asm__ ("r1") =3D (long)(arg2); \ + register long _arg3 __asm__ ("r2") =3D (long)(arg3); \ + register long _arg4 __asm__ ("r3") =3D (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") =3D (num); \ + register long _arg1 __asm__ ("r0") =3D (long)(arg1); \ + register long _arg2 __asm__ ("r1") =3D (long)(arg2); \ + register long _arg3 __asm__ ("r2") =3D (long)(arg3); \ + register long _arg4 __asm__ ("r3") =3D (long)(arg4); \ + register long _arg5 __asm__ ("r4") =3D (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") =3D (num); \ + register long _arg1 __asm__ ("r0") =3D (long)(arg1); \ + register long _arg2 __asm__ ("r1") =3D (long)(arg2); \ + register long _arg3 __asm__ ("r2") =3D (long)(arg3); \ + register long _arg4 __asm__ ("r3") =3D (long)(arg4); \ + register long _arg5 __asm__ ("r4") =3D (long)(arg5); \ + register long _arg6 __asm__ ("r5") =3D (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 =3D sp\n" /* save stack pointer to r0, as arg1 of _s= tart_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 =3D -EB -mabi=3D64 -march=3Dmips64r2 CFLAGS_loongarch =3D $(if $(LLVM),-fuse-ld=3Dlld) CFLAGS_sparc32 =3D $(call cc-option,-m32) -mcpu=3Dv8 CFLAGS_sh4 =3D -ml -m4 +# github.com/llvm/llvm-project/issues/216765 +CFLAGS_hexagon =3D -fno-sanitize=3Dundefined ifeq ($(origin XARCH),command line) CFLAGS_XARCH =3D $(CFLAGS_$(XARCH)) endif @@ -222,6 +224,12 @@ LDFLAGS :=3D # Modify CFLAGS based on LLVM=3D include $(srctree)/tools/scripts/Makefile.include =20 +ifeq ($(ARCH),hexagon) +# tools/scripts/Makefile.include requires CROSS_COMPILE which does not exi= st for hexagon +CFLAGS +=3D --target=3Dhexagon-linux-musl +CLANG_CROSS_FLAGS +=3D --target=3Dhexagon-linux-musl +endif + REPORT ?=3D 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 =3D> sta= tus: ", p+s+f, p, s, f); \ diff --git a/tools/testing/selftests/nolibc/run-tests.sh b/tools/testing/se= lftests/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=3D( sh4 parisc32 alpha + hexagon ) archs=3D"${all_archs[@]}" =20 @@ -134,6 +135,7 @@ crosstool_abi() { =20 need_gcc() { case "$1" in + hexagon);; *) echo "1";; esac } @@ -212,6 +214,10 @@ test_arch() { echo "Unsupported configuration" return fi + if [ "$arch" =3D "hexagon" ] && [ -z "$llvm" -o "$test_mode" =3D "system"= ]; then + echo "Unsupported configuration" + return + fi =20 mkdir -p "$build_dir" swallow_output "${MAKE[@]}" defconfig --=20 2.55.0