Make the build of extensions reproducible#2481
Conversation
The mkmf.log file can contain name of temporary files used at build time which makes the extension build non reproducible [1]. So, this file has to be removed at package installation. The generated (by the mkmf library) Makefile contains the `mkmf.log` file in the `distclean` target, but it considers the file is in the build directory while it has been moved to the installation dir. This patch just deletes this file moving in order to be able to distclean it. [1] https://reproducible-builds.org/
|
Tests are failing because they are checking the existence of the files deleted by this PR:/ I would prefer to wait for feedback before fixing these tests. |
|
Can you try to add a test for making extension builds “reproducible”, as well as documenting what exactly that means? |
This removes files generated at build time that are no longer required. The main purposes is to allow reproducible build but this also saves disk space. Indeed, the `Makefile` and `mkmf.log` are not reproducbile since they contain temporary filepaths.
The Makefile output can still be viewed when the `verbose` flag is enable.
|
Basically, a build is reproducible if the build process always creates the same result from the same source code. https://reproducible-builds.org/ is providing more (and better) explanations. I don't have any experience with Ruby so it's really time consuming for me to write a test;( But a test for this PR should
I started to make current tests working. |
|
Thanks for your work on this.
I'm not sure if there's agreement on what the meaning of 'the same result' is. If one looks at https://reproducible-builds.org/docs/definition/ the critical phrase is 'any party can recreate bit-by-bit identical copies of all specified artifacts' In addition - 'The artifacts of a build are the parts of the build results that are the desired primary output.' A packaged gem (which is a single file) should be reproducible. As to a 'gem install', I'm not sure if files like mkmf.log, gem_make.out, and Makefile would be considered 'primary output' or 'specified artifacts'... |
|
@MSP-Greg The point is distributions (at least ArchLinux and NixOS) are using Also, the |
|
So, the assumption here is that an external application is determining whether a gem install is correct by essentially hashing every file/folder created by If so, and given that the 'byproducts / non-primary output / non-runtime' files may be helpful for some users, should a option be added to |
This is how you compare two builds - of the same gem - to know if it it is reproducible. Regarding opt-in/opt-out, by default, the output of gem install should be reproducible. A flag such as |
|
I think
Since As long as there's an option, I think it's a good idea... |
Sorry, I was not enough clear! I was talking from the distribution packager point of view: when a distribution builds a ruby package, it uses I don't understand why we should add a |
We're changing previous behavior by deleting these files that are a byproduct of compiling, which I'm okay with. If a user finds an issue with installing a gem with a particular OS/compiler, having these files may be helpful. Hence, the |
|
@MSP-Greg In the use case you are talking about (debugging an issue), the |
|
I never approve your current approach for supporting the reproducible build. Because of this makes difficult to break the compatiblity. Please consider to store existed logs to new or other directory. |
|
No feedback with a couple of weeks. Please open another pull-request in the next time. |
|
mkmf.log files are for development purpose. |
Description:
When a package contains extension, the build is not reproducible due to temporary filepaths in some files which are not required at run time. This PR removes all of these files to make the build reproducible (https://reproducible-builds.org).
This PR has been tested on several gems, such as
msgpack,strptime,yajl-rubyand all fluentd ruby dependencies.See also the issue https://bugs.ruby-lang.org/issues/15304.
cc @nobu
Tasks:
I will abide by the code of conduct.