From patchwork Thu Oct 1 23:15:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Hutchings X-Patchwork-Id: 7312211 Return-Path: X-Original-To: patchwork-linux-kbuild@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id F2B5E9F1D5 for ; Thu, 1 Oct 2015 23:15:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 14A0B20502 for ; Thu, 1 Oct 2015 23:15:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EBB6F204B5 for ; Thu, 1 Oct 2015 23:15:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750795AbbJAXPp (ORCPT ); Thu, 1 Oct 2015 19:15:45 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:56091 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750788AbbJAXPo (ORCPT ); Thu, 1 Oct 2015 19:15:44 -0400 Received: from deadeye.wl.decadent.org.uk ([192.168.4.247] helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84) (envelope-from ) id 1Zhn4g-0003nf-Ua; Fri, 02 Oct 2015 00:15:43 +0100 Received: from ben by deadeye with local (Exim 4.86) (envelope-from ) id 1Zhn4b-0000UG-Pf; Fri, 02 Oct 2015 00:15:37 +0100 Message-ID: <1443741332.2730.75.camel@decadent.org.uk> Subject: [PATCH] kbuild: Add support for SOURCE_DATE_EPOCH environment variable From: Ben Hutchings To: Michal Marek Cc: linux-kbuild , reproducible-builds@lists.alioth.debian.org Date: Fri, 02 Oct 2015 00:15:32 +0100 X-Mailer: Evolution 3.16.5-1 Mime-Version: 1.0 X-SA-Exim-Connect-IP: 192.168.4.247 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, T_TVD_MIME_EPI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP As part of the reproducible builds project, the SOURCE_DATE_EPOCH environment variable has been specified as a project- and distribution-independent means to specify a timestamp at build time: https://reproducible-builds.org/specs/source-date-epoch/ Add support for this by converting it to KBUILD_BUILD_TIMESTAMP if they aren't both set. Signed-off-by: Ben Hutchings --- Documentation/kbuild/kbuild.txt | 15 +++++++++------ Makefile | 10 ++++++++++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/Documentation/kbuild/kbuild.txt b/Documentation/kbuild/kbuild.txt index 0ff6a46..9f95228 100644 --- a/Documentation/kbuild/kbuild.txt +++ b/Documentation/kbuild/kbuild.txt @@ -211,12 +211,15 @@ KBUILD_ENABLE_EXTRA_GCC_CHECKS If enabled over the make command line with "W=1", it turns on additional gcc -W... options for more extensive build-time checking. -KBUILD_BUILD_TIMESTAMP --------------------------------------------------- -Setting this to a date string overrides the timestamp used in the -UTS_VERSION definition (uname -v in the running kernel). The value has to -be a string that can be passed to date -d. The default value -is the output of the date command at one point during build. +KBUILD_BUILD_TIMESTAMP, SOURCE_DATE_EPOCH +-------------------------------------------------- +Setting KBUILD_BUILD_TIMESTAMP to a date string overrides the +timestamp used in the UTS_VERSION definition (uname -v in the running +kernel). The value has to be a string that can be passed to date -d. +The default value is the output of the date command at one point +during build. Alternately, the timestamp may be specified in +SOURCE_DATE_EPOCH as the number of whole non-leap seconds since the +epoch. KBUILD_BUILD_USER, KBUILD_BUILD_HOST -------------------------------------------------- diff --git a/Makefile b/Makefile index 1d341eb..bfb0243 100644 --- a/Makefile +++ b/Makefile @@ -417,6 +417,16 @@ export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL export KBUILD_ARFLAGS +ifndef KBUILD_BUILD_TIMESTAMP + # If SOURCE_DATE_EPOCH is set in the environment (only), then + # generate a timestamp string based on that, independent of the + # current time zone and locale. + ifeq ("$(origin SOURCE_DATE_EPOCH)", "environment") + KBUILD_BUILD_TIMESTAMP := $(shell LC_TIME=C date -u -d@$(SOURCE_DATE_EPOCH)) + export KBUILD_BUILD_TIMESTAMP + endif +endif + # When compiling out-of-tree modules, put MODVERDIR in the module # tree rather than in the kernel tree. The kernel tree might # even be read-only.