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

Instable member order in _index cause nvc build to be non-reproducible #409

Closed
daym opened this issue Dec 16, 2020 · 3 comments
Closed

Instable member order in _index cause nvc build to be non-reproducible #409

daym opened this issue Dec 16, 2020 · 3 comments

Comments

@daym
Copy link

daym commented Dec 16, 2020

We're trying to package nvc in the GNU Guix distribution.

Unfortunately, timestamps in _index files cause the nvc build to be non-reproducible (see https://reproducible-builds.org/ for why reproducibility is important).

We've tracked it down to writing out the timestamp of the "design unit" files. If the source files are compiled, then the mtime timestamp of the design unit file is the time stamp of the system at time of that compilation process. Therefore, if someone else compiles the same thing, the timestamp is likely be different (compilation probably doesn't always take the same time), making the entire build of nvc non-reproducible (and diffoscope will flag the _index files as the culprit).

It would be nice to make the build of the nvc library reproducible somehow.

For example, it could be useful to set the design unit file mtime to the source file mtime on compilation.

See also https://reproducible-builds.org/docs/source-date-epoch/ and https://wiki.debian.org/ReproducibleBuilds/StandardEnvironmentVariables

@nickg
Copy link
Owner

nickg commented Dec 17, 2020

The timestamp is not actually stored in the file: it's read each time the design unit is loaded with stat(2) - see lib_get_aux() in src/lib.c.

The _index file is sensitive to to the order files were compiled in. Are you building with make -j? Does it make a difference if you don't use -j? I think that could be fixed by storing the entries in the _index file in sorted order.

@daym
Copy link
Author

daym commented Dec 17, 2020

Oh! That's good news!

Indeed, it's reproducible when disabling parallel builds.

Thank you.

@daym daym changed the title Timestamps in _index cause nvc build to be non-reproducible Instable member order in _index cause nvc build to be non-reproducible Dec 17, 2020
@nickg nickg closed this as completed in e37c73d Dec 17, 2020
@nickg
Copy link
Owner

nickg commented Dec 17, 2020

Should be fixed by the above commit. I did a few rounds of make clean-libs && make -j && sha1sum lib/ieee/_index and it always gets the same hash.

nickg added a commit that referenced this issue Apr 9, 2021
Also fixed a few other potential errors or non-deterministic behaviour
when building libraries in parallel.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants