Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3032434pxu; Tue, 8 Dec 2020 01:26:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJyHSI9ZW/pEqGlal2RCZO17Wfc3p7WEj1l4B0wgmYcmjheGkxZP4n6M/yWcTTHy+t4xwMpI X-Received: by 2002:a17:906:3c11:: with SMTP id h17mr21998699ejg.20.1607419573488; Tue, 08 Dec 2020 01:26:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607419573; cv=none; d=google.com; s=arc-20160816; b=Jhks6dvlRKate9+kxE/bU7bzc5FSpJFQqFGoebnmH9Dc9hBZ9sCof+gNbRVazV8Mah yjvq7xC5++9ENPrT0VZLiljd1trFhmbt5Yv/DCZpY59BIi4kAM7R9nOrm55TF/Gwg86P 669bJ3hPw6d+LjdGv4sq/hOdT7fmE02eR7M4eE84ooHr3CKJbi9b67d5zkdxhTiMg9HP wmbT+DrDFdKCX4iWngez/fKS0yJwdyhTilwgq98dEkG/oD+ef+86jZM7U1p3XC++4167 +sW6c4uPX7GszGru/rgXtGi+b19oFJrbQLIHOgy2oWBhMXKQj38wkB7tBSUYQZFzilem dOvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=SciF2eQXmsoC973q5vGyR0zTw+Mde8Kb2oEsdpk9Yvw=; b=W0xHqPnyoBjz+UcgJ/a1tU2sFbK2A/aaLjneo0Xq69IfiI5GBJ3KOTuCIzja3mub5+ x7/cbAPiDr1ZaOg9cNpZf6CpPL9l/ZqnaBjgxJXh7LqFoS+ETrUTD1L7pZY9OK1BDwnl tWyd20l7dxS6G6WT5mIFmEqPagGs6+W3E5PN4YlSqIBf5MD03TV9W+wj4r9GIUBdtmjS nCo040LCCtCiRupIKI16OliFsdn3lo/11lsvwNJ1Na4w3q2hG6zRKdjGJrRyBNCD7nF5 rA6iQzL7KXiq1K2f72CTI0CZDbP+1NTKi3eo5iNO6HgzmT0wrO5MIQZ6iD39eyEqT5kp Y7tQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ucloud.cn Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o16si8080841ejx.217.2020.12.08.01.25.50; Tue, 08 Dec 2020 01:26:13 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ucloud.cn Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728652AbgLHJVv (ORCPT + 99 others); Tue, 8 Dec 2020 04:21:51 -0500 Received: from m9785.mail.qiye.163.com ([220.181.97.85]:8979 "EHLO m9785.mail.qiye.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726114AbgLHJVu (ORCPT ); Tue, 8 Dec 2020 04:21:50 -0500 Received: from localhost (unknown [117.48.120.186]) by m9785.mail.qiye.163.com (Hmail) with ESMTPA id 779595C1D0C; Tue, 8 Dec 2020 17:20:38 +0800 (CST) Date: Tue, 8 Dec 2020 17:20:35 +0800 From: WANG Chao To: Masahiro Yamada Cc: Linux Kernel Mailing List , Linux Kbuild mailing list , artem.savkov@gmail.com, joe.lawrence@redhat.com Subject: Re: [PATCH] kbuild: add extra-y to targets-for-modules Message-ID: <20201208092035.GA96434@MacBook-Pro-2.local> References: <20201103054425.59251-1-chao.wang@ucloud.cn> <20201123150452.GA68187@MacBook-Pro-2> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgYFAkeWUFZS1VLWVdZKFlBSUI3V1ktWUFJV1kPCR oVCBIfWUFZSEgdHk8aTEMYH0lPVkpNS0xPSkJJSENNTk9VGRETFhoSFyQUDg9ZV1kWGg8SFR0UWU FZT0tIVUpKS09ISVVLWQY+ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6PSo6Tjo5Cj04Nio3C1YqGi0W NzkKChxVSlVKTUtMT0pCSUhDQ0hMVTMWGhIXVRgTGhRVDBoVHDsOGBcUDh9VGBVFWVdZEgtZQVlK SkxVT0NVSklLVUpDTVlXWQgBWUFPQkJDNwY+ X-HM-Tid: 0a7641a7188e2087kuqy779595c1d0c Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Sorry for the late reply. On 11/25/20 at 10:42P, Masahiro Yamada wrote: > 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're right. I missed that. > > > 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 I don't have a clean fix to kpatch right now. I'm looping kpatch forks in. They're also looking at this right now: https://github.com/dynup/kpatch/pull/1149 Thanks WANG Chao > > > > 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 >