From nobody Mon Jun 22 15:43:45 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D91EC433EF for ; Mon, 21 Mar 2022 17:33:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349212AbiCURfN (ORCPT ); Mon, 21 Mar 2022 13:35:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348662AbiCURe5 (ORCPT ); Mon, 21 Mar 2022 13:34:57 -0400 Received: from 1wt.eu (wtarreau.pck.nerim.net [62.212.114.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C17FD6623B for ; Mon, 21 Mar 2022 10:33:30 -0700 (PDT) Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 22LHXNTJ007570; Mon, 21 Mar 2022 18:33:23 +0100 From: Willy Tarreau To: "Paul E . McKenney" Cc: linux-kernel@vger.kernel.org, Ammar Faizi Subject: [PATCH 1/8] tools/nolibc/stdio: make printf(%s) accept NULL Date: Mon, 21 Mar 2022 18:33:07 +0100 Message-Id: <20220321173314.7519-2-w@1wt.eu> X-Mailer: git-send-email 2.17.5 In-Reply-To: <20220321173314.7519-1-w@1wt.eu> References: <20220321173314.7519-1-w@1wt.eu> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" It's often convenient to support this, especially in test programs where a NULL may correspond to an allocation error or a non-existing value. Let's make printf("%s") support being passed a NULL. In this case it prints "(null)" like glibc's printf(). Signed-off-by: Willy Tarreau --- tools/include/nolibc/stdio.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/include/nolibc/stdio.h b/tools/include/nolibc/stdio.h index cb4d3ab3a565..559ebe052a75 100644 --- a/tools/include/nolibc/stdio.h +++ b/tools/include/nolibc/stdio.h @@ -220,6 +220,8 @@ int vfprintf(FILE *stream, const char *fmt, va_list arg= s) } else if (c =3D=3D 's') { outstr =3D va_arg(args, char *); + if (!outstr) + outstr=3D"(null)"; } else if (c =3D=3D '%') { /* queue it verbatim */ --=20 2.35.1 From nobody Mon Jun 22 15:43:45 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 488A3C433F5 for ; Mon, 21 Mar 2022 17:33:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348802AbiCURfJ (ORCPT ); Mon, 21 Mar 2022 13:35:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348534AbiCURe5 (ORCPT ); Mon, 21 Mar 2022 13:34:57 -0400 Received: from 1wt.eu (wtarreau.pck.nerim.net [62.212.114.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C1F2566617 for ; Mon, 21 Mar 2022 10:33:30 -0700 (PDT) Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 22LHXNrS007571; Mon, 21 Mar 2022 18:33:23 +0100 From: Willy Tarreau To: "Paul E . McKenney" Cc: linux-kernel@vger.kernel.org, Ammar Faizi Subject: [PATCH 2/8] tools/nolibc/stdlib: add a simple getenv() implementation Date: Mon, 21 Mar 2022 18:33:08 +0100 Message-Id: <20220321173314.7519-3-w@1wt.eu> X-Mailer: git-send-email 2.17.5 In-Reply-To: <20220321173314.7519-1-w@1wt.eu> References: <20220321173314.7519-1-w@1wt.eu> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This implementation relies on an extern definition of the environ variable, that the caller must declare and initialize from envp. Signed-off-by: Willy Tarreau --- tools/include/nolibc/stdlib.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tools/include/nolibc/stdlib.h b/tools/include/nolibc/stdlib.h index 733105c574ee..aca8616335e3 100644 --- a/tools/include/nolibc/stdlib.h +++ b/tools/include/nolibc/stdlib.h @@ -60,6 +60,29 @@ int atoi(const char *s) return atol(s); } =20 +/* Tries to find the environment variable named in the environment = array + * pointed to by global variable "environ" which must be declared as a cha= r **, + * and must be terminated by a NULL (it is recommended to set this variabl= e to + * the "envp" argument of main()). If the requested environment variable e= xists + * its value is returned otherwise NULL is returned. + */ +static __attribute__((unused)) +char *getenv(const char *name) +{ + extern char **environ; + int idx, i; + + if (environ) { + for (idx =3D 0; environ[idx]; idx++) { + for (i =3D 0; name[i] && name[i] =3D=3D environ[idx][i];) + i++; + if (!name[i] && environ[idx][i] =3D=3D '=3D') + return &environ[idx][i+1]; + } + } + return NULL; +} + /* Converts the unsigned long integer to its hex representation into * buffer , which must be long enough to store the number and the * trailing zero (17 bytes for "ffffffffffffffff" or 9 for "ffffffff"). The --=20 2.35.1 From nobody Mon Jun 22 15:43:45 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 479C7C433F5 for ; Mon, 21 Mar 2022 17:33:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349390AbiCURfT (ORCPT ); Mon, 21 Mar 2022 13:35:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348687AbiCURe5 (ORCPT ); Mon, 21 Mar 2022 13:34:57 -0400 Received: from 1wt.eu (wtarreau.pck.nerim.net [62.212.114.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C207266AC5 for ; Mon, 21 Mar 2022 10:33:30 -0700 (PDT) Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 22LHXN0f007572; Mon, 21 Mar 2022 18:33:23 +0100 From: Willy Tarreau To: "Paul E . McKenney" Cc: linux-kernel@vger.kernel.org, Ammar Faizi Subject: [PATCH 3/8] tools/nolibc/stdio: add support for '%p' to vfprintf() Date: Mon, 21 Mar 2022 18:33:09 +0100 Message-Id: <20220321173314.7519-4-w@1wt.eu> X-Mailer: git-send-email 2.17.5 In-Reply-To: <20220321173314.7519-1-w@1wt.eu> References: <20220321173314.7519-1-w@1wt.eu> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" %p remains quite useful in test code, and the code path can easily be merged with the existing "%x" thus only adds ~50 bytes, thus let's add it. Signed-off-by: Willy Tarreau --- tools/include/nolibc/stdio.h | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/tools/include/nolibc/stdio.h b/tools/include/nolibc/stdio.h index 559ebe052a75..15dedf8d0902 100644 --- a/tools/include/nolibc/stdio.h +++ b/tools/include/nolibc/stdio.h @@ -163,7 +163,7 @@ char *fgets(char *s, int size, FILE *stream) =20 =20 /* minimal vfprintf(). It supports the following formats: - * - %[l*]{d,u,c,x} + * - %[l*]{d,u,c,x,p} * - %s * - unknown modifiers are ignored. */ @@ -184,8 +184,12 @@ int vfprintf(FILE *stream, const char *fmt, va_list ar= gs) if (escape) { /* we're in an escape sequence, ofs =3D=3D 1 */ escape =3D 0; - if (c =3D=3D 'c' || c =3D=3D 'd' || c =3D=3D 'u' || c =3D=3D 'x') { - if (lpref) { + if (c =3D=3D 'c' || c =3D=3D 'd' || c =3D=3D 'u' || c =3D=3D 'x' || c = =3D=3D 'p') { + char *out =3D tmpbuf; + + if (c =3D=3D 'p') + v =3D va_arg(args, unsigned long); + else if (lpref) { if (lpref > 1) v =3D va_arg(args, unsigned long long); else @@ -202,18 +206,22 @@ int vfprintf(FILE *stream, const char *fmt, va_list a= rgs) } =20 switch (c) { + case 'c': + out[0] =3D v; + out[1] =3D 0; + break; case 'd': - i64toa_r(v, tmpbuf); + i64toa_r(v, out); break; case 'u': - u64toa_r(v, tmpbuf); + u64toa_r(v, out); break; - case 'x': - u64toh_r(v, tmpbuf); - break; - default: /* 'c' */ - tmpbuf[0] =3D v; - tmpbuf[1] =3D 0; + case 'p': + *(out++) =3D '0'; + *(out++) =3D 'x'; + /* fall through */ + default: /* 'x' and 'p' above */ + u64toh_r(v, out); break; } outstr =3D tmpbuf; --=20 2.35.1 From nobody Mon Jun 22 15:43:45 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E89BEC433F5 for ; Mon, 21 Mar 2022 17:34:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349498AbiCURfY (ORCPT ); Mon, 21 Mar 2022 13:35:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348720AbiCURe6 (ORCPT ); Mon, 21 Mar 2022 13:34:58 -0400 Received: from 1wt.eu (wtarreau.pck.nerim.net [62.212.114.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6D7C36A072 for ; Mon, 21 Mar 2022 10:33:31 -0700 (PDT) Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 22LHXNUw007573; Mon, 21 Mar 2022 18:33:23 +0100 From: Willy Tarreau To: "Paul E . McKenney" Cc: linux-kernel@vger.kernel.org, Ammar Faizi Subject: [PATCH 4/8] tools/nolibc/string: add strcmp() and strncmp() Date: Mon, 21 Mar 2022 18:33:10 +0100 Message-Id: <20220321173314.7519-5-w@1wt.eu> X-Mailer: git-send-email 2.17.5 In-Reply-To: <20220321173314.7519-1-w@1wt.eu> References: <20220321173314.7519-1-w@1wt.eu> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We need these functions all the time, including when checking environment variables and parsing command-line arguments. These implementations were optimized to show optimal code size on a wide range of compilers (22 bytes return included for strcmp(), 33 for strncmp()). Signed-off-by: Willy Tarreau --- tools/include/nolibc/string.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tools/include/nolibc/string.h b/tools/include/nolibc/string.h index 4554b6fcb400..0d5e870c7c0b 100644 --- a/tools/include/nolibc/string.h +++ b/tools/include/nolibc/string.h @@ -102,6 +102,17 @@ char *strchr(const char *s, int c) return NULL; } =20 +static __attribute__((unused)) +int strcmp(const char *a, const char *b) +{ + unsigned int c; + int diff; + + while (!(diff =3D (unsigned char)*a++ - (c =3D (unsigned char)*b++)) && c) + ; + return diff; +} + static __attribute__((unused)) char *strcpy(char *dst, const char *src) { @@ -184,6 +195,18 @@ char *strncat(char *dst, const char *src, size_t size) return orig; } =20 +static __attribute__((unused)) +int strncmp(const char *a, const char *b, size_t size) +{ + unsigned int c; + int diff =3D 0; + + while (size-- && + !(diff =3D (unsigned char)*a++ - (c =3D (unsigned char)*b++)) && c) + ; + + return diff; +} =20 static __attribute__((unused)) char *strncpy(char *dst, const char *src, size_t size) --=20 2.35.1 From nobody Mon Jun 22 15:43:45 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7A1F0C433F5 for ; Mon, 21 Mar 2022 17:34:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349443AbiCURfa (ORCPT ); Mon, 21 Mar 2022 13:35:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348746AbiCURe6 (ORCPT ); Mon, 21 Mar 2022 13:34:58 -0400 Received: from 1wt.eu (wtarreau.pck.nerim.net [62.212.114.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6D5CD69CF3 for ; Mon, 21 Mar 2022 10:33:31 -0700 (PDT) Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 22LHXOaH007574; Mon, 21 Mar 2022 18:33:24 +0100 From: Willy Tarreau To: "Paul E . McKenney" Cc: linux-kernel@vger.kernel.org, Ammar Faizi Subject: [PATCH 5/8] tools/nolibc/sys: add syscall definition for getppid() Date: Mon, 21 Mar 2022 18:33:11 +0100 Message-Id: <20220321173314.7519-6-w@1wt.eu> X-Mailer: git-send-email 2.17.5 In-Reply-To: <20220321173314.7519-1-w@1wt.eu> References: <20220321173314.7519-1-w@1wt.eu> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This is essentially for completeness as it's not the most often used in regtests. Signed-off-by: Willy Tarreau --- tools/include/nolibc/sys.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index 28437863c63f..4d4308d5d111 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -464,6 +464,23 @@ pid_t getpid(void) } =20 =20 +/* + * pid_t getppid(void); + */ + +static __attribute__((unused)) +pid_t sys_getppid(void) +{ + return my_syscall0(__NR_getppid); +} + +static __attribute__((unused)) +pid_t getppid(void) +{ + return sys_getppid(); +} + + /* * pid_t gettid(void); */ --=20 2.35.1 From nobody Mon Jun 22 15:43:45 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0AD4C433EF for ; Mon, 21 Mar 2022 17:34:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349586AbiCURf1 (ORCPT ); Mon, 21 Mar 2022 13:35:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348813AbiCURe6 (ORCPT ); Mon, 21 Mar 2022 13:34:58 -0400 Received: from 1wt.eu (wtarreau.pck.nerim.net [62.212.114.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AD78A74847 for ; Mon, 21 Mar 2022 10:33:31 -0700 (PDT) Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 22LHXOj5007575; Mon, 21 Mar 2022 18:33:24 +0100 From: Willy Tarreau To: "Paul E . McKenney" Cc: linux-kernel@vger.kernel.org, Ammar Faizi Subject: [PATCH 6/8] tools/nolibc/types: add poll() and waitpid() flag definitions Date: Mon, 21 Mar 2022 18:33:12 +0100 Message-Id: <20220321173314.7519-7-w@1wt.eu> X-Mailer: git-send-email 2.17.5 In-Reply-To: <20220321173314.7519-1-w@1wt.eu> References: <20220321173314.7519-1-w@1wt.eu> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" - POLLIN etc were missing, so poll() could only be used with timeouts. - WNOHANG was not defined and is convenient to check if a child is still running Signed-off-by: Willy Tarreau --- tools/include/nolibc/types.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/include/nolibc/types.h b/tools/include/nolibc/types.h index e4026e740b56..357e60ad38a8 100644 --- a/tools/include/nolibc/types.h +++ b/tools/include/nolibc/types.h @@ -82,6 +82,9 @@ #define WEXITSTATUS(status) (((status) & 0xff00) >> 8) #define WIFEXITED(status) (((status) & 0x7f) =3D=3D 0) =20 +/* waitpid() flags */ +#define WNOHANG 1 + /* standard exit() codes */ #define EXIT_SUCCESS 0 #define EXIT_FAILURE 1 @@ -122,6 +125,13 @@ typedef struct { } while (0) =20 /* for poll() */ +#define POLLIN 0x0001 +#define POLLPRI 0x0002 +#define POLLOUT 0x0004 +#define POLLERR 0x0008 +#define POLLHUP 0x0010 +#define POLLNVAL 0x0020 + struct pollfd { int fd; short int events; --=20 2.35.1 From nobody Mon Jun 22 15:43:45 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 753CFC433F5 for ; Mon, 21 Mar 2022 17:33:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349040AbiCURfA (ORCPT ); Mon, 21 Mar 2022 13:35:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348477AbiCURe5 (ORCPT ); Mon, 21 Mar 2022 13:34:57 -0400 Received: from 1wt.eu (wtarreau.pck.nerim.net [62.212.114.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C1F9566628 for ; Mon, 21 Mar 2022 10:33:30 -0700 (PDT) Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 22LHXOSO007576; Mon, 21 Mar 2022 18:33:24 +0100 From: Willy Tarreau To: "Paul E . McKenney" Cc: linux-kernel@vger.kernel.org, Ammar Faizi Subject: [PATCH 7/8] tools/nolibc: add a makefile to install headers Date: Mon, 21 Mar 2022 18:33:13 +0100 Message-Id: <20220321173314.7519-8-w@1wt.eu> X-Mailer: git-send-email 2.17.5 In-Reply-To: <20220321173314.7519-1-w@1wt.eu> References: <20220321173314.7519-1-w@1wt.eu> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This provides a target "headers_standalone" which installs the nolibc's arch-specific headers with "arch.h" taken from the current arch (or a concatenation of both i386 and x86_64 for arch=3Dx86), then installs kernel headers. This creates a convenient sysroot which is directly usable by a bare-metal compiler to create any executable. Signed-off-by: Willy Tarreau --- tools/include/nolibc/Makefile | 43 +++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 tools/include/nolibc/Makefile diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile new file mode 100644 index 000000000000..7d4d61b08637 --- /dev/null +++ b/tools/include/nolibc/Makefile @@ -0,0 +1,43 @@ +# SPDX-License-Identifier: GPL-2.0 +# Makefile for nolibc installation and tests +include ../../scripts/Makefile.include + +# we're in ".../tools/include/nolibc" +ifeq ($(srctree),) +srctree :=3D $(patsubst %/tools/include/,%,$(dir $(CURDIR))) +endif + +nolibc_arch :=3D $(patsubst arm64,aarch64,$(ARCH)) +arch_file :=3D arch-$(nolibc_arch).h +all_files :=3D ctype.h errno.h nolibc.h signal.h std.h stdio.h stdlib.h st= ring.h \ + sys.h time.h types.h unistd.h + +# install all headers needed to support a bare-metal compiler +all: + +# Note: when ARCH is "x86" we concatenate both x86_64 and i386 +headers: + $(Q)mkdir -p $(OUTPUT)sysroot + $(Q)mkdir -p $(OUTPUT)sysroot/include + $(Q)cp $(all_files) $(OUTPUT)sysroot/include/ + $(Q)if [ "$(ARCH)" =3D "x86" ]; then \ + sed -e \ + 's,^#ifndef _NOLIBC_ARCH_X86_64_H,#if !defined(_NOLIBC_ARCH_X86_64_H) = \&\& defined(__x86_64__),' \ + arch-x86_64.h; \ + sed -e \ + 's,^#ifndef _NOLIBC_ARCH_I386_H,#if !defined(_NOLIBC_ARCH_I386_H) \&\&= !defined(__x86_64__),' \ + arch-i386.h; \ + elif [ -e "$(arch_file)" ]; then \ + cat $(arch_file); \ + else \ + echo "Fatal: architecture $(ARCH) not yet supported by nolibc." >&2; \ + exit 1; \ + fi > $(OUTPUT)sysroot/include/arch.h + +headers_standalone: headers + $(Q)$(MAKE) -C $(srctree) headers + $(Q)$(MAKE) -C $(srctree) headers_install INSTALL_HDR_PATH=3D$(OUTPUT)/sy= sroot + +clean: + $(call QUIET_CLEAN, nolibc) rm -rf "$(OUTPUT)sysroot" + --=20 2.35.1 From nobody Mon Jun 22 15:43:45 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63D60C433EF for ; Mon, 21 Mar 2022 17:33:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349315AbiCURfQ (ORCPT ); Mon, 21 Mar 2022 13:35:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346206AbiCURe5 (ORCPT ); Mon, 21 Mar 2022 13:34:57 -0400 Received: from 1wt.eu (wtarreau.pck.nerim.net [62.212.114.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C1C6766610 for ; Mon, 21 Mar 2022 10:33:30 -0700 (PDT) Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 22LHXOmQ007577; Mon, 21 Mar 2022 18:33:24 +0100 From: Willy Tarreau To: "Paul E . McKenney" Cc: linux-kernel@vger.kernel.org, Ammar Faizi Subject: [PATCH 8/8] tools/nolibc: add the nolibc subdir to the common Makefile Date: Mon, 21 Mar 2022 18:33:14 +0100 Message-Id: <20220321173314.7519-9-w@1wt.eu> X-Mailer: git-send-email 2.17.5 In-Reply-To: <20220321173314.7519-1-w@1wt.eu> References: <20220321173314.7519-1-w@1wt.eu> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The Makefile in tools/ is used to forward options to the makefiles in the various subdirs. Let's add nolibc there so that it becomes possible to make tools/nolibc_headers_standalone from the main tree to simply create a completely usable sysroot. Signed-off-by: Willy Tarreau --- tools/Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/Makefile b/tools/Makefile index db2f7b8ebed5..724134f0e56c 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -24,6 +24,7 @@ help: @echo ' intel-speed-select - Intel Speed Select tool' @echo ' kvm_stat - top-like utility for displaying kvm sta= tistics' @echo ' leds - LEDs tools' + @echo ' nolibc - nolibc headers testing and installation' @echo ' objtool - an ELF object analysis tool' @echo ' pci - PCI tools' @echo ' perf - Linux performance measurement and analy= sis tool' @@ -74,6 +75,9 @@ bpf/%: FORCE libapi: FORCE $(call descend,lib/api) =20 +nolibc_%: FORCE + $(call descend,include/nolibc,$(patsubst nolibc_%,%,$@)) + # The perf build does not follow the descend function setup, # invoking it via it's own make rule. PERF_O =3D $(if $(O),$(O)/tools/perf,) --=20 2.35.1