This is an archive of the discontinued LLVM Phabricator instance.

[gn build] Make build fully deterministic
Needs ReviewPublic

Authored by thakis on Feb 10 2020, 6:53 PM.

Details

Reviewers
phosek
rnk
Summary

This follows http://blog.llvm.org/2019/11/deterministic-builds-with-clang-and-lld.html
after ead0b76382a5a to make the GN build fully deterministic, instead of just locally
deterministic.

Getting a fully deterministic build requires some configuration and setup. See
llvm/utils/gn/docs/deterministic.md for details.

With this, I've built lld at two different build paths on my Windows box and got
identical binaries. (I'd expect the same to happen on Linux, and with other
binaries.)

This is not 100% complete yet. A few absolute include paths need to become sysroot-relative
if a sysroot is in use (there are FIXMEs for this), and the sysroot setup is a pain.

I'm sending this out for early feedback. Maybe I should put the sysroot bits in a separate
patch and land only the rest first.

Diff Detail

Event Timeline

thakis created this revision.Feb 10 2020, 6:53 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 10 2020, 6:53 PM
rnk added inline comments.Feb 11 2020, 10:54 AM
llvm/utils/gn/build/BUILD.gn
21

Can this be shortened to use_relative_paths_in_debug_info? It seems descriptive enough. Are there non-deterministic relative paths?

llvm/utils/gn/docs/deterministic.md
25

I was going to ask about this, but I think I agree it should be future work after a second individual has replicated your results manually. :)

71

One thing to note is that if this points at the main MSVC installation, the link may become stale. The Visual Studio updater deletes old MSVC versions and adds new ones in a newly versioned directory. We may eventually want a script that detects the stale junctions and repoints them to the current installation.

thakis marked an inline comment as done.

Thanks for taking a look!

llvm/utils/gn/build/BUILD.gn
21

Done. I pulled the non-sysroot bits into D74519 which has fewer fixmes and is ready to land today. I'll rebase this on top of D74519 once D74519 is in.

phosek added inline comments.Feb 12 2020, 6:32 PM
llvm/utils/gn/docs/deterministic.md
27

I've build a tool for creating Debian-based sysroots that we use in Fuchsia, it's a single Go file plus YAML file that's used to describe what you want in your sysroot: https://fuchsia.googlesource.com/fuchsia/+/refs/heads/master/tools/debroot/cmd/, this might be useful in case people want to create their own sysroot and don't want to do it by hand.

thakis updated this revision to Diff 247903.Mar 3 2020, 7:45 AM

rebase (but still incomplete)

thakis edited the summary of this revision. (Show Details)Mar 3 2020, 7:47 AM
thakis edited the summary of this revision. (Show Details)