Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1953486rwb; Thu, 17 Nov 2022 04:40:57 -0800 (PST) X-Google-Smtp-Source: AA0mqf5CDoNpryjg+Z1EDgmDFg27YX+l4Vt0qubTuNNOHyQvOz4EOTAnhUIbRfT3b55NQytSjAna X-Received: by 2002:a17:902:8217:b0:186:e2c3:91c6 with SMTP id x23-20020a170902821700b00186e2c391c6mr2603766pln.27.1668688856871; Thu, 17 Nov 2022 04:40:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668688856; cv=none; d=google.com; s=arc-20160816; b=w+QX2jI6GKWaFI9JvPVQkNGiM0rICGGxSg8btr26Mb7ZDljEdnt5lFYs+pwUoDv3Ur VE9k2CE8/tUU2dZ0Ultu/1ubdeCBXgmwM+vVTHBapsL4NGgJga04VfHNpXv3jAgtxPqA RsMs9ifiArsoRDrhcR8DNMh1RQ3WKvvk7TdPCNDqLTuSAvqtQ+Nf8qcRYtq4I2DMJDvY Ej/k3NrK4YRP30kGp1yhuATap0ln4lpBqvNQuh8FGU+FReQyWn2ybL6nlnRjQ/SI7Ajn VnxLOw+m/xPHrkjx/zPs+Pog7e63pQhrXE4AD71/maokUg9QROJehLFyWw8mI8GQG9Aj SDCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature:dkim-filter; bh=nRWOhJaZ5KAIeF0ENljN/lYw/5/QcrKlraNrZbKSTAM=; b=Qn+nKJ/MCfCGTBvpIkgoNEAh9jzFAGTPJ6K9jSVPnmhZyU4/hTX01Zr9fpGk0hxASp 2hNQHjW9tm7nzYQGiP7LDYCsTd8Z7ZKkUbnlI8TrqiL9+HvHt4Ijs4i0JNO8xmZmsEiV F3S6MMDu/av/s9w8PJCeKdK04Nkp2NkgQoAh/5xWcpgSFj08a8W+iACgHSlogrcUDwHU m8V9YOCEZ/XC6tD41qGSd2nCYAgNLJ8bprLwFpeYMRlnhW+1+lwuOTzAtpoND7nNdwkL TFXizV1Bv4vC9kde2NeedHjpeFwclQkcnkIc9FxaVA2Tl3Fm91CvVa0DC98sBetUFjHu Xd1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=XC2ya10T; 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 y10-20020a634b0a000000b00476f8b57e4asi827226pga.475.2022.11.17.04.40.45; Thu, 17 Nov 2022 04:40:56 -0800 (PST) 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=@nifty.com header.s=dec2015msa header.b=XC2ya10T; 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 S234901AbiKQLRy (ORCPT + 92 others); Thu, 17 Nov 2022 06:17:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239281AbiKQLRw (ORCPT ); Thu, 17 Nov 2022 06:17:52 -0500 X-Greylist: delayed 136 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 17 Nov 2022 03:17:50 PST Received: from condef-05.nifty.com (condef-05.nifty.com [202.248.20.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C858CF78; Thu, 17 Nov 2022 03:17:50 -0800 (PST) Received: from conssluserg-06.nifty.com ([10.126.8.85])by condef-05.nifty.com with ESMTP id 2AHB9cFS027160; Thu, 17 Nov 2022 20:09:38 +0900 Received: from mail-ot1-f45.google.com (mail-ot1-f45.google.com [209.85.210.45]) (authenticated) by conssluserg-06.nifty.com with ESMTP id 2AHB9ICE016704; Thu, 17 Nov 2022 20:09:18 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-06.nifty.com 2AHB9ICE016704 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1668683359; bh=nRWOhJaZ5KAIeF0ENljN/lYw/5/QcrKlraNrZbKSTAM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=XC2ya10TgEd1/8TzhF2Gr0PhHcLAntAWAqf3VAo1zqogYwrVf1xAC3tvJnrHRXzFh sHjUgIADN21SHjC3AlekRf+Ox8MnfToRWl/lqFA1ACbVLm7ZJpIi6OnfrCK3pE8oU8 5l4cqD0kU2a7/vQR/icZ605LP0KceNLoT5PP9JI4Wohs1ENeYjSE0Ujm59k966Pbrt ErwMQXOfdT3YtvF91V72VtQ7D/+jXPr2lO1GNZHej2Vn+9R2Y2RqDuTzOaz69kiYFl fnx2jMDesvKTAolXZ3+In6CEeuDnwQASAamQRtGVvps4L0W/7BOeNjfP4VB2CUIPfy 5LMj2rvBqAqgw== X-Nifty-SrcIP: [209.85.210.45] Received: by mail-ot1-f45.google.com with SMTP id p27-20020a056830319b00b0066d7a348e20so812322ots.8; Thu, 17 Nov 2022 03:09:18 -0800 (PST) X-Gm-Message-State: ANoB5plBe1FLaMkMcXlr2fMExyNIDzIEM56lNWUhWGi++CQp4q3l0ENz TZwCUrSOfNU0Z6c/IQ19FoRNZ9BWlBG1FGgAPjk= X-Received: by 2002:a9d:282:0:b0:66c:794e:f8c6 with SMTP id 2-20020a9d0282000000b0066c794ef8c6mr1077050otl.343.1668683357460; Thu, 17 Nov 2022 03:09:17 -0800 (PST) MIME-Version: 1.0 References: <20220828024003.28873-1-masahiroy@kernel.org> <20220828024003.28873-6-masahiroy@kernel.org> In-Reply-To: From: Masahiro Yamada Date: Thu, 17 Nov 2022 20:08:39 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 05/15] kbuild: build init/built-in.a just once To: Jon Hunter Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, "linux-tegra@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no 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 Thu, Nov 17, 2022 at 7:00 PM Jon Hunter wrote: > > Hi Masahiro > > On 28/08/2022 03:39, 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 > > > Since this change I have noticed that the kernel image (at least on ARM64) now contains two version strings ... > > $ strings arch/arm64/boot/Image | grep "Linux version" > Linux version 6.0.0-rc7-00011-g2df8220cc511 (jonathanh@moonraker) (aarch64-linux-gnu-gcc (Linaro GCC 6.4-2017.08) 6.4.1 20170707, GNU ld (Linaro_Binutils-2017.08) 2.27.0.20161019) # SMP PREEMPT > Linux version 6.0.0-rc7-00011-g2df8220cc511 (jonathanh@moonraker) (aarch64-linux-gnu-gcc (Linaro GCC 6.4-2017.08) 6.4.1 20170707, GNU ld (Linaro_Binutils-2017.08) 2.27.0.20161019) #20 SMP PREEMPT Thu Nov 17 09:49:18 GMT 2022 > > Is this expected? Yes. The first line is a weak (i.e. unused) symbol. The second one is a real one. 2df8220cc511326508ec4da2f43ef69311bdd7b9 fixed up arch/powerpc/boot/wrapper because it grep's vmlinux. The weak symbols slightly increase the image size, but I do not know how to do this better. > Thanks! > Jon > > -- > nvpublic -- Best Regards Masahiro Yamada