From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE86FC43460 for ; Thu, 15 Apr 2021 07:40:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9C0076113B for ; Thu, 15 Apr 2021 07:40:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231515AbhDOHky (ORCPT ); Thu, 15 Apr 2021 03:40:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:57935 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231482AbhDOHkv (ORCPT ); Thu, 15 Apr 2021 03:40:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618472427; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FABcKglbZyz1XUUkdOXQm+i1lKqkxdPYz82VDd7EHCc=; b=E3G/7HUOPVaw66wibjCv1WbFy3oUvSIpPjdbGVrER+fIgFMdIxriPAasDdqOJb3Du7jE5/ 8icemMvkBVKtvzcUgWfSf5p0AYDR8EnlAcwKTSR9fkI0otf1KZhfu/GmUwNat6SdsaObDG QEEPJBI/t4Qt+enrR9V/8M5X7ycLMYk= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-197-ZlEDVuOQOaeF8atOdSQdQA-1; Thu, 15 Apr 2021 03:40:25 -0400 X-MC-Unique: ZlEDVuOQOaeF8atOdSQdQA-1 Received: by mail-ed1-f71.google.com with SMTP id w14-20020aa7da4e0000b02903834aeed684so2947949eds.13 for ; Thu, 15 Apr 2021 00:40:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=FABcKglbZyz1XUUkdOXQm+i1lKqkxdPYz82VDd7EHCc=; b=oPVOCQAY8cvGt9YVyrxAicWkdl6x+oUqF03lLKLdPg73iKeJs6sO//qChCur9FfTuE Ns2j7enE0uhco0va/i2lQroSSCoHPlrifHsjUrJ3LCbqeDY3SvG7DAIvwoCzTecpv6XB uodTRNbjkR5SbghsgVmP3nQEak+EjFmAEpQXzltgMK41Aaap3ygQGzCyx760JxnNQ5TK tD0jzriP4/ehvwje5U5vd2PgBFFzrF+dExbs2osHvv4RCnxFC9xKECW6M5pmmS74j4FT Eh4srsuzW8qTZ4FE+bw4+/hM2QavpMpO1PFVTb/DJb6TO63idm+1YKTBITe9WyVTSOci g8cw== X-Gm-Message-State: AOAM532reNedc8drsCskaDRf1BxBWtEH0pxW+mnYdFj77oZY4skDlcGJ VL279Fsb71IXRCsbXYTwx9Bb1rId7Ul9CYphFmA/FgxgEqAf5qtQuN2VePfilftcA52zHa62Xa5 hXhFhZrskUhe9 X-Received: by 2002:a17:906:80d6:: with SMTP id a22mr2018530ejx.277.1618472424067; Thu, 15 Apr 2021 00:40:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx0fuohm6puHv0F4pqjM8Oe2og4+AYVZWqbQ2+dlsXsdUigyAKX+u4GzMQpiq69iOvQF1X+Kw== X-Received: by 2002:a17:906:80d6:: with SMTP id a22mr2018508ejx.277.1618472423854; Thu, 15 Apr 2021 00:40:23 -0700 (PDT) Received: from [192.168.10.118] ([93.56.169.140]) by smtp.gmail.com with ESMTPSA id d18sm1701897edv.1.2021.04.15.00.40.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 15 Apr 2021 00:40:23 -0700 (PDT) Subject: Re: [PATCH 2/2] tools: do not include scripts/Kbuild.include To: Masahiro Yamada , linux-kbuild@vger.kernel.org Cc: Janosch Frank , Christian Borntraeger , Alexei Starovoitov , Andrii Nakryiko , Benjamin Herrenschmidt , Daniel Borkmann , Harish , John Fastabend , KP Singh , Martin KaFai Lau , Michael Ellerman , Nathan Chancellor , Nick Desaulniers , Paul Mackerras , Shuah Khan , Song Liu , Yonghong Song , bpf@vger.kernel.org, clang-built-linux@googlegroups.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, netdev@vger.kernel.org References: <20210415072700.147125-1-masahiroy@kernel.org> <20210415072700.147125-2-masahiroy@kernel.org> From: Paolo Bonzini Message-ID: <9d33ee98-9de3-2215-0c0b-cc856cec1b69@redhat.com> Date: Thu, 15 Apr 2021 09:40:20 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: <20210415072700.147125-2-masahiroy@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On 15/04/21 09:27, Masahiro Yamada wrote: > Since commit d9f4ff50d2aa ("kbuild: spilt cc-option and friends to > scripts/Makefile.compiler"), some kselftests fail to build. > > The tools/ directory opted out Kbuild, and went in a different > direction. They copy any kind of files to the tools/ directory > in order to do whatever they want to do in their world. > > tools/build/Build.include mimics scripts/Kbuild.include, but some > tool Makefiles included the Kbuild one to import a feature that is > missing in tools/build/Build.include: > > - Commit ec04aa3ae87b ("tools/thermal: tmon: use "-fstack-protector" > only if supported") included scripts/Kbuild.include from > tools/thermal/tmon/Makefile to import the cc-option macro. > > - Commit c2390f16fc5b ("selftests: kvm: fix for compilers that do > not support -no-pie") included scripts/Kbuild.include from > tools/testing/selftests/kvm/Makefile to import the try-run macro. > > - Commit 9cae4ace80ef ("selftests/bpf: do not ignore clang > failures") included scripts/Kbuild.include from > tools/testing/selftests/bpf/Makefile to import the .DELETE_ON_ERROR > target. > > - Commit 0695f8bca93e ("selftests/powerpc: Handle Makefile for > unrecognized option") included scripts/Kbuild.include from > tools/testing/selftests/powerpc/pmu/ebb/Makefile to import the > try-run macro. > > Copy what they want there, and stop including scripts/Kbuild.include > from the tool Makefiles. I think it would make sense to add try-run, cc-option and .DELETE_ON_ERROR to tools/build/Build.include? Paolo > Link: https://lore.kernel.org/lkml/86dadf33-70f7-a5ac-cb8c-64966d2f45a1@linux.ibm.com/ > Fixes: d9f4ff50d2aa ("kbuild: spilt cc-option and friends to scripts/Makefile.compiler") > Reported-by: Janosch Frank > Reported-by: Christian Borntraeger > Signed-off-by: Masahiro Yamada > --- > > tools/testing/selftests/bpf/Makefile | 3 ++- > tools/testing/selftests/kvm/Makefile | 12 +++++++++++- > .../selftests/powerpc/pmu/ebb/Makefile | 11 ++++++++++- > tools/thermal/tmon/Makefile | 19 +++++++++++++++++-- > 4 files changed, 40 insertions(+), 5 deletions(-) > > diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile > index 044bfdcf5b74..d872b9f41543 100644 > --- a/tools/testing/selftests/bpf/Makefile > +++ b/tools/testing/selftests/bpf/Makefile > @@ -1,5 +1,4 @@ > # SPDX-License-Identifier: GPL-2.0 > -include ../../../../scripts/Kbuild.include > include ../../../scripts/Makefile.arch > include ../../../scripts/Makefile.include > > @@ -476,3 +475,5 @@ EXTRA_CLEAN := $(TEST_CUSTOM_PROGS) $(SCRATCH_DIR) $(HOST_SCRATCH_DIR) \ > prog_tests/tests.h map_tests/tests.h verifier/tests.h \ > feature \ > $(addprefix $(OUTPUT)/,*.o *.skel.h no_alu32 bpf_gcc bpf_testmod.ko) > + > +.DELETE_ON_ERROR: > diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile > index a6d61f451f88..8b45bc417d83 100644 > --- a/tools/testing/selftests/kvm/Makefile > +++ b/tools/testing/selftests/kvm/Makefile > @@ -1,5 +1,15 @@ > # SPDX-License-Identifier: GPL-2.0-only > -include ../../../../scripts/Kbuild.include > + > +TMPOUT = .tmp_$$$$ > + > +try-run = $(shell set -e; \ > + TMP=$(TMPOUT)/tmp; \ > + mkdir -p $(TMPOUT); \ > + trap "rm -rf $(TMPOUT)" EXIT; \ > + if ($(1)) >/dev/null 2>&1; \ > + then echo "$(2)"; \ > + else echo "$(3)"; \ > + fi) > > all: > > diff --git a/tools/testing/selftests/powerpc/pmu/ebb/Makefile b/tools/testing/selftests/powerpc/pmu/ebb/Makefile > index af3df79d8163..d5d3e869df93 100644 > --- a/tools/testing/selftests/powerpc/pmu/ebb/Makefile > +++ b/tools/testing/selftests/powerpc/pmu/ebb/Makefile > @@ -1,5 +1,4 @@ > # SPDX-License-Identifier: GPL-2.0 > -include ../../../../../../scripts/Kbuild.include > > noarg: > $(MAKE) -C ../../ > @@ -8,6 +7,16 @@ noarg: > CFLAGS += -m64 > > TMPOUT = $(OUTPUT)/TMPDIR/ > + > +try-run = $(shell set -e; \ > + TMP=$(TMPOUT)/tmp; \ > + mkdir -p $(TMPOUT); \ > + trap "rm -rf $(TMPOUT)" EXIT; \ > + if ($(1)) >/dev/null 2>&1; \ > + then echo "$(2)"; \ > + else echo "$(3)"; \ > + fi) > + > # Toolchains may build PIE by default which breaks the assembly > no-pie-option := $(call try-run, echo 'int main() { return 0; }' | \ > $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -no-pie -x c - -o "$$TMP", -no-pie) > diff --git a/tools/thermal/tmon/Makefile b/tools/thermal/tmon/Makefile > index 59e417ec3e13..92a683e4866c 100644 > --- a/tools/thermal/tmon/Makefile > +++ b/tools/thermal/tmon/Makefile > @@ -1,6 +1,21 @@ > # SPDX-License-Identifier: GPL-2.0 > -# We need this for the "cc-option" macro. > -include ../../../scripts/Kbuild.include > + > +TMPOUT = .tmp_$$$$ > + > +try-run = $(shell set -e; \ > + TMP=$(TMPOUT)/tmp; \ > + mkdir -p $(TMPOUT); \ > + trap "rm -rf $(TMPOUT)" EXIT; \ > + if ($(1)) >/dev/null 2>&1; \ > + then echo "$(2)"; \ > + else echo "$(3)"; \ > + fi) > + > +__cc-option = $(call try-run,\ > + $(1) -Werror $(2) $(3) -c -x c /dev/null -o "$$TMP",$(3),$(4)) > + > +cc-option = $(call __cc-option, $(CC),\ > + $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS),$(1),$(2)) > > VERSION = 1.0 > >