erlyaws / yaws

Yaws webserver
https://erlyaws.github.io
BSD 3-Clause "New" or "Revised" License
1.28k stars 267 forks source link

Create a deterministic build environment #448

Closed avtobiff closed 2 years ago

avtobiff commented 2 years ago

This commit creates a deterministic build environment, which enables reproducible builds.

See #446

avtobiff commented 2 years ago

mime_types_SUITE.erl needs work.

avtobiff commented 2 years ago

It would be better to handle +deterministic via configure.ac, and that would have the added benefit of also allowing an --enable-deterministic-build option to configure. This patch supports this new option while also still handling the YAWS_DETERMINISTIC_BUILD env var:

Great!

+DEBUGINFO_OR_DETERMINISTIC= +if test "x${YAWS_DETERMINISTIC_BUILD}" = "x"; then

  • DEBUGINFO_OR_DETERMINISTIC=+debug_info +else
  • DEBUGINFO_OR_DETERMINISTIC=+deterministic +fi

Is there no use case where one would like to build with both +deterministic and +debug_info? Maybe they implicitly are mutually exclusive?

Furthermore, should --enable-deterministic-build also set

YAWS_DETERMINISTIC_BUILD=true
SOURCE_DATE_EPOCH=$(date +%s)

Perhaps SOURCE_DATE_EPOCH could be set implicitly by --enable-deterministic-build, but another configure option can be introduced to set it explicitly e.g. --source-date-epoch. It should still be overridable from the environment though.

With this patch, I think changes to examples/src/Makefile.am and examples/src/erlc_flags.mk aren't needed.

Yeah, I know it is hacky; but I don't really know autotools...

Out of curiousity, you don't happen to know why make -C testsuites break with two successive runs if +deterministic is used? I'm guessing that the make dependency files (.Pbeam) maybe don't include enough data to build a proper dependency graph.

avtobiff commented 2 years ago

With the last commit diffoscope reports only different timestamps of the installed files, when building make all doc apps.

Please review.

Fixing mime_types_SUITE is still needed.

When the tests pass and the review is approved I'll squash and write a proper commit message.

avtobiff commented 2 years ago

This PR is ready for final review.

vinoski commented 2 years ago

I'm still working on reviewing this, thanks for your patience.

vinoski commented 2 years ago

I modified this a bit, and rebased it to master. Thanks!