Message ID | 20230613074931.666966-1-anders.roxell@linaro.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp371893vqr; Tue, 13 Jun 2023 00:57:13 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6FiIN5Oij79NfNP8LXMBwMrC5jMIMYjDyAaAE7jZ/rUwi2V9sXYHHb7aWEp3L5EvLIlAER X-Received: by 2002:a67:f906:0:b0:43b:5892:bad4 with SMTP id t6-20020a67f906000000b0043b5892bad4mr5468335vsq.15.1686643033126; Tue, 13 Jun 2023 00:57:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686643033; cv=none; d=google.com; s=arc-20160816; b=hn63eCMPzf1LoMhCd8k6mXtQw+T6TlP6JJfvZAiORJ5tYNO1FUKrPGiFsAunv7Hlut 677/0ZTOIogRifPjHKLnUhmdEKQx592DrtN/9ym72EHJm36kH0kT9fZrsNg+NkULDLw1 5YhDNhoY7T2o+iJmfuIHXxbODoq9VKHuVWdHV+mdImwa7LWYYQTr9qdfyBn6uRCPabsf QGCydftbSaRRNzZdALhL/GX1DRNjOvlRLNrLMUPePGNC9NDpeoEKECi3nNJ7gt9eHUCF Avx1eemc+udtkHByoG12IFMFYK54CQWw+Flfsnz+mrNRrNK5h7P3FwQhTpAv4rYxnb3G UaGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=moJN+g8UiI2hq78ltZSSLuP9Xu72wgPasq355As9aLA=; b=Nuk8yKb2BjlpVl10zYy2HzmjCC8tVsV+PIiijYQF4vnXJE+eGYJ1i+fUpqBYHZpftj KIOR04/9G7o71P6BFW3m2QM/3Z66chk7/DMC7d2XBkkFF0u8GxFlXJkPIPow7bdW89dd +EbnUnIpQeumgeM6XLG34YI3kW5o+iRqBPe3Bv0uFXDnxNN5gTcyk1s6zB8yJJndsYI3 +E2mUmO+16LoDf1Ze8oD9rw9MdYoFfzmbpw9wfd4fFC8p6Z+CSPQrqb7yXXlcsERldHY s/aCqohCayX5RWbrl6Xel+qJLs2HmRmN78Pb8ds9Bl0RYkn2u8RaTMILfO43kkfbpPks 7dwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jOjKffaH; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r6-20020a632b06000000b0052c8234a858si4680075pgr.168.2023.06.13.00.56.59; Tue, 13 Jun 2023 00:57:13 -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; dkim=pass header.i=@linaro.org header.s=google header.b=jOjKffaH; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239123AbjFMHto (ORCPT <rfc822;rust.linux@gmail.com> + 99 others); Tue, 13 Jun 2023 03:49:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239210AbjFMHtl (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 13 Jun 2023 03:49:41 -0400 Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3A6F10E2 for <linux-kernel@vger.kernel.org>; Tue, 13 Jun 2023 00:49:36 -0700 (PDT) Received: by mail-lj1-x236.google.com with SMTP id 38308e7fff4ca-2b1b084620dso64040771fa.0 for <linux-kernel@vger.kernel.org>; Tue, 13 Jun 2023 00:49:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686642575; x=1689234575; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=moJN+g8UiI2hq78ltZSSLuP9Xu72wgPasq355As9aLA=; b=jOjKffaHPlrXbRTvLrrGNPnl+MXhW2iVgyKxsqO/GF/igHOtyq4n0fpXrJdvfXsllM QUemy3UwuRMz1DALtR4jszRFg4IWG+fIacrlX93aHyC7+8oXwZjP5l1LPYFpLA3VtHMF wcFSpX6k24IKLvljp4MUGmlv0mwqS/DEju2uDPHvsoPqanW8K1r0gMwxVesGNgPlgSFj zAaSuyiNiezWxRCugqlTI2nRVCp8VU7IU87VWLAWoPN4/6Pm0tqvLElsN7uz5CUEFGXs 8H6G0guic+grViobw+IjXjatk64VX6mJzldZ1IQL8IDVK07P1e8MOLtsqTvViSXuS54f /ylA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686642575; x=1689234575; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=moJN+g8UiI2hq78ltZSSLuP9Xu72wgPasq355As9aLA=; b=SlHOVz6m3t5D9d+WowJSawDM1H9vRZql5+WE/c6DpAGNZuTFZ1k6Uz+UhxZgcylQbD +NTp/I2M4gWd5ko2wQkCeqHnSM1bYASgFPes1q6mZfatMoKMQRd5n13GqM/OhWLVYBOL j5kalguwkPNbCZxL1vbUQz0mpOW2WKMgQqQvqggKpCygyhGsLpl6G59wh7vK89z4DEUk tmBXDaGIZ7dJAzGbz2ZaaBkoQ1RU9bTNPJiSb6if6pcF3/Ucrti/KMrR/p8eYc5nYf87 WGJ93hrt9L8Do+hfkhHuOjhHXneurVafF6ha6lFwYYgbVx3ecYtWdDoFWaHl/uURaXJl aaxA== X-Gm-Message-State: AC+VfDzRKKNX7LGtjtYU0SPGa3UI/3twb5O0OKRUHhmUSdfCK+oLPxpU k36MjuhkMxuXNIBHNMAPnsoXkw== X-Received: by 2002:a2e:918a:0:b0:2ad:8929:e8f4 with SMTP id f10-20020a2e918a000000b002ad8929e8f4mr4071464ljg.43.1686642574978; Tue, 13 Jun 2023 00:49:34 -0700 (PDT) Received: from localhost (c-9b0ee555.07-21-73746f28.bbcust.telenor.se. [85.229.14.155]) by smtp.gmail.com with ESMTPSA id p7-20020a2e9a87000000b002adb10a6620sm1990220lji.107.2023.06.13.00.49.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jun 2023 00:49:34 -0700 (PDT) From: Anders Roxell <anders.roxell@linaro.org> To: shuah@kernel.org Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, usama.anjum@collabora.com, jhubbard@nvidia.com, Anders Roxell <anders.roxell@linaro.org> Subject: [PATCH] selftests: lib.mk: fix out-of-tree builds Date: Tue, 13 Jun 2023 09:49:31 +0200 Message-Id: <20230613074931.666966-1-anders.roxell@linaro.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768573404876480916?= X-GMAIL-MSGID: =?utf-8?q?1768573404876480916?= |
Series |
selftests: lib.mk: fix out-of-tree builds
|
|
Commit Message
Anders Roxell
June 13, 2023, 7:49 a.m. UTC
Since commit ("selftests: error out if kernel header files are not yet
built") got merged, the kselftest build correctly because the
KBUILD_OUTPUT isn't set when building out-of-tree and specifying 'O='
This is the error message that pops up.
make --silent --keep-going --jobs=32 O=/home/anders/.cache/tuxmake/builds/1482/build INSTALL_PATH=/home/anders/.cache/tuxmake/builds/1482/build/kselftest_install ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- V=1 CROSS_COMPILE_COMPAT=arm-linux-gnueabihf- kselftest-install
make[3]: Entering directory '/home/anders/src/kernel/next/tools/testing/selftests/alsa'
-e [1;31merror[0m: missing kernel header files.
Please run this and try again:
cd /home/anders/src/kernel/next/tools/testing/selftests/../../..
make headers
make[3]: Leaving directory '/home/anders/src/kernel/next/tools/testing/selftests/alsa'
make[3]: *** [../lib.mk:77: kernel_header_files] Error 1
Fixing the issue by assigning KBUILD_OUTPUT the same way how its done in
kselftest's Makefile. By adding 'KBUILD_OUTPUT := $(O)' 'if $(origin O)'
is set to 'command line'. This will set the the BUILD dir to
KBUILD_OUTPUT/kselftest when doing out-of-tree builds which makes them
in its own separete output directory.
Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
---
tools/testing/selftests/lib.mk | 4 ++++
1 file changed, 4 insertions(+)
Comments
This patch needs to go through mm tree as the commit which it fixes is in mm. On 6/13/23 12:49 PM, Anders Roxell wrote: > Since commit ("selftests: error out if kernel header files are not yet > built") got merged, the kselftest build correctly because the > KBUILD_OUTPUT isn't set when building out-of-tree and specifying 'O=' > This is the error message that pops up. > > make --silent --keep-going --jobs=32 O=/home/anders/.cache/tuxmake/builds/1482/build INSTALL_PATH=/home/anders/.cache/tuxmake/builds/1482/build/kselftest_install ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- V=1 CROSS_COMPILE_COMPAT=arm-linux-gnueabihf- kselftest-install > make[3]: Entering directory '/home/anders/src/kernel/next/tools/testing/selftests/alsa' > > -e [1;31merror[0m: missing kernel header files. > Please run this and try again: > > cd /home/anders/src/kernel/next/tools/testing/selftests/../../.. > make headers > > make[3]: Leaving directory '/home/anders/src/kernel/next/tools/testing/selftests/alsa' > make[3]: *** [../lib.mk:77: kernel_header_files] Error 1 > > Fixing the issue by assigning KBUILD_OUTPUT the same way how its done in > kselftest's Makefile. By adding 'KBUILD_OUTPUT := $(O)' 'if $(origin O)' > is set to 'command line'. This will set the the BUILD dir to > KBUILD_OUTPUT/kselftest when doing out-of-tree builds which makes them > in its own separete output directory. > > Signed-off-by: Anders Roxell <anders.roxell@linaro.org> Please add fixes tag. ("selftests: error out if kernel header files are not yet built") Tested-by: Muhammad Usama Anjum <usama.anjum@collabora.com> > --- > tools/testing/selftests/lib.mk | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk > index b8ea03b9a015..d17854285f2b 100644 > --- a/tools/testing/selftests/lib.mk > +++ b/tools/testing/selftests/lib.mk > @@ -44,6 +44,10 @@ endif > selfdir = $(realpath $(dir $(filter %/lib.mk,$(MAKEFILE_LIST)))) > top_srcdir = $(selfdir)/../../.. > > +ifeq ("$(origin O)", "command line") > + KBUILD_OUTPUT := $(O) > +endif > + > ifneq ($(KBUILD_OUTPUT),) > # Make's built-in functions such as $(abspath ...), $(realpath ...) cannot > # expand a shell special character '~'. We use a somewhat tedious way here.
On 13.06.23 10:16, Muhammad Usama Anjum wrote: > This patch needs to go through mm tree as the commit which it fixes is in mm. > > On 6/13/23 12:49 PM, Anders Roxell wrote: >> Since commit ("selftests: error out if kernel header files are not yet >> built") got merged, the kselftest build correctly because the >> KBUILD_OUTPUT isn't set when building out-of-tree and specifying 'O=' >> This is the error message that pops up. >> >> make --silent --keep-going --jobs=32 O=/home/anders/.cache/tuxmake/builds/1482/build INSTALL_PATH=/home/anders/.cache/tuxmake/builds/1482/build/kselftest_install ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- V=1 CROSS_COMPILE_COMPAT=arm-linux-gnueabihf- kselftest-install >> make[3]: Entering directory '/home/anders/src/kernel/next/tools/testing/selftests/alsa' >> >> -e [1;31merror[0m: missing kernel header files. >> Please run this and try again: >> >> cd /home/anders/src/kernel/next/tools/testing/selftests/../../.. >> make headers >> >> make[3]: Leaving directory '/home/anders/src/kernel/next/tools/testing/selftests/alsa' >> make[3]: *** [../lib.mk:77: kernel_header_files] Error 1 >> >> Fixing the issue by assigning KBUILD_OUTPUT the same way how its done in >> kselftest's Makefile. By adding 'KBUILD_OUTPUT := $(O)' 'if $(origin O)' >> is set to 'command line'. This will set the the BUILD dir to >> KBUILD_OUTPUT/kselftest when doing out-of-tree builds which makes them >> in its own separete output directory. >> >> Signed-off-by: Anders Roxell <anders.roxell@linaro.org> > Please add fixes tag. ("selftests: error out if kernel header files are not > yet built") > > Tested-by: Muhammad Usama Anjum <usama.anjum@collabora.com> This should get squashed into the original patch unless it's already in mm-stable (which it isn't) and we have a stable commit id.
On 6/13/23 00:49, Anders Roxell wrote: > Since commit ("selftests: error out if kernel header files are not yet > built") got merged, the kselftest build correctly because the > KBUILD_OUTPUT isn't set when building out-of-tree and specifying 'O=' > This is the error message that pops up. > > make --silent --keep-going --jobs=32 O=/home/anders/.cache/tuxmake/builds/1482/build INSTALL_PATH=/home/anders/.cache/tuxmake/builds/1482/build/kselftest_install ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- V=1 CROSS_COMPILE_COMPAT=arm-linux-gnueabihf- kselftest-install > make[3]: Entering directory '/home/anders/src/kernel/next/tools/testing/selftests/alsa' > > -e [1;31merror[0m: missing kernel header files. > Please run this and try again: > > cd /home/anders/src/kernel/next/tools/testing/selftests/../../.. > make headers > > make[3]: Leaving directory '/home/anders/src/kernel/next/tools/testing/selftests/alsa' > make[3]: *** [../lib.mk:77: kernel_header_files] Error 1 > > Fixing the issue by assigning KBUILD_OUTPUT the same way how its done in > kselftest's Makefile. By adding 'KBUILD_OUTPUT := $(O)' 'if $(origin O)' > is set to 'command line'. This will set the the BUILD dir to > KBUILD_OUTPUT/kselftest when doing out-of-tree builds which makes them > in its own separete output directory. > > Signed-off-by: Anders Roxell <anders.roxell@linaro.org> > --- > tools/testing/selftests/lib.mk | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk > index b8ea03b9a015..d17854285f2b 100644 > --- a/tools/testing/selftests/lib.mk > +++ b/tools/testing/selftests/lib.mk > @@ -44,6 +44,10 @@ endif > selfdir = $(realpath $(dir $(filter %/lib.mk,$(MAKEFILE_LIST)))) > top_srcdir = $(selfdir)/../../.. > > +ifeq ("$(origin O)", "command line") > + KBUILD_OUTPUT := $(O) > +endif > + Thanks for fixing this up! This looks correct. (It's too bad that we have all this duplication between the Makefile and lib.mk.) thanks,
On Wed, 14 Jun 2023 at 04:23, John Hubbard <jhubbard@nvidia.com> wrote: > > On 6/13/23 00:49, Anders Roxell wrote: > > Since commit ("selftests: error out if kernel header files are not yet > > built") got merged, the kselftest build correctly because the > > KBUILD_OUTPUT isn't set when building out-of-tree and specifying 'O=' > > This is the error message that pops up. > > > > make --silent --keep-going --jobs=32 O=/home/anders/.cache/tuxmake/builds/1482/build INSTALL_PATH=/home/anders/.cache/tuxmake/builds/1482/build/kselftest_install ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- V=1 CROSS_COMPILE_COMPAT=arm-linux-gnueabihf- kselftest-install > > make[3]: Entering directory '/home/anders/src/kernel/next/tools/testing/selftests/alsa' > > > > -e [1;31merror [0m: missing kernel header files. > > Please run this and try again: > > > > cd /home/anders/src/kernel/next/tools/testing/selftests/../../.. > > make headers > > > > make[3]: Leaving directory '/home/anders/src/kernel/next/tools/testing/selftests/alsa' > > make[3]: *** [../lib.mk:77: kernel_header_files] Error 1 > > > > Fixing the issue by assigning KBUILD_OUTPUT the same way how its done in > > kselftest's Makefile. By adding 'KBUILD_OUTPUT := $(O)' 'if $(origin O)' > > is set to 'command line'. This will set the the BUILD dir to > > KBUILD_OUTPUT/kselftest when doing out-of-tree builds which makes them > > in its own separete output directory. > > > > Signed-off-by: Anders Roxell <anders.roxell@linaro.org> > > --- > > tools/testing/selftests/lib.mk | 4 ++++ > > 1 file changed, 4 insertions(+) > > > > diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk > > index b8ea03b9a015..d17854285f2b 100644 > > --- a/tools/testing/selftests/lib.mk > > +++ b/tools/testing/selftests/lib.mk > > @@ -44,6 +44,10 @@ endif > > selfdir = $(realpath $(dir $(filter %/lib.mk,$(MAKEFILE_LIST)))) > > top_srcdir = $(selfdir)/../../.. > > > > +ifeq ("$(origin O)", "command line") > > + KBUILD_OUTPUT := $(O) > > +endif > > + > > Thanks for fixing this up! This looks correct. > > (It's too bad that we have all this duplication between the Makefile > and lib.mk.) I agree, also the duplication of get_sys_includes in bpf, hid and net Makefile's Do you have any idea how we can remove the duplication? Cheers, Anders > > thanks, > -- > John Hubbard > NVIDIA > > > ifneq ($(KBUILD_OUTPUT),) > > # Make's built-in functions such as $(abspath ...), $(realpath ...) cannot > > # expand a shell special character '~'. We use a somewhat tedious way here. > >
On 6/14/23 14:16, Anders Roxell wrote: >> (It's too bad that we have all this duplication between the Makefile >> and lib.mk.) > > I agree, also the duplication of get_sys_includes in bpf, hid and net Makefile's > Do you have any idea how we can remove the duplication? > Well, since you asked... :) Yes. Given that the goal is to support two similar, related activities: a) make -C tools/testing/selftests b) make -C tools/testing/selftests/<subtest> , we could move common functionality into common_vars.mk and common_targets.mk, and include those from both the top level tools/testing/selftests/Makefile, and the subtest Makefiles. This allows deduplication in a fairly safe sort of way, because it also simultaneously moves everything to a non-recursive Make design. That's especially nice, because then dependencies work reliably, and you also don't have to worry about propagating Make variables (via Make's export directive). I haven't done this, because a few years ago I somehow got the vague impression that it would not be well-received. But maybe that's pessimistic and/or obsolete--times change, after all! *************************************************************** Contents of tools/testing/selftests/Makefile: include common_vars.mk include alsa/alsa.mk include amd-pstate/amd-pstate.mk include arm64/arm64.mk ...etc, there are 100+ subdirs include common_targets.mk (This is instead of doing "TARGETS += xxx" in the Makefile. Including the subtest *.mk fragments allows each subtest to add features and quirks as necessary, while also enabling full dependency checking via a true non-recursive Make.) *************************************************************** Contents of tools/testing/selftests/common_targets.mk: all: kernel_headers ... Other rules/targets here. *************************************************************** Contents of tools/testing/selftests/common_vars.mk: Common variables, some of which may be overridden by a Makefile. *************************************************************** Using alsa as an example of a subtest: *************************************************************** Contents of tools/testing/selftests/alsa/alsa.mk: TARGETS += alsa TEST* items Plus: alsa-specific items, such as: CFLAGS += $(shell pkg-config --cflags alsa) *************************************************************** Contents of tools/testing/selftests/alsa/Makefile: include ../common_vars.mk include alsa.mk ...maybe very little else needs to go here. include ../common_targets.mk thanks,
diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk index b8ea03b9a015..d17854285f2b 100644 --- a/tools/testing/selftests/lib.mk +++ b/tools/testing/selftests/lib.mk @@ -44,6 +44,10 @@ endif selfdir = $(realpath $(dir $(filter %/lib.mk,$(MAKEFILE_LIST)))) top_srcdir = $(selfdir)/../../.. +ifeq ("$(origin O)", "command line") + KBUILD_OUTPUT := $(O) +endif + ifneq ($(KBUILD_OUTPUT),) # Make's built-in functions such as $(abspath ...), $(realpath ...) cannot # expand a shell special character '~'. We use a somewhat tedious way here.