Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0DF4CC61DA4 for ; Mon, 20 Feb 2023 02:42:54 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1A2A6857E9; Mon, 20 Feb 2023 03:42:35 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="XZyY/BKh"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AE32F85831; Mon, 20 Feb 2023 03:42:11 +0100 (CET) Received: from mail-io1-xd36.google.com (mail-io1-xd36.google.com [IPv6:2607:f8b0:4864:20::d36]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 93B84857DC for ; Mon, 20 Feb 2023 03:42:07 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd36.google.com with SMTP id bf15so3695iob.7 for ; Sun, 19 Feb 2023 18:42:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4K0sn28wy9GuUu7s+r4NMx41RBSv7JlLglqbQZoV85c=; b=XZyY/BKhkOcXMUb09ocuw7m89EW91MH+8LsfZwsbjoTj8ydrJtnfuCWGMWIK1/+AwV lwn+myxdDWMnTtF+5smVkx4AKGfnkyCxYcyt0ZsA4PK5cqYJ/OyGDEUwojcUAnO9Pu8S VhDE02MwB/2uDs3J8c6CFwxlEFDu8Z2LKSRls= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4K0sn28wy9GuUu7s+r4NMx41RBSv7JlLglqbQZoV85c=; b=hPEvf3TpLDQIx1uwKJZ5HtQGXwyGonq8+aFkick8DFsXXWs/Mw1PR6XqJKUwI2b+eI LbLBQnEhtyl8NGe9dEz+gQs+vcrtVHd3+/OpbmMQRdAKup2SAVfJIuhPzvM2ZqUp7WVt 4tGHTtm+JBPzhTpJHrRj9xTt9oPh0vmUSE0sNuEVQqO762QqYIuoUpADmP9lpdYJ5OnP 28J8W9SaiinA+1KVkeqYBkBjCc9+mjCK2t/dVOuoqOXWVOcxKWAPCVmsmR3Q01iMnU7G ibXG+F8ZB14706pMCmrhAjryE6IyBJIZ5r5D+mnfMa/anT6CZ5f3s9ujdukAN6Pj6buW 3exQ== X-Gm-Message-State: AO0yUKUPSWPLKUXT29jGq8heQaA8pdlY1dc9sd0RfGwnXfYlRlK/igBb 5eu6DOdpTF7UxleI/ugYrEp/B4OEyvnIlUfH X-Google-Smtp-Source: AK7set/pybR5bm8GzQpUun1nWl34FrDczFvgaZI01Wd7WHhjhARdLm64eeoGi0fiKaHfxSp5p6hEDg== X-Received: by 2002:a5d:9404:0:b0:720:8d71:522a with SMTP id v4-20020a5d9404000000b007208d71522amr6649251ion.16.1676860925952; Sun, 19 Feb 2023 18:42:05 -0800 (PST) Received: from sjg1.roam.corp.google.com (c-73-14-173-85.hsd1.co.comcast.net. [73.14.173.85]) by smtp.gmail.com with ESMTPSA id a4-20020a029f84000000b0035a40af60fcsm3744742jam.86.2023.02.19.18.42.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Feb 2023 18:42:05 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Heinrich Schuchardt Subject: [PATCH 4/4] buildman: Add a flag for reproducible builds Date: Sun, 19 Feb 2023 19:41:55 -0700 Message-Id: <20230220024156.1866977-4-sjg@chromium.org> X-Mailer: git-send-email 2.39.2.637.g21b0678d19-goog In-Reply-To: <20230220024156.1866977-1-sjg@chromium.org> References: <20230220024156.1866977-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean This is quite a useful thing to use when building since it avoids small size changes between commits. Add a -r flag for it. Signed-off-by: Simon Glass --- doc/build/reproducible.rst | 2 ++ tools/buildman/builder.py | 4 +++- tools/buildman/builderthread.py | 2 ++ tools/buildman/buildman.rst | 7 ++++--- tools/buildman/cmdline.py | 2 ++ tools/buildman/control.py | 3 ++- tools/buildman/func_test.py | 4 ++++ 7 files changed, 19 insertions(+), 5 deletions(-) diff --git a/doc/build/reproducible.rst b/doc/build/reproducible.rst index 5423080633e..8b030f469d7 100644 --- a/doc/build/reproducible.rst +++ b/doc/build/reproducible.rst @@ -23,3 +23,5 @@ This date is shown when we launch U-Boot: ./u-boot -T U-Boot 2023.01 (Jan 01 2023 - 00:00:00 +0000) + +The same effect can be obtained with buildman using the `-r` flag. diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py index 107086cc0e5..7b9be887e55 100644 --- a/tools/buildman/builder.py +++ b/tools/buildman/builder.py @@ -195,6 +195,7 @@ class Builder: don't write to a separate output directory. thread_exceptions: List of exceptions raised by thread jobs no_lto (bool): True to set the NO_LTO flag when building + reproducible_builds (bool): True to set SOURCE_DATE_EPOCH=0 for builds Private members: _base_board_dict: Last-summarised Dict of boards @@ -254,7 +255,7 @@ class Builder: config_only=False, squash_config_y=False, warnings_as_errors=False, work_in_output=False, test_thread_exceptions=False, adjust_cfg=None, - allow_missing=False, no_lto=False): + allow_missing=False, no_lto=False, reproducible_builds=False): """Create a new Builder object Args: @@ -334,6 +335,7 @@ class Builder: self.allow_missing = allow_missing self._ide = False self.no_lto = no_lto + self.reproducible_builds = reproducible_builds if not self.squash_config_y: self.config_filenames += EXTRA_CONFIG_FILENAMES diff --git a/tools/buildman/builderthread.py b/tools/buildman/builderthread.py index dae3d4ab9ff..8b88c68e5d2 100644 --- a/tools/buildman/builderthread.py +++ b/tools/buildman/builderthread.py @@ -257,6 +257,8 @@ class BuilderThread(threading.Thread): args.append('BINMAN_ALLOW_MISSING=1') if self.builder.no_lto: args.append('NO_LTO=1') + if self.builder.reproducible_builds: + args.append('SOURCE_DATE_EPOCH=0') config_args = ['%s_defconfig' % brd.target] config_out = '' args.extend(self.builder.toolchains.GetMakeArguments(brd)) diff --git a/tools/buildman/buildman.rst b/tools/buildman/buildman.rst index 800b83a89de..c8b0db3d8b9 100644 --- a/tools/buildman/buildman.rst +++ b/tools/buildman/buildman.rst @@ -1023,14 +1023,15 @@ U-Boot's build system embeds information such as a build timestamp into the final binary. This information varies each time U-Boot is built. This causes various files to be rebuilt even if no source changes are made, which in turn requires that the final U-Boot binary be re-linked. This unnecessary work can -be avoided by turning off the timestamp feature. This can be achieved by -setting the SOURCE_DATE_EPOCH environment variable to 0. +be avoided by turning off the timestamp feature. This can be achieved using +the `-r` flag, which enables reproducible builds by setting +`SOURCE_DATE_EPOCH=0` when building. Combining all of these options together yields the command-line shown below. This will provide the quickest possible feedback regarding the current content of the source tree, thus allowing rapid tested evolution of the code:: - SOURCE_DATE_EPOCH=0 ./tools/buildman/buildman -P tegra + ./tools/buildman/buildman -Pr tegra Checking configuration diff --git a/tools/buildman/cmdline.py b/tools/buildman/cmdline.py index 409013671be..da7f1a99f6b 100644 --- a/tools/buildman/cmdline.py +++ b/tools/buildman/cmdline.py @@ -97,6 +97,8 @@ def ParseArgs(): default=False, help="Use full toolchain path in CROSS_COMPILE") parser.add_option('-P', '--per-board-out-dir', action='store_true', default=False, help="Use an O= (output) directory per board rather than per thread") + parser.add_option('-r', '--reproducible-builds', action='store_true', + help='Set SOURCE_DATE_EPOCH=0 to suuport a reproducible build') parser.add_option('-R', '--regen-board-list', action='store_true', help='Force regeneration of the list of boards, like the old boards.cfg file') parser.add_option('-s', '--summary', action='store_true', diff --git a/tools/buildman/control.py b/tools/buildman/control.py index 13a462ae595..0d7c5f5269f 100644 --- a/tools/buildman/control.py +++ b/tools/buildman/control.py @@ -351,7 +351,8 @@ def DoBuildman(options, args, toolchains=None, make_func=None, brds=None, work_in_output=options.work_in_output, test_thread_exceptions=test_thread_exceptions, adjust_cfg=adjust_cfg, - allow_missing=allow_missing, no_lto=options.no_lto) + allow_missing=allow_missing, no_lto=options.no_lto, + reproducible_builds=options.reproducible_builds) builder.force_config_on_failure = not options.quick if make_func: builder.do_make = make_func diff --git a/tools/buildman/func_test.py b/tools/buildman/func_test.py index 6d1557293f0..47fca33002d 100644 --- a/tools/buildman/func_test.py +++ b/tools/buildman/func_test.py @@ -753,3 +753,7 @@ Some images are invalid''' lines = self.check_command('-L') self.assertIn(b'NO_LTO=1', lines[0]) + def testReproducible(self): + """Test that the -r flag works""" + lines = self.check_command('-r') + self.assertIn(b'SOURCE_DATE_EPOCH=0', lines[0]) -- 2.39.2.637.g21b0678d19-goog