Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp255939rwb; Fri, 4 Aug 2023 12:09:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEYjGa1a8SQ09La9dXe1YYu+cEGxsqEbSwLg7L9eLG61jp3bUXE0fOlGB3uTWRgrELASsMd X-Received: by 2002:a17:90a:1b2d:b0:268:daa4:3a70 with SMTP id q42-20020a17090a1b2d00b00268daa43a70mr2401159pjq.32.1691176198727; Fri, 04 Aug 2023 12:09:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691176198; cv=none; d=google.com; s=arc-20160816; b=tVE8D9/gHEy9oNvSXW5FsBaljz0ikhlRAVE6gcRfK/H8Bpq2vkLSZn6mX6zrAc7G/5 eudI7Ww6k4CuzJJSeoZQMT6MtOQmIwHkcurQObbGBM8JcE9Po9ul85E06mMu5jYgTrif lG8qLbvNpSf7f/MKpJTtrhba7+PbDXvFfJD6fiwfeOsRJ/Fx+NBfT/CnNUuK+bfKfG/W nfs+Sw0E8CLqa61QZYbQ8uZju7+OARh8gceCvvxJQxvuMHCzFDyv1aEamXNwm1HsMUHU AgPbzIl3e/vTzpLNhMUGw/9wnyyvRyYJri35KX412OK5cMma17/MeFFnIRs8Rl4lm46D Zx7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=p8Ee9oHnTEzsgTj8TOTziZ98H5FMDkgcs4FmoyojzCs=; fh=p3LhtcKKerlxi1+R83aQNbQMqsPJwM66jgHsL8P8U1E=; b=fyPUp3R/pYE1aIvezhbaoGXLRsLdnJfsGCv1us2EqyUTf5C/S0wD42lkqYabAcmjey 2yP9WXyC8kTlTpwv4pAYBtFAB/Tc3BmqOtwvezJ0zisW4ZNGFJYmAGo5qNUMzPpCoZWR r+TO8WRcnEMbjiXa0glciym8SPAaU47IdBWLUvCn7i+0cfF6mHylMUfbFZjeABD+aeXq AHrQ8t5jnKq2Ju/5ubSWb+GtmSwbPQ/dXfo3av3wZJkXqOYJUlcyTAFmTHwnd+0GkiVl Nw+AOiFSYfr35EbwzK8nHnxYVDVE7W2R9sIq44fq/5ewPuwqWIvlxiTkBXS94RWsVzMe B5/g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id om10-20020a17090b3a8a00b002680abc3699si5839052pjb.115.2023.08.04.12.09.07; Fri, 04 Aug 2023 12:09:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229730AbjHDRyp (ORCPT + 99 others); Fri, 4 Aug 2023 13:54:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229606AbjHDRyo (ORCPT ); Fri, 4 Aug 2023 13:54:44 -0400 Received: from 1wt.eu (ded1.1wt.eu [163.172.96.212]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8E6A7198B; Fri, 4 Aug 2023 10:54:42 -0700 (PDT) Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 374HsTm7031321; Fri, 4 Aug 2023 19:54:29 +0200 Date: Fri, 4 Aug 2023 19:54:29 +0200 From: Willy Tarreau To: Thomas =?iso-8859-1?Q?Wei=DFschuh?= Cc: Zhangjin Wu , arnd@arndb.de, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, tanyuan@tinylab.org Subject: Re: [PATCH v1 2/3] selftests/nolibc: fix up O= option support Message-ID: <20230804175429.GC31163@1wt.eu> References: <500504f6-fed1-45a4-a518-4631a6f3e463@t-8ch.de> <20230804162910.305533-1-falcon@tinylab.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS,SPF_PASS 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 On Fri, Aug 04, 2023 at 07:51:50PM +0200, Thomas Wei?schuh wrote: > On 2023-08-05 00:29:10+0800, Zhangjin Wu wrote: > > > On 2023-08-04 23:52:18+0800, Zhangjin Wu wrote: > > > > > On 2023-08-04 15:43:42+0800, Zhangjin Wu wrote: > > > > > > Hi, Thomas > > > > > > > > > > > > > On 2023-08-03 22:45:52+0800, Zhangjin Wu wrote: > > > > > > > > To avoid pollute the source code tree and avoid mrproper for every > > > > > > > > architecture switch, the O= argument must be supported. > > > > > > > > > > > > > > > > Both IMAGE and .config are from the building directory, let's use > > > > > > > > objtree instead of srctree for them. > > > > > > > > > > > > > > > > If no O= option specified, means building kernel in source code tree, > > > > > > > > objtree should be srctree in such case. > > > > > > > > > > > > > > > > Suggested-by: Willy Tarreau > > > > > > > > Link: https://lore.kernel.org/lkml/ZK0AB1OXH1s2xYsh@1wt.eu/ > > > > > > > > Signed-off-by: Zhangjin Wu > > > > > > > > --- > > > > > > > > tools/testing/selftests/nolibc/Makefile | 7 +++++-- > > > > > > > > 1 file changed, 5 insertions(+), 2 deletions(-) > > > > > > > > > > > > > > > > diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile > > > > > > > > index 51fef5e6a152..af590aee063a 100644 > > > > > > > > --- a/tools/testing/selftests/nolibc/Makefile > > > > > > > > +++ b/tools/testing/selftests/nolibc/Makefile > > > > > > > > @@ -9,6 +9,9 @@ ifeq ($(srctree),) > > > > > > > > srctree := $(patsubst %/tools/testing/selftests/,%,$(dir $(CURDIR))) > > > > > > > > endif > > > > > > > > > > > > > > > > +# add objtree for O= argument, required by IMAGE and .config > > > > > > > > +objtree ?= $(srctree) > > > > > > > > > > > > > > Isn't this already set by the included tools/scripts/Makefile.include? > > > > > > > > > > > > > > > > > > > Good question, but it is empty if no O= specified, checked it several > > > > > > times before ;-) > > > > > > > > > > For me it is not empty when I am in tools/testing/selftests/nolibc/. > > > > > > > > > > > > > Interesting, here is the code I added to check the value: > > > > > > > > diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile > > > > index 22f1e1d73fa8..1ae19e896e24 100644 > > > > --- a/tools/testing/selftests/nolibc/Makefile > > > > +++ b/tools/testing/selftests/nolibc/Makefile > > > > @@ -12,6 +12,8 @@ include $(srctree)/scripts/subarch.include > > > > ARCH = $(SUBARCH) > > > > endif > > > > > > > > +$(error objtree=$(objtree), srctree=$(srctree)) > > > > + > > > > > > > > Whenever I do defconfig or run, > > > > > > > > $ make help > > > > Makefile:15: *** objtree=, srctree=/labs/linux-lab/src/linux-stable. Stop. > > > > > > > > It is only not empty when we pass O explicitly: > > > > > > > > $ mkdir out > > > > $ make help O=out > > > > Makefile:15: *** objtree=out, srctree=/labs/linux-lab/src/linux-stable. Stop. > > > > $ make help O=$PWD/out > > > > Makefile:15: *** objtree=/labs/linux-lab/src/linux-stable/tools/testing/selftests/nolibc/out, srctree=/labs/linux-lab/src/linux-stable. Stop. > > > > > > Welp, now it's the same for me. > > > I guess I messed it up before, maybe I forgot to remove your changes > > > while testing? > > > > > > Anyways instead of having to manually do stuff with $(objtree) we could > > > also use $(OUTPUT)$(IMAGE) to always get the correct image. > > > > > > > Do you mean here? > > > > # kernel image names by architecture > > IMAGE_i386 = arch/x86/boot/bzImage > > IMAGE_x86 = arch/x86/boot/bzImage > > IMAGE_arm64 = arch/arm64/boot/Image > > IMAGE_arm = arch/arm/boot/zImage > > IMAGE_mips = vmlinuz > > IMAGE_riscv = arch/riscv/boot/Image > > IMAGE = $(IMAGE_$(ARCH)) > > IMAGE_NAME = $(notdir $(IMAGE)) > > > > It does save another KERNEL_IMAGE macro in my future patch ;-) > > > > But without O=, OUTPUT is also empty like objtree and when empty, it is > > assigned as $(CURDIR), not $(srctree) as we expected for IMAGE and .config. To > > be cleaner, objtree should also be used: > > > > - IMAGE = $(IMAGE_$(ARCH)) > > + IMAGE = $(objtree)/$(IMAGE_$(ARCH)) > > > > Is this what you want? > > More like: > > - $(Q)qemu-system-$(QEMU_ARCH) -display none -no-reboot -kernel "$(srctree)/$(IMAGE)" -serial stdio $(QEMU_ARGS) > "$(CURDIR)/run.out" > + $(Q)qemu-system-$(QEMU_ARCH) -display none -no-reboot -kernel "$(OUTPUT)$(IMAGE)" -serial stdio $(QEMU_ARGS) > "$(CURDIR)/run.out" > > My assumption was that it's weird that we need to define such variables > ourselves. > > Using an empty $(OUTPUT) would have been fine if make is run from the > root of the kernel tree. But that is not the case. > > It still feels weird but I can't think of a nicer way, and it's not > a big issue. So let's keep that part the same. > > Or maybe Willy has a better idea. I've just glanced over the discussion, but I'm wondering, why not "$(objtree)/$(IMAGE)" instead ? Willy