Repository navigation
fix(elixir_bytecode): store relative source paths in beam files - #6
Open
TrapsterDK wants to merge 1 commit into
Open
TrapsterDK wants to merge 1 commit into
TrapsterDK wants to merge 1 commit into
Conversation
elixirc expands every source to an absolute path, and the path lands in the Dbgi and Docs chunks of each module. The path holds the sandbox directory, so the same sources produce different beam files in different sandboxes or checkouts, which breaks reproducible builds and remote cache sharing. Rewrite both paths relative to the execroot after elixirc runs, and compile with ERL_COMPILER_OPTIONS=deterministic to keep the source path and compile options out of the CInf chunk. Add beam_paths_test, which reads the chunks of a compiled module. Signed-off-by: Martin Kuntz Jacobsen <martin.kuntz.jacobsen@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
elixircexpands every source to an absolute path, and that path is stored in the debug info (Dbgi) and docs (Docs) chunks of each.beam. The path contains the sandbox directory, so the same sources give different beam files in different sandboxes or checkouts. Builds are not reproducible and remote cache entries are not shared across machines. The compile info (CInf) chunk also records the source path and compile options.Repro: build any
elixir_app, then read theDbgichunk of a beam (:beam_lib.chunks(beam, [:debug_info])).fileis an absolute path inside the sandbox.Change
ERL_COMPILER_OPTIONS=deterministic, which keeps the source path and options out ofCInf. It is exported beforeenv, so a target can still override it.elixircfinishes, rewriteDbgifileandDocssource_pathof every beam in the output directory to be relative to the execroot.Fixedentry toCHANGELOG.md.Issues are disabled on this repository, so there is no linked issue.
Test
test/beam_paths_test.sh(//:beam_paths_test) reads the chunks of the compiledBasicmodule and fails ifDbgiorDocsholds an absolute path orCInfhas asourceentry. It runs withbazel test //...intest/, likeescript_test.I could not run Bazel or Elixir on the machine used to prepare this, so the change and test are not run locally. CI is the first run.
Assisted by Claude.