Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for deterministic build #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,22 @@ and those parameters may be combined with

> make DESTDIR=/my/staging/area install

Reproducible builds
-------------------

It is possible to build Lux deterministically, thus enabling
reproducible builds.

By configuring the build with the `--enable-deterministic-build` option
the erlc flag `+deterministic` replaces the `+debug_info` erlc flag to
generate deterministic beam files. Additionally the `runpty` program is
stripped from non-deterministic content. After the configuration build
normally, e.g.

> autoconf
> ./configure --enable-deterministic-build
> make

Standalone installation
-----------------------

Expand Down
4 changes: 4 additions & 0 deletions c_src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ trace:

$(PROG): runpty.c
$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $<
ifeq ($(STRIP_RUNPTY), true)
strip $(PROG)
strip --remove-section=.note.gnu.build-id $(PROG)
endif

clean:
rm -rf $(PROG) ../priv/bin/runpty.dSYM core* *~
Expand Down
15 changes: 15 additions & 0 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,21 @@ if test "x$ERLC" = "xno"; then
AC_MSG_ERROR([erlc: command not found])
fi

AC_ARG_ENABLE(deterministic_build,
AS_HELP_STRING([--enable-deterministic-build],
[enable deterministic build,
add +deterministic remove +debug_info]))

DEBUGINFO_OR_DETERMINISTIC=+debug_info
STRIP_RUNPTY=
if test "x$enable_deterministic_build" = "xyes"; then
DEBUGINFO_OR_DETERMINISTIC=+deterministic
STRIP_RUNPTY=true
fi

AC_SUBST(DEBUGINFO_OR_DETERMINISTIC)
AC_SUBST(STRIP_RUNPTY)

################################################################################
# Doc

Expand Down
3 changes: 2 additions & 1 deletion include.mk.in
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,14 @@ LUX=$(APP_DIR)/bin/lux
ERL="@ERL@"
ERLC="@ERLC@"
EMULATOR=beam
ERLC_FLAGS += +warnings_as_errors +warn_unused_vars +debug_info
ERLC_FLAGS += +warnings_as_errors +warn_unused_vars @DEBUGINFO_OR_DETERMINISTIC@

# C
CC=@CC@
CFLAGS=@CFLAGS@
LDFLAGS=@LDFLAGS@
C_SRC_TARGET=@C_SRC_TARGET@
STRIP_RUNPTY=@STRIP_RUNPTY@

# Doc
MARKDOWN=@MARKDOWN@
Expand Down