Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3218325pxu; Tue, 8 Dec 2020 06:36:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJyv0nr69l3P4oWDiSpIvhp/mi4vB8pBHCnIuMY7hlxJcpFypDxKr79t3RSw7h4+MZzidAKn X-Received: by 2002:a17:906:118c:: with SMTP id n12mr24122139eja.167.1607438182174; Tue, 08 Dec 2020 06:36:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607438182; cv=none; d=google.com; s=arc-20160816; b=il0BgNKwdKu+aqIThVcCg5O4KzvRr4Z/nNmQd3t4UHwSxmTj5agvIwIiwd7NtMWePC 7GqI5KGY3x3qiDn09ApR/wLhy3Wg1tK+DixlCJJU+VmLmXbOdNhrsTDLfk+d+6cjJFx5 Wowey0SsJoE6uSwBLJReY9aIac/nE0+BDnpkqA1K4QeUsWu1ytcZF9DxdxfbLbQFdTMz Aaz8L4GtjsVQnNMS3UDEzu/jCVh4OAAH/frzdbw7Aq8pdAOibkLiD9WUCvFd/UBwa1hf 1jTZxd27epHGNNQGgQkVJuEtd3/FnE+rYr8xD14m9zuyKT9/mk38bP/IiLCim0GoOxg/ KLgA== 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:dkim-signature; bh=zIR+0wdX9mGZ+9nZq06jlSlh4CwZTHmgzYjBIwlfzOY=; b=kN00r/z++XA9d8AnVowy5Wz4mKz5Omsz6jLhAsqzBtL+zmNhcrIiVhY5pqK3JXg9wx w8O0epjS0GfZ9f7Gg45uWNmzpU4kpURJsLfx/SzOQL0jr8KsRtYl0Do3wA+6IAi8Swb4 OfaFA5Rkfzkhd+iKmWoP+DbgTA0G+RlNUcAP5nczqdFotD9/8JVEg3ad3uLgQNYe4sU1 CgvG3kEckmedkkrT+AJIi0d0ew6MaStUdhPPCKPC4vifFVBAvzS0YLccJsYiNHqQe36f MrCR31cSisxrI1zti7ZHRR2dLtHtkS/MjgZGqwtZH1cg0Ocfa+vL1pa2uGo5GE0s5WVQ 0UMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kUOnfZTE; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id eb9si10299068edb.436.2020.12.08.06.35.57; Tue, 08 Dec 2020 06:36:22 -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=@gmail.com header.s=20161025 header.b=kUOnfZTE; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729759AbgLHOcB (ORCPT + 99 others); Tue, 8 Dec 2020 09:32:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729558AbgLHOcB (ORCPT ); Tue, 8 Dec 2020 09:32:01 -0500 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0722CC0613D6; Tue, 8 Dec 2020 06:31:21 -0800 (PST) Received: by mail-ej1-x643.google.com with SMTP id b9so14553040ejy.0; Tue, 08 Dec 2020 06:31:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=zIR+0wdX9mGZ+9nZq06jlSlh4CwZTHmgzYjBIwlfzOY=; b=kUOnfZTEkCfHF08lRsp7EbR4PQPdz2eCqeaWPixuzgaa46cpgZV+c28DPhaPpLol5W 49ztne8MsRTGzYp58vevprD5qcfdIoIdsnbOmqhVc/9e1worAspYwZGeeP05MKZYO0k6 teyGwD67498U+ZfPrD+WgAgPB+TzDlsyuO88zKzUjNh33lFaK0oiFvNn/KGDZsCLvUTD hsuPHy1kfoo5r0E33vcuFWKMSEUfjxqZMtvanAMaO/luxNUaivEVuXUFQk7CyYCpRbMN Q5be070aLvQloX2Jhw2/FNaArCtnjQCCzcizpHRvVRXeawRiIvszibC7nZWgI2N1igD0 9A7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=zIR+0wdX9mGZ+9nZq06jlSlh4CwZTHmgzYjBIwlfzOY=; b=R5OJahc17ZYv5N75iIO955OM913xzLbwmP4k/7aLI35IRyQgqRxwfhK28vG3UuBkZe Jcw9eVJrA+wl8vSn7vlir4z1ad/LGfTqyhn5ubdrbGqVHPe1UBSsM3Az1M5YLBwI9VfR YwVGADE3LLy5oOgFeJE/ndAHQXUcWOVoxHQdinGEpn549hUFobRkT4tY8SgCD4xNhXag JVOuVeinTWl4agIdsaWgxUTfhW7CYAauaBGgXlxeK6+p6fkMXLX1bdYUDG2rJoNIGXiu dh7xiiOpFdN/0BMGBTvJlwDRqnAyVkTb5a6YWejmmLS0d28QlUkNvu5cwRHSunmWnKoI s/Zg== X-Gm-Message-State: AOAM5321a7f+ShCs4aeyreX78qpPP/dG/FeZTrAJjocD0FyDH/gn9XyL TmbTJVDaQVJYXmCjGrFLzsY= X-Received: by 2002:a17:907:20a4:: with SMTP id pw4mr23094192ejb.499.1607437879764; Tue, 08 Dec 2020 06:31:19 -0800 (PST) Received: from localhost (176-74-128-122.netdatacomm.cz. [176.74.128.122]) by smtp.gmail.com with ESMTPSA id 3sm15792444ejn.7.2020.12.08.06.31.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Dec 2020 06:31:18 -0800 (PST) Date: Tue, 8 Dec 2020 15:31:17 +0100 From: Artem Savkov To: WANG Chao Cc: Masahiro Yamada , Linux Kernel Mailing List , Linux Kbuild mailing list , joe.lawrence@redhat.com Subject: Re: [PATCH] kbuild: add extra-y to targets-for-modules Message-ID: <20201208143117.GA3333762@wtfbox.lan> References: <20201103054425.59251-1-chao.wang@ucloud.cn> <20201123150452.GA68187@MacBook-Pro-2> <20201208092035.GA96434@MacBook-Pro-2.local> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20201208092035.GA96434@MacBook-Pro-2.local> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 08, 2020 at 05:20:35PM +0800, WANG Chao wrote: > 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 We want linker script to be used on both those steps, otherwise modpost fails. It looks like the right thing to do here is leave ldflags-y in, get rid of always-y/extra-y altogether and specify our linker script as a dependency for the object. > 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 > > > -- Regards, Artem Savkov