Project

General

Profile

Actions

Feature #2828

closed

Reproducible builds

Added by stbuehler over 6 years ago. Updated over 6 years ago.

Status:
Fixed
Priority:
Normal
Category:
core
Target version:
ASK QUESTIONS IN Forums:

Description

Using __DATE__ and __TIME__ macros in C leads to non-reproducible builds (goal: create the exact same files when run in the same environment again).

lighttpd.spec shows how opensuse patches the sources to replace those macros with a timestamp from their changelog.

I would be nice to offer a cleaner API here (or maybe simply (optionally) remove the timestamp completely).

Otoh it seems more recent gcc versions might support SOURCE_DATE_EPOCH.

Actions #1

Updated by gstrauss over 6 years ago

In lighttpd's case, I'd be fine with removing DATE and TIME from server.c, where this info is used only for display when showing version (lighttpd -v) or showing help (lighttpd -h) For most people, installing the package would already have package build info in package database. For those building from source, the timestamps on the lighttpd executable would probably suffice for "when was this built?" as long as timestamp was preserved when installed out of the build area.

FYI: I wrote a multi-platform set of macros that stores ident information in the .comment section of the binary, instead of in .data.
https://github.com/gstrauss/plasma/blob/master/plasma_ident.h
This separate section could be separated from the binary after the build and stored separately in a database, keyed by a checksum of the binary after the .comment section has been removed.

Actions #2

Updated by gstrauss over 6 years ago

--- a/src/server.c
+++ b/src/server.c
@@ -538,8 +538,10 @@ static int server_oneshot_init(server *srv, int fd) {

 static void show_version (void) {
        char *b = PACKAGE_DESC TEXT_SSL \
-" - a light and fast webserver\n" \
+" - a light and fast webserver\n" 
+#ifdef NONREPRODUCIBLE_BUILD
 "Build-Date: " __DATE__ " " __TIME__ "\n";
+#endif
 ;
        write_all(STDOUT_FILENO, b, strlen(b));
 }
@@ -705,7 +707,10 @@ static void show_features (void) {
 }

 static void show_help (void) {
-       char *b = PACKAGE_DESC TEXT_SSL " ("__DATE__ " " __TIME__ ")" \
+       char *b = PACKAGE_DESC TEXT_SSL
+#ifdef NONREPRODUCIBLE_BUILD
+" ("__DATE__ " " __TIME__ ")" 
+#endif
 " - a light and fast webserver\n" \
 "usage:\n" \
 " -f <name>  filename of the config-file\n" \
Actions #3

Updated by gstrauss over 6 years ago

  • Category set to core
  • Status changed from New to Patch Pending
  • Target version changed from 1.4.x to 1.4.46
Actions #4

Updated by gstrauss over 6 years ago

  • Status changed from Patch Pending to Fixed
  • % Done changed from 0 to 100
Actions

Also available in: Atom