From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 95027 invoked by alias); 30 Jun 2015 13:19:03 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 95012 invoked by uid 89); 30 Jun 2015 13:19:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 X-HELO: smtp3.openmailbox.org Received: from smtp3.openmailbox.org (HELO smtp3.openmailbox.org) (62.4.1.37) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 30 Jun 2015 13:19:01 +0000 Received: from localhost (localhost [127.0.0.1]) by mail2.openmailbox.org (Postfix) with ESMTP id D4CFB2008BB for ; Tue, 30 Jun 2015 15:18:57 +0200 (CEST) Received: from mail2.openmailbox.org ([62.4.1.33]) by localhost (mail.openmailbox.org [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id nNF53-JBex_H for ; Tue, 30 Jun 2015 15:18:56 +0200 (CEST) Message-ID: <55929721.4020400@openmailbox.org> Date: Tue, 30 Jun 2015 13:19:00 -0000 From: Dhole User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: gcc-patches@gcc.gnu.org Subject: [PATCH] Allow embedded timestamps by C/C++ macros to be set externally Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="ftwBhv9HQ17hlT2FmMTbM25eRmFieQLqP" X-IsSubscribed: yes X-SW-Source: 2015-06/txt/msg02211.txt.bz2 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --ftwBhv9HQ17hlT2FmMTbM25eRmFieQLqP Content-Type: multipart/mixed; boundary="------------000809070007030506020005" This is a multi-part message in MIME format. --------------000809070007030506020005 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Content-length: 1853 Hi! We are working in Debian =E2=80=94and I know other free software projects care=E2=80=94 in providing our users with a way to reproduce bit-for-bit identical binary packages from the source and build environment. See for some rationale and further explanations. In order to do this, we need to make the build processes deterministic. As you can imagine, gcc is quite involved in producing Debian packages. One issue we encounter in many packages that fail to build reproducibly is the use of the __DATE__, __TIME__ C macros [1], right now we have 456 affected packages that would need patching (either removing the macros, or passing a known date externally). A solution for toolchain packages that embed timestamps during the build process has been proposed for anyone interested and it consists of the following: The build environment can export an environment variable called SOURCE_DATE_EPOCH with a known timestamp in Unix epoch format (In our case, we use the last date of the package's debian changelog). The toolchain package running during the build can check if the exported variable is set and if so, instead of embedding the local date/time, embed the date/time from SOURCE_DATE_EPOCH. It would be very beneficial to our project (and other free software projects working on reproducible builds) if gcc supported this feature. I'm attaching a patch for gcc-5.1.0 that enables this feature: it modifies the behavior of the macros __DATE__ and __TIME__ when SOURCE_DATE_EPOCH is exported. What do you think? Any suggestions or other ideas that help getting reproducible builds are welcomed. I'm willing to extend the documentation if the patch feels appropriate. Thanks for your attention! [1] https://wiki.debian.org/ReproducibleBuilds/TimestampsFromCPPMacros Best regards, Dhole --------------000809070007030506020005 Content-Type: text/plain; charset=UTF-8; name="set_DATE_TIME_externally.diff.txt" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="set_DATE_TIME_externally.diff.txt" Content-length: 2148 ZGlmZiAtLWdpdCBhL2xpYmNwcC9tYWNyby5jIGIvbGliY3BwL21hY3JvLmMK aW5kZXggMWUwYTBiNS4uYTUyZTNjYiAxMDA2NDQKLS0tIGEvbGliY3BwL21h Y3JvLmMKKysrIGIvbGliY3BwL21hY3JvLmMKQEAgLTM0OSwxNCArMzQ5LDM4 IEBAIF9jcHBfYnVpbHRpbl9tYWNyb190ZXh0IChjcHBfcmVhZGVyICpwZmls ZSwgY3BwX2hhc2hub2RlICpub2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VVJDRV9EQVRFX0VQT0NIPVwi JXNcIiBpcyBub3QgYSB2YWxpZCBkYXRlIiwKKwkJCSAgICAgICBzb3VyY2Vf ZGF0ZV9lcG9jaCk7CisJICAgICAgICB9CisJICAgICAgZWxzZQorCQljcHBf ZXJyb3IgKHBmaWxlLCBDUFBfRExfRVJST1IsCisJCQkgICAiU09VUkNFX0RB VEVfRVBPQ0g9XCIlc1wiIGlzIG5vdCBhIHZhbGlkIG51bWJlciIsCisJCQkg ICBzb3VyY2VfZGF0ZV9lcG9jaCk7CisJICAgIH0KKwkgIGVsc2UKKwkgICAg eworCSAgICAvKiAodGltZV90KSAtMSBpcyBhIGxlZ2l0aW1hdGUgdmFsdWUg Zm9yICJudW1iZXIgb2Ygc2Vjb25kcworCSAgICAgICBzaW5jZSB0aGUgRXBv Y2giLCBzbyB3ZSBoYXZlIHRvIGRvIGEgbGl0dGxlIGRhbmNlIHRvCisJICAg ICAgIGRpc3Rpbmd1aXNoIHRoYXQgZnJvbSBhIGdlbnVpbmUgZXJyb3IuICAq LworCSAgICBlcnJubyA9IDA7CisJICAgIHR0ID0gdGltZShOVUxMKTsKKwkg ICAgaWYgKHR0ICE9ICh0aW1lX3QpLTEgfHwgZXJybm8gPT0gMCkKKwkgICAg ICB0YiA9IGxvY2FsdGltZSAoJnR0KTsKKwkgIH0KIAogCSAgaWYgKHRiKQog CSAgICB7Cg== --------------000809070007030506020005-- --ftwBhv9HQ17hlT2FmMTbM25eRmFieQLqP Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" Content-length: 836 -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAEBAgAGBQJVkpcnAAoJEE+kV6GFFMxjzU0P/jPW6RuyR7OQM0PHScFOeFgG OjI9h0scscaqIhDcYxCj9FoiZ9lcQ0kdfAN074E07V9pbJvIiS2TNXQ81RwxAOqS eDovIrjbkNE6J/Ozvt7j8LowFpAGDW9GWB2qp/MmDKq1V4Exz+LbMCoy7kOnJaG1 2QI3ux0jjB4igLqkg5rAlQGPlZg3ieiEPICAIANjrvD1v2ji7BBrXA2yjeOeT7M1 B+2zxeMasd1gERDN57iDyxvx/8Rgx0eIH0hG+s3WM1LesCMuBP7fqG17/vAWwSBb YG+8KmBVCyr54TGKRxsSF3zfjH7VWx+lP0LVPsRvFzt559YNBnwW8t7Nm5j2Aac5 1NMB25FzD0e4+xA82DWaumPfZfRJjhYZtYoY8HjGVHpTC1qJ5tWMDctQSfv0diXI BpDbDoRSkXvkVRBuTeN973VSAaKSv/UDJeDiRYiAYs9dwGMBNc9R1p/lZ7LCyaF1 kOmy4gWxw1fBJtZe133x4r+sSgoN1aDcilB93UFkiR/U1X05n+lerAenqS3Slw+O DltC3cUvkY9U0yrYl0PUN0lT37G4VAB6ZwgwlwFwJj6+SbL7eTtTTP2HbQXjjdAO o74del8UtY2AZKlNq4CSCc8TeLGYT3enafYs4xA1YTXe29/YCPSjw5d5CsP/jKAa ym1u9e+lQQkiMY80ywcp =RZty -----END PGP SIGNATURE----- --ftwBhv9HQ17hlT2FmMTbM25eRmFieQLqP--