Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1867787rwi; Thu, 20 Oct 2022 19:02:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6TtTlk6U1Ca7K37byZX3mnbOw/VrMwBksAszQ8bP2z7CBExka+FMekK/eI8Jfg2G0EAvgW X-Received: by 2002:a17:907:3186:b0:777:3fe7:4659 with SMTP id xe6-20020a170907318600b007773fe74659mr13278409ejb.336.1666317778992; Thu, 20 Oct 2022 19:02:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666317778; cv=none; d=google.com; s=arc-20160816; b=tLRsazAOvlY2EHUdeX0MfKkbAZHmKXYrXv6IQW8ciCLsoOcKeUQ8i6/GV+kd0ay/lj XaJ2ac0CqxEpyFtP3ePfT5ax0k9eL6FXwCcOTIFGuclcdfxBtL1atm5QUlYOvkXDpPGo WDvkZ/M2M1+vjdI5R9zY5U5SIpE5mifpcCKyyT4voKSwvbFZG/rgg1vlidDeu8ZcLaDJ MS3i7EaOG3SKo74GHBjnHgULzKlNdA/Gc2NbsHUITeeofddClCmnUZNThgN+siWQzs9W V1WK/Pia2l0Y/WUnVONiHTpPDDC970Wy9gSkbI7SvrLvjWPxWKkc5lBEN/Az8P/tS6aO pkYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=HKvQli9Hdr2F6o3Nj9RfyaepLeOQTRsCkfWxOB0iwuU=; b=m6HFsWj6ZoZ5Civnqshq/G5z+k51KW8yMO+U7mOkbkqyXNkv+dP+UI9ZzTztbxvMLp +TmJjnxUhm+CVK3WKGapZln8HpEgSuFD4n+RIg8JXAfWqPTIkHhfV8SIGIeyqTMqZpaG pgGUOiQx+7at19hO0Btudufb7bGvoAW05FEkjsXq1uTN8XZXTXDRo/s+D7+mp6JT0hvh mZ8YRSy7xKta/TJ5c6PKeb/cameEypUhlNGIimrlmE28S8+Dd7Sax0X+WmHPSziiBeWV ELKbWjhd/bB1KHGVH3KO2M/b8rW4CZjmbOLUlc3AbFhiLzvgAU/O+xWuswkQNX0GjDxZ Erdg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n8-20020a05640205c800b00458e87a1d83si22144633edx.54.2022.10.20.19.02.33; Thu, 20 Oct 2022 19:02:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229710AbiJUBs2 (ORCPT + 99 others); Thu, 20 Oct 2022 21:48:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229678AbiJUBs1 (ORCPT ); Thu, 20 Oct 2022 21:48:27 -0400 Received: from out30-130.freemail.mail.aliyun.com (out30-130.freemail.mail.aliyun.com [115.124.30.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E4813F1DF; Thu, 20 Oct 2022 18:48:25 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R171e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046051;MF=ashimida@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0VShB2hj_1666316900; Received: from 192.168.199.158(mailfrom:ashimida@linux.alibaba.com fp:SMTPD_---0VShB2hj_1666316900) by smtp.aliyun-inc.com; Fri, 21 Oct 2022 09:48:21 +0800 Message-ID: <8b2864bd-30b1-254f-ebd6-79967249da9b@linux.alibaba.com> Date: Thu, 20 Oct 2022 18:48:20 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [RFC] Documentation: kbuild: Add description of git for reproducible builds Content-Language: en-US To: Bagas Sanjaya Cc: masahiroy@kernel.org, michal.lkml@markovi.net, ndesaulniers@google.com, corbet@lwn.net, linux-kbuild@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Nicolas Schier References: <20221020103823.31001-1-ashimida@linux.alibaba.com> From: Dan Li In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/20/22 07:05, Bagas Sanjaya wrote: > On Thu, Oct 20, 2022 at 03:38:23AM -0700, Dan Li wrote: >> diff --git a/Documentation/kbuild/reproducible-builds.rst b/Documentation/kbuild/reproducible-builds.rst >> index 071f0151a7a4..13397f38c358 100644 >> --- a/Documentation/kbuild/reproducible-builds.rst >> +++ b/Documentation/kbuild/reproducible-builds.rst >> @@ -119,6 +119,16 @@ To avoid this, you can make the vDSO different for different >> kernel versions by including an arbitrary string of "salt" in it. >> This is specified by the Kconfig symbol ``CONFIG_BUILD_SALT``. >> >> +Git >> +----------------------- >> + >> +Uncommitted changes or different commit ids in git can also lead >> +to different compilation results. For example, after executing >> +``git reset HEAD^``, even if the code is the same, the >> +``include/config/kernel.release`` generated during compilation >> +will be different, which will eventually lead to binary differences. >> +See ``scripts/setlocalversion`` for details. >> + > > Briefly read the script, I don't see what the correlation between git > reset with LOCALVERSION thing is. Also, does the exact state of git > repository required for reproducible builds? > Hi Bagas, The Makefile has the following code: filechk_kernel.release = \ echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))" The output of setlocalversion affects kernel.release, while the output of setlocalversion is related to the state of git when the git repository exists (see function scm_version). So changes in git state will result in changes to kernel.release, and this information will be included in the final output vmlinux/modules and in turn affect reproducible builds. For example: $ git log commit 4cd155a93eec...... $ make ... $ cat include/config/kernel.release 6.0.0-rc4-00025-g4cd155a93eec $ git reset HEAD^ $ git log commit 7b4d266b0c41...... $ make ... $ cat include/config/kernel.release 6.0.0-rc4-00024-g7b4d266b0c41-dirty AFAICT, in the presence of a git repository, we can compile a reproducible build kernel in any git state, but we need to ensure that the git state is always the same between compilations (or the same from the perspective of the scm_version function). Thanks, Dan. > Thanks. >