Received: by 10.223.185.116 with SMTP id b49csp3234664wrg; Mon, 12 Feb 2018 23:10:25 -0800 (PST) X-Google-Smtp-Source: AH8x2277v1O91YSffNbd3wi5hH1wpuHUW2ZgQy6DjW1S698rvyTjPgWzJwrgSqUhujgg9t3Ur7P2 X-Received: by 2002:a17:902:1683:: with SMTP id h3-v6mr215869plh.433.1518505825503; Mon, 12 Feb 2018 23:10:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518505825; cv=none; d=google.com; s=arc-20160816; b=QwZcdN9wV9YWVdBq39way5b4NGRDw6zKi9BhTqQWn5ujDroJSOM7WodC+2HRqS8tVs ATwtlIL6S36RhhpuIty7bsYOUeUwGyOjI+Xp3IVC1wEBLTcglStMtuuVzgIBTHhMkccL fH+BgXh46GNZKzXDOJqqlVVz2bccvTEPHKGd/y/Iuq/hDfM4zAMnOoE5dDLgVUJGGOBH lPKEfpbiY3st7sJeZbzeyZaXPR0SCOaJShzhOah/s4UoHPKLsU9K9cuvDNkuRPNmMM7X rwICiFx18iT3N5swRNRDglamGagMqx1aKI8uJydUPA/zz/pRzXhqvLmUXTKutgpiGOi0 F9GA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=+vH02eKpGmKr8ZJGc61yq5PRykqnM49CeVz5H2SQ718=; b=gcH+2YHZwhsPa5oR4FwFTlh55Qp55K66U1kMZvt1wi7PjXyHasMqC9BKoiGSJ4VenQ HtPnn8dpwtTjVyQUN10iUeyw3YLZtGHTi+40QUUYIWn/H1rGNDGAtyz73CVh7yToWPVt ixFPD4Ad8oS9LDM0pWleeLxLJ31+I9Z0PjeHI7LVEKdzb9gjzl8TIXW4kR/01sMPIM1N NKe92u5/bWgi3X7laHqC4MyQ/e7QJEr+3cE5TtWykekLavL/sP9J1Q+HOZlwxtIKsTtg v9U7iNtLazqBN2jTGRDCwFRYs5EPwVFhLV7D9TtoH9dOniSFsmwds+a0jXJrr6usF/cv dpxQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b3-v6si791301plc.309.2018.02.12.23.10.10; Mon, 12 Feb 2018 23:10:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933502AbeBMHJa (ORCPT + 99 others); Tue, 13 Feb 2018 02:09:30 -0500 Received: from mail.cn.fujitsu.com ([183.91.158.132]:5279 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933366AbeBMHJ2 (ORCPT ); Tue, 13 Feb 2018 02:09:28 -0500 X-IronPort-AV: E=Sophos;i="5.43,368,1503331200"; d="scan'208";a="37022158" Received: from bogon (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 13 Feb 2018 15:09:26 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (unknown [10.167.33.83]) by cn.fujitsu.com (Postfix) with ESMTP id 8A9E848AE761; Tue, 13 Feb 2018 15:09:25 +0800 (CST) Received: from [10.167.226.60] (10.167.226.60) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.361.1; Tue, 13 Feb 2018 15:09:23 +0800 Subject: Re: why scripts/link-vmlinux.sh has a final build of init/ To: Masahiro Yamada CC: Michal Marek , Linux Kbuild mailing list , "linux-kernel@vger.kernel.org" References: From: Cao jin Message-ID: <6f19ae3f-249e-2d20-dcd6-e34c475a2638@cn.fujitsu.com> Date: Tue, 13 Feb 2018 15:08:55 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.167.226.60] X-yoursite-MailScanner-ID: 8A9E848AE761.A88B1 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: caoj.fnst@cn.fujitsu.com X-Spam-Status: No Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/12/2018 10:48 PM, Masahiro Yamada wrote: > 2018-02-12 13:22 GMT+09:00 Cao jin : >> Hi Masahiro-san, >> >> As I remember, init/ is already built during recursive make, and I did >> a clean build(make mrproper, make localmodconfig) with all plugins >> included on x86_64 with following patch, the kernel can boot without any >> obvious problem. So, I don't figure out why we need this final build? >> >> >> diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh >> index e6818b8e7141..086b2efd4d53 100755 >> --- a/scripts/link-vmlinux.sh >> +++ b/scripts/link-vmlinux.sh >> @@ -247,9 +247,6 @@ else >> expr 0$(cat .old_version) + 1 >.version; >> fi; >> >> -# final build of init/ >> -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init >> GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" >> - >> archive_builtin >> >> #link vmlinux.o >> > > > link-vmlinux.sh increments '.version' > so it must descend into init/ > to update include/generated/compile.h > and re-compile init/version.o > > We do not increment '.version' > at the first descend into init/ > because we never know whether the kernel > is updated or not before the final link stage. > Oh, I wasn't aware of this process, now understood. Thanks Masahiro-san. BTW, I still have 2 questions. 1. In final build, why need    GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" Doesn't GCC_PLUGINS_CFLAGS already exist in the environment? I also tested the Randomizing Structure Layout plugin with this patch, the plugin seems works in my test. 2. scripts/link-vmlinux.sh seems just handle only one argument: clean. So why shouldn't it be: diff --git a/Makefile b/Makefile index ccd981892ef2..21d93b545381 100644 --- a/Makefile +++ b/Makefile @@ -998,7 +998,7 @@ ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink) # Final link of vmlinux with optional arch pass after final link cmd_link-vmlinux = \ - $(CONFIG_SHELL) $< $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) ; \ + $(CONFIG_SHELL) $<; \ $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) vmlinux: scripts/link-vmlinux.sh vmlinux_prereq $(vmlinux-deps) FORCE -- Sincerely, Cao jin