Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp505071rdb; Tue, 31 Oct 2023 13:37:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFmoPSn2DhabmyKTwCW4+ta0w+62X/tbdyhBN0rPkT3GEV35Mn46hVum0aF9vPhpMBQ0d25 X-Received: by 2002:a05:6870:1059:b0:1ea:69f6:fe13 with SMTP id 25-20020a056870105900b001ea69f6fe13mr12750745oaj.44.1698784635773; Tue, 31 Oct 2023 13:37:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698784635; cv=none; d=google.com; s=arc-20160816; b=bw1ddglaBqxZkJnKWoGtVmPLUkdueLbZ3nHSnEUdaeIgSTFeCuUxqJtYZmu0XNUVmY wkz/XDMuE/ZcxdF3PT9Yd16mtY46mkxqu6RalI5z2IuGgU411SHexsnKygc+MBhXGww+ sQB9Kte8qyzPQnPPEzooi/g0zdKjR8aNH7orVCC/77KkWHYzaKLKlaDWHOqptYQCT3mM /S2tyXko6sya1zuWYKDyy8Z122vt5bP0M1PXv+9w9CPJwuVBlfQHlwFO1+0E9lkVbdfn 15WLqygAaQ75hRzyEBhfgyaMUJ+Hn8ZAWiPIo39JN4kzc1jLvfbUaInmwuQmsJ2Lu6DE vkmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=wc+bk23mT1/OefwfY2iSiExUbRV94pkUKcKnnHNt0+k=; fh=MEusuZMnxhrNAu45ysRmC1MHGnmniUkTNzVzpsulgt4=; b=0FmmaH2a48M6OjdvHuZkloIp2Xg1hOkFELHz2PLEda2bec8kUYWU0HNKJb6GFEMJc/ OoZOBtmd6vdS41RpNGdcxCncEDyeglcpHsXNSWQ9EbSs22y+8hoO87WdbEKskIpu0bsz YvkJQMugYEJC5dk/FN+IFLhiMBZV5ST4pQDefCtdszkXWHuDNocbPcs0YnbWvux4VEKo Ac57dktT4YCkkbVNPmidxUdOBhv/N4Oxp9JpPKEmbFh3uzZbAvT6Y/NnAQhdbB+46FQL Dwseh6HG1avPMmuxwWjMjkRqlSuYm9mpS5o3E14ExPyv02D6rJ/gKjAyiA+BOpt+MMQv uFsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@weissschuh.net header.s=mail header.b=GHEQO9eb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id z190-20020a6333c7000000b00578e0ff59bbsi1546477pgz.865.2023.10.31.13.37.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 13:37:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@weissschuh.net header.s=mail header.b=GHEQO9eb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 1E68780FA9DC; Tue, 31 Oct 2023 13:37:12 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234013AbjJaUhK (ORCPT + 99 others); Tue, 31 Oct 2023 16:37:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230406AbjJaUhG (ORCPT ); Tue, 31 Oct 2023 16:37:06 -0400 Received: from todd.t-8ch.de (todd.t-8ch.de [IPv6:2a01:4f8:c010:41de::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62480F9; Tue, 31 Oct 2023 13:37:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1698784621; bh=LNx+nj4jlE223VhzZ9GFi7fWQ5Fyb/XHvEpIBKCFyVM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=GHEQO9ebq4PLKKuavypuPdsKYAWA8jQ3FdQE572za9KmzKD/5aHkznU/oKFr+nvAA wHIZQ55uC4ZX8MAZWYAoXOUGqp2p4dNd2h5pWZ59WxUauUdl21qw5+f1Lm0V0nK8o+ unVBlzuKOc3qS32OuEc0ZTDD7jTZN0/RzvBRgrmk= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Tue, 31 Oct 2023 21:37:00 +0100 Subject: [PATCH 3/3] selftests/nolibc: support out-of-tree builds MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20231031-nolibc-out-of-tree-v1-3-47c92f73590a@weissschuh.net> References: <20231031-nolibc-out-of-tree-v1-0-47c92f73590a@weissschuh.net> In-Reply-To: <20231031-nolibc-out-of-tree-v1-0-47c92f73590a@weissschuh.net> To: Willy Tarreau , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , Shuah Khan Cc: Zhangjin Wu , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1698784620; l=4087; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=LNx+nj4jlE223VhzZ9GFi7fWQ5Fyb/XHvEpIBKCFyVM=; b=TyJDLtPEizhFex+t38T4ccb988q2/Hc4CqgbIfibOz8zcilrEO/oxpLY4PuAYAfPLiZ9Q5QzK /633oAtcuJ/AQUmBFWa6JJqhBE+U6Fxh8nQtdlKHFMuYgBkK4ZOqrdX X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,TO_EQ_FM_DIRECT_MX,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 31 Oct 2023 13:37:12 -0700 (PDT) Out of tree builds are much more convenient when building for multiple architectures or configurations in parallel. Only absolute O= parameters are supported as Makefile.include will always resolve relative paths in relation to $(srctree) instead of the current directory. Add a call to "make outputmakefile" to verify that the sourcetree is clean. This is based on Zhangjins out-of-tree patch. It extends that work for get_init_cpio support and also drops relative O= specifications explicitly. Link: https://lore.kernel.org/lkml/06d96bd81fe812a9718098a383678ad3beba98b1.1691215074.git.falcon@tinylab.org/ Co-developed-by: Zhangjin Wu Signed-off-by: Zhangjin Wu Acked-by: Willy Tarreau Signed-off-by: Thomas Weißschuh --- tools/testing/selftests/nolibc/Makefile | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index b1129be98376..c5df1617cbc3 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -1,9 +1,16 @@ # SPDX-License-Identifier: GPL-2.0 # Makefile for nolibc tests include ../../../scripts/Makefile.include +include ../../../scripts/utilities.mak # We need this for the "cc-option" macro. include ../../../build/Build.include +ifneq ($(O),) +ifneq ($(call is-absolute,$(O)),y) +$(error Only absolute O= parameters are supported) +endif +endif + # we're in ".../tools/testing/selftests/nolibc" ifeq ($(srctree),) srctree := $(patsubst %/tools/testing/selftests/,%,$(dir $(CURDIR))) @@ -14,6 +21,8 @@ include $(srctree)/scripts/subarch.include ARCH = $(SUBARCH) endif +objtree ?= $(srctree) + # XARCH extends the kernel's ARCH with a few variants of the same # architecture that only differ by the configuration, the toolchain # and the Qemu program used. It is copied as-is into ARCH except for @@ -52,7 +61,7 @@ IMAGE_ppc64le = arch/powerpc/boot/zImage IMAGE_riscv = arch/riscv/boot/Image IMAGE_s390 = arch/s390/boot/bzImage IMAGE_loongarch = arch/loongarch/boot/vmlinuz.efi -IMAGE = $(IMAGE_$(XARCH)) +IMAGE = $(objtree)/$(IMAGE_$(XARCH)) IMAGE_NAME = $(notdir $(IMAGE)) # default kernel configurations that appear to be usable @@ -174,6 +183,7 @@ sysroot: sysroot/$(ARCH)/include sysroot/$(ARCH)/include: $(Q)rm -rf sysroot/$(ARCH) sysroot/sysroot $(QUIET_MKDIR)mkdir -p sysroot + $(Q)$(MAKE) -C $(srctree) outputmakefile $(Q)$(MAKE) -C $(srctree)/tools/include/nolibc ARCH=$(ARCH) OUTPUT=$(CURDIR)/sysroot/ headers_standalone $(Q)mv sysroot/sysroot sysroot/$(ARCH) @@ -206,7 +216,7 @@ run-user: nolibc-test $(Q)$(REPORT) $(CURDIR)/run.out initramfs.cpio: kernel nolibc-test - $(QUIET_GEN)echo 'file /init nolibc-test 755 0 0' | $(srctree)/usr/gen_init_cpio - > initramfs.cpio + $(QUIET_GEN)echo 'file /init nolibc-test 755 0 0' | $(objtree)/usr/gen_init_cpio - > initramfs.cpio initramfs: nolibc-test $(QUIET_MKDIR)mkdir -p initramfs @@ -224,12 +234,12 @@ kernel-standalone: initramfs # run the tests after building the kernel run: kernel initramfs.cpio - $(Q)qemu-system-$(QEMU_ARCH) -display none -no-reboot -kernel "$(srctree)/$(IMAGE)" -initrd initramfs.cpio -serial stdio $(QEMU_ARGS) > "$(CURDIR)/run.out" + $(Q)qemu-system-$(QEMU_ARCH) -display none -no-reboot -kernel "$(IMAGE)" -initrd initramfs.cpio -serial stdio $(QEMU_ARGS) > "$(CURDIR)/run.out" $(Q)$(REPORT) $(CURDIR)/run.out # re-run the tests from an existing kernel rerun: - $(Q)qemu-system-$(QEMU_ARCH) -display none -no-reboot -kernel "$(srctree)/$(IMAGE)" -initrd initramfs.cpio -serial stdio $(QEMU_ARGS) > "$(CURDIR)/run.out" + $(Q)qemu-system-$(QEMU_ARCH) -display none -no-reboot -kernel "$(IMAGE)" -initrd initramfs.cpio -serial stdio $(QEMU_ARGS) > "$(CURDIR)/run.out" $(Q)$(REPORT) $(CURDIR)/run.out # report with existing test log -- 2.42.0