From nobody Mon Feb 9 19:25:56 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 CE746C0015E for ; Sun, 25 Jun 2023 16:12:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230169AbjFYQMY (ORCPT ); Sun, 25 Jun 2023 12:12:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229526AbjFYQMW (ORCPT ); Sun, 25 Jun 2023 12:12:22 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2791D18D; Sun, 25 Jun 2023 09:12:20 -0700 (PDT) X-QQ-mid: bizesmtp85t1687709530tsvfo8pm Received: from linux-lab-host.localdomain ( [116.30.129.193]) by bizesmtp.qq.com (ESMTP) with id ; Mon, 26 Jun 2023 00:12:09 +0800 (CST) X-QQ-SSF: 01200000000000D0V000000A0000000 X-QQ-FEAT: XBN7tc9DADJ/OcMdENJaOzWBkZLGnIpxol5HU5eHhMJPihloFMK4nV8tycOqP HcFbWitRT8ddnSgIxB4OEtcz18ioeAnXfZ/MrBw4IpHZfmtCgWRpTgqxkPqh0g72G187XBG FBxsQ2+M1egZBKQKwY+g8lqoc/5WHoHP2t7aZUQuOLiB643WygQ27rWCZ6T/8cgN29l5DaG EcF9AjMPzwmnUmCEc0CulnMK1nfUeR+Bp7UMx8LCV5GJcYxQ/P5TzVexQWbEERiTWMbyDm5 P9yDZVUU3EoY3HD1BSRnFTFnBLHyPyunUd3s1RkxhHMPz/U5jCHY27tlTa9cA5pNbdN4z9U +iX6V2Hsgg+we5SNg2ilRyctvtMS61cx8HrbAIJ+kGfYUsx4cg= X-QQ-GoodBg: 0 X-BIZMAIL-ID: 15070065792118708961 From: Zhangjin Wu To: thomas@t-8ch.de, w@1wt.eu Cc: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v1 01/22] selftests/nolibc: add test for -include /path/to/nolibc.h Date: Mon, 26 Jun 2023 00:12:00 +0800 Message-Id: <149d51ee77cdd4936de4a02ee8b2cff239fd8253.1687706332.git.falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrsz:qybglogicsvrsz3a-3 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" As the head comment of nolibc-test.c shows, it can be built in 3 ways: The program may be built in 3 ways: $(CC) -nostdlib -include /path/to/nolibc.h =3D> NOLIBC already defined $(CC) -nostdlib -I/path/to/nolibc/sysroot =3D> _NOLIBC_* guards are pr= esent $(CC) with default libc =3D> NOLIBC* never defined Only last two of them are tested currently, let's allow test the first one = too. This may help to find issues about using nolibc.h to build programs. it derives from this change: commit 3a8039e289a3 ("tools/nolibc: Fix build of stdio.h due to header = ordering") Usage: // test with sysroot $ make run-user SYSROOT=3D1 // test without sysroot, using nolibc.h directly $ make run-user SYSROOT=3D0 Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/Makefile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selfte= sts/nolibc/Makefile index 848884204a84..0b66b7a79cea 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -102,6 +102,9 @@ REPORT ?=3D awk '/\[OK\][\r]*$$/{p++} /\[FAIL\][\r]*$$= /{f++;print} /\[SKIPPED\][\ END{ printf("%d test(s) passed, %d skipped, %d failed.\n", p, s, f); \ printf("See all results in %s\n", ARGV[1]); }' =20 +# allow switch nolibc headers include method: 1 for sysroot, 0 for nolibc.h +SYSROOT ?=3D 1 + help: @echo "Supported targets under selftests/nolibc:" @echo " all call the \"run\" target below" @@ -139,9 +142,15 @@ sysroot/$(ARCH)/include: $(Q)$(MAKE) -C ../../../include/nolibc ARCH=3D$(ARCH) OUTPUT=3D$(CURDIR)/= sysroot/ headers_standalone $(Q)mv sysroot/sysroot sysroot/$(ARCH) =20 +ifeq ($(SYSROOT), 1) nolibc-test: nolibc-test.c sysroot/$(ARCH)/include $(QUIET_CC)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ \ -nostdlib -static -Isysroot/$(ARCH)/include $< -lgcc +else +nolibc-test: nolibc-test.c + $(QUIET_CC)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ \ + -nostdlib -static -include ../../../include/nolibc/nolibc.h $< -lgcc +endif =20 libc-test: nolibc-test.c $(QUIET_CC)$(CC) -o $@ $< --=20 2.25.1