Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6297854rwn; Tue, 13 Sep 2022 01:59:22 -0700 (PDT) X-Google-Smtp-Source: AA6agR5RtYKXkzokNeGTvwC715pr0hRqPrvO2RoffQ5TAaechJArbZv9vqLdHs0ptioTKG1twCZX X-Received: by 2002:a17:90a:1f49:b0:202:7a55:558f with SMTP id y9-20020a17090a1f4900b002027a55558fmr2837019pjy.108.1663059561874; Tue, 13 Sep 2022 01:59:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663059561; cv=none; d=google.com; s=arc-20160816; b=f7sk93U3n7FksdeMi07zhfkW3o6HO+pNs23PpUTyMxFI7Bn7q8/vCnvFTrkca98OkC MAHmoX6db5m8VMXXIh4SnbaZlVv4gKr/sabw4J6ZfNtbL6azB5BkxhxrXMs/u6R14+5x ECRQi8EyHnnCn26gWqrTjoisQiWusP/eaMTlN+B4rNIlJXqFgmagB3srDoNiw72AGL19 TrBPBqLzayOyu74dRuaNuf3gGOBC0FHHTSlbB/Rq73uj/39k2XzMJNLFcuqb664LRxwy jkYO1CqqeUPytBet6YE1439bhc3vP1VuATSa6xvBCje5mkl9SRW/8r/pKxZATQMbyuZR tYlQ== 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=KDL6VlUsgkLk3CJExgF74nHOrxhwc9TOLumcNGlt9ik=; b=QHnx1woe0IYNx+B523rBsuVqaE1pGG1ci8uvbC1Rsd7qsMyj2C+Puj2Udnl9VCEzJ5 TDV5Ejk5aZDAu5fDrT0iDxQ2rAFg1Cjf+1/ev5SuGNLQYimPbXLYvPtdXrsQOcCQOXLF 35uwAlF6YTh2+JeD1zxHmmv3Zjerg1lcWYGKVyVrEdmbjJdB6kk2y594iNzSZ51FQdXn uAfViG7Ysypq8qIxF1x5VkLjxDPecMHtONlWiXGc7zdC9dRKvYTgV1cz1Hmv+UlgFSsP /nJ5nZNQuqixKacyPtshhAm4hcvDyyYMwwTkFaNvbBUJQUMoQF9XbqS+V4SM7DQUwn4d rZwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lfPiTmao; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w22-20020a170902d71600b001781a1c0898si10901704ply.454.2022.09.13.01.59.10; Tue, 13 Sep 2022 01:59:21 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lfPiTmao; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231468AbiIMIc1 (ORCPT + 99 others); Tue, 13 Sep 2022 04:32:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230308AbiIMIcY (ORCPT ); Tue, 13 Sep 2022 04:32:24 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B42532BAE; Tue, 13 Sep 2022 01:32:23 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EA5C961348; Tue, 13 Sep 2022 08:32:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1C7B2C433C1; Tue, 13 Sep 2022 08:32:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663057942; bh=IpBWenXYeupRmjxDDsPlTF+3obS82kk1lpWQuCco5+I=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=lfPiTmaohwaNWsD/cBAWS0LdnmTZ7deyI3x2T0JSUPyITOTySPDNC8cNMVXQ4+JRs YIl8lx7Ta1yRVaM5lSiDyew/bJiY64qWTfNYUsMe/kQVQsMOSAtfsTN9CJ+aq3WlA6 AUYQz8v5PiSfAm0MhYmHG0GE6/2Ku5UlSbRkc5CDlW/zbAPwo3Tdoutbd9mVhdKLbp E/nlthrWW+nJ5+ZdeKacqQMW1ca7k+BcVHXreftNkFKZ4XaD2jc0SbzPaTHzrVS4LI G0yHd1gqsN7kn2B7vEClRdoQbD96JLqkc69vRQA0njFpQiQ6j60HsgWlPjECQ2k/m/ CetHM6rZXmCww== Date: Tue, 13 Sep 2022 01:32:20 -0700 From: Nathan Chancellor To: Masahiro Yamada Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org Subject: Re: [PATCH 05/15] kbuild: build init/built-in.a just once Message-ID: References: <20220828024003.28873-1-masahiroy@kernel.org> <20220828024003.28873-6-masahiroy@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220828024003.28873-6-masahiroy@kernel.org> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Hi Masahiro, On Sun, Aug 28, 2022 at 11:39:53AM +0900, Masahiro Yamada wrote: > Kbuild builds init/built-in.a twice; first during the ordinary > directory descending, second from scripts/link-vmlinux.sh. > > We do this because UTS_VERSION contains the build version and the > timestamp. We cannot update it during the normal directory traversal > since we do not yet know if we need to update vmlinux. UTS_VERSION is > temporarily calculated, but omitted from the update check. Otherwise, > vmlinux would be rebuilt every time. > > When Kbuild results in running link-vmlinux.sh, it increments the > version number in the .version file and takes the timestamp at that > time to really fix UTS_VERSION. > > However, updating the same file twice is a footgun. To avoid nasty > timestamp issues, all build artifacts that depend on init/built-in.a > must be atomically generated in link-vmlinux.sh, where some of them > do not need rebuilding. > > To fix this issue, this commit changes as follows: > > [1] Split UTS_VERSION out to include/generated/utsversion.h from > include/generated/compile.h > > include/generated/utsversion.h is generated just before the > vmlinux link. It is generated under include/generated/ because > some decompressors (s390, x86) use UTS_VERSION. > > [2] Split init_uts_ns and linux_banner out to init/version-timestamp.c > from init/version.c > > init_uts_ns and linux_banner contain UTS_VERSION. During the ordinary > directory descending, they are compiled with __weak and used to > determine if vmlinux needs relinking. Just before the vmlinux link, > they are compiled without __weak to embed the real version and > timestamp. > > Signed-off-by: Masahiro Yamada > diff --git a/init/build-version b/init/build-version > new file mode 100755 > index 000000000000..39225104f14d > --- /dev/null > +++ b/init/build-version > @@ -0,0 +1,10 @@ > +#!/bin/sh > +# SPDX-License-Identifier: GPL-2.0-only > + > +VERSION=$(cat .version) 2>/dev/null && > +VERSION=$(expr $VERSION + 1) 2>/dev/null || > +VERSION=1 > + > +echo ${VERSION} > .version > + > +echo ${VERSION} I am seeing cat: .version: No such file or directory at some point in nearly all of my builds in -next. Does the 2>/dev/null want to be moved into the subshell? Cheers, Nathan