Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp382081pxu; Wed, 25 Nov 2020 05:45:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJzhfoB+k+BPAf3J/z4rI648L9qly5v/Rn2tIGltN5Rut76WQjLZY+SREMw3Hs3HAl8OrkPa X-Received: by 2002:a50:fd8a:: with SMTP id o10mr3582481edt.308.1606311920476; Wed, 25 Nov 2020 05:45:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606311920; cv=none; d=google.com; s=arc-20160816; b=J5tr+41KfnFNJYw+M0nMQlDujbmgyFx1VpZfRQtBHRztMpESyMsUohuwc2wMRKNfp3 pmrvlk6jVHQwAzLkF32ZtX8r83+KxcQj4kf6rhzrlVTgrDNhv5kK2HvqY9an55JR99dU aPG/phMGeOQ5c61FjuNnH4RbwKZfpuc4VdBMZHWGjPNvheKA1mMnJVbQAIK69GMNfxYT NJ/6E2CPIQG/wipwPjrFobU2Sezfz7cd6nDyzoLPBCKZhdkESjKaF3tIxYOdb4tztTFv 6zskeRhlqq1XV+5ljX+ihgwqqjB6MVJ89Kl9JgKKR2M6aZOztZSSEz27Vx4s9/C1Oj1A zFLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature:dkim-filter; bh=Xr9kKa1yy2aEd8Z8mSK6Pod0JXKPYiwqr/gCQAQT6Lk=; b=C7+ZCMlpicEzwLl6F1hrePdZwqhf3VJXPq1FzvHi+aDCKWYIWOxo0mPWSaUFNKHIoR 31vqahBdt99YtTRrmIudS2NqNWHjRDPYBCxh1KrFpLcqmG2jZReiMt8CxYlc5rmyCysn gcJYer8XXlPacHutl0tbOT8bcedD+p1pjUnNX+chhvK5r+4dHQ2XGmVdPAbRE+2qdivw tgjmy7JHj1uuNFXBx+lY1u0NjJncvroDRXF0V8ZnHshZ8EQ5KRUnycBGJBx6/iAaZ4SX aIISSdyPiDyM3ql2VFo8zQdntkK5frxB8X5Kxse8K0m72iuAOstSFvMwTMkRacx2cyKB I2DQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=HcmLiYlq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u17si1246984edv.131.2020.11.25.05.44.56; Wed, 25 Nov 2020 05:45:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=HcmLiYlq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729563AbgKYNnU (ORCPT + 99 others); Wed, 25 Nov 2020 08:43:20 -0500 Received: from conssluserg-02.nifty.com ([210.131.2.81]:47041 "EHLO conssluserg-02.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729526AbgKYNnU (ORCPT ); Wed, 25 Nov 2020 08:43:20 -0500 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) (authenticated) by conssluserg-02.nifty.com with ESMTP id 0APDh6pQ004097; Wed, 25 Nov 2020 22:43:06 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-02.nifty.com 0APDh6pQ004097 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1606311786; bh=Xr9kKa1yy2aEd8Z8mSK6Pod0JXKPYiwqr/gCQAQT6Lk=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=HcmLiYlqEqyEO+xcSDxfv2S2tGX4N3ptJppIcINadM4hs6TWzL+2nFiXeCPCK0wXt E2WL0ffgr0n+uUypn1M3CWCHCMISFl1Q5PPxg0MjUlG3CuhjoncZA+xgeODYVg/5Wp c///hqN9AmHr5SvZbq4DT3HIWI2vSi1Jtle7zz+pUfl5kQVszJOSxsGlOThBg/48M5 1GoJgHcZT8aCJezsLe1JunAhZ5BUR2/2oWzIelNcnTQSnUmvIINEBpYNyly/TaTBZC qO8Ue6V70SkNOID/Nx3OrCdKaXE7km8AHVBADIZuQmMEgmbjZNJsjitT55JfOUNNPp uNJLd/QINT7TA== X-Nifty-SrcIP: [209.85.210.181] Received: by mail-pf1-f181.google.com with SMTP id w187so2366902pfd.5; Wed, 25 Nov 2020 05:43:06 -0800 (PST) X-Gm-Message-State: AOAM532pU9v07HAGvN9+/870L8gnZPfqXLLejGZsjedYsv4jLTZ+VWc4 QH7xDnS16NRuZa5UNdx2QYQKuwfITXKw5K8XldA= X-Received: by 2002:a62:e519:0:b029:197:bcec:7c0c with SMTP id n25-20020a62e5190000b0290197bcec7c0cmr3229396pff.63.1606311785520; Wed, 25 Nov 2020 05:43:05 -0800 (PST) MIME-Version: 1.0 References: <20201103054425.59251-1-chao.wang@ucloud.cn> <20201123150452.GA68187@MacBook-Pro-2> In-Reply-To: <20201123150452.GA68187@MacBook-Pro-2> From: Masahiro Yamada Date: Wed, 25 Nov 2020 22:42:28 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] kbuild: add extra-y to targets-for-modules To: WANG Chao Cc: Linux Kernel Mailing List , Linux Kbuild mailing list Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 24, 2020 at 12:05 AM WANG Chao wrote: > > On 11/23/20 at 02:23P, Masahiro Yamada wrote: > > On Tue, Nov 3, 2020 at 3:23 PM WANG Chao wrote: > > > > > > extra-y target doesn't build for 'make M=...' since commit 6212804f2d78 > > > ("kbuild: do not create built-in objects for external module builds"). > > > > > > This especially breaks kpatch, which is using 'extra-y := kpatch.lds' > > > and 'make M=...' to build livepatch patch module. > > > > > > Add extra-y to targets-for-modules so that such kind of build works > > > properly. > > > > > > Signed-off-by: WANG Chao > > > --- > > > scripts/Makefile.build | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/scripts/Makefile.build b/scripts/Makefile.build > > > index ae647379b579..0113a042d643 100644 > > > --- a/scripts/Makefile.build > > > +++ b/scripts/Makefile.build > > > @@ -86,7 +86,7 @@ ifdef need-builtin > > > targets-for-builtin += $(obj)/built-in.a > > > endif > > > > > > -targets-for-modules := $(patsubst %.o, %.mod, $(filter %.o, $(obj-m))) > > > +targets-for-modules := $(extra-y) $(patsubst %.o, %.mod, $(filter %.o, $(obj-m))) > > > > > > ifdef need-modorder > > > targets-for-modules += $(obj)/modules.order > > > -- > > > 2.29.1 > > > > > > > NACK. > > > > Please fix your Makefile. > > > > Hint: > > https://patchwork.kernel.org/project/linux-kbuild/patch/20201123045403.63402-6-masahiroy@kernel.org/ > > > > > > Probably what you should use is 'targets'. > > I tried with 'targets' and 'always-y'. Both doesn't work for me. > > I narraw it down to the following example: > > cat > Makefile << _EOF_ > obj-m += foo.o > > ldflags-y += -T $(src)/kpatch.lds > always-y += kpatch.lds > > foo-objs += bar.o > > all: > make -C /lib/modules/$(shell uname -r)/build M=$(PWD) > clean: > make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean > _EOF_ > > Take a look into scripts/Makefile.build:488: > > __build: $(if $(KBUILD_BUILTIN), $(targets-for-builtin)) \ > $(if $(KBUILD_MODULES), $(targets-for-modules)) \ > $(subdir-ym) $(always-y) > @: > > 'always-y' is built after 'targets-for-modules'. This makes > 'targets-for-modules' fails because kpatch.lds isn't there. Heh, you rely on the targets built from left to right, and you have never thought Make supports the parallel option -j. You need to specify the dependency if you expect objects are built in the particular order. However, in this case, using ldflags-y looks wrong in the first place. The linker script is used when combining the object as well as the final link of *.ko > For 'targets', in case of OOT, does not seem to be useful. > > What change do you suggest to make to fix this kind of Makefile? > > Thanks, > WANG Chao -- Best Regards Masahiro Yamada