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

Fixes and tests for reproducibility #1580

Merged
merged 2 commits into from
Jul 3, 2018

Conversation

siddharthab
Copy link
Contributor

@siddharthab siddharthab commented Jul 1, 2018

Includes a reproducibility test in travis, that will test if stdlib and binaries with cgo are reproducible across multiple builds by the same user. This still does not test if the binaries are reproducible across multiple users or machines. I am relying on tests/legacy/reproducible_binary to check that.

There are two fixes included here:

  1. Supplying -fdebug-prefix-map to C compiler invocations for cgo.
  2. Stripping temp dir path from generated src files (*.cgo2.c).

Resolves #1518.
Resolves #1547.

@siddharthab
Copy link
Contributor Author

You can see that the test fails in the first travis run because the PR did not have the commit for the fixes for that run. The second travis run which includes the commit for the fixes passes.

Please ignore the main bazel test run failure in the first travis run. I accidentally deleted a line in the travis config which led to command line parsing errors.

Copy link
Contributor

@jayconrod jayconrod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but I'd like to request some changes in the test. Thanks for working on this!

.travis.yml Outdated
@@ -58,6 +58,8 @@ script:
--local_resources=400,1,1.0 \
--test_tag_filters=-dev \
//...
- tests/core/reproducibility/test.sh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like you to migrate the test to something that can be run through bazel test //.... We used to have a number of tests that were run with bash, and I don't want to go back to those days.

I think you may be able to express this as an sh_test. Make sure to use size = "large", timeout = "moderate", and tags = ["local", "bazel", "exclusive"]. If you can reuse some of the infrastructure in tests/bazel_tests.bzl, please do. I don't think you'll be able to use bazel_test directly though, since it's designed for verifying the result of a single bazel command.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking into it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

)
build_opts=()

if [[ $(uname -s) == "Linux" ]]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to leave this flag out to keep the test simpler, even if it speeds up the tests. This will probably eventually be the default.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

build_opts+=("--experimental_sandbox_base=/dev/shm")
fi

bazel "${bazel_opts[@]}" build "${build_opts[@]+"${build_opts[@]}"}" \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not familiar with the syntax for expanding build_opts here. Can it just be "${build_opts[@]}"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now removed, so no longer applicable. But the main reason was that empty arrays are considered unset in most bash versions. This will trigger the trap in set -u and the script fails. The syntax I had is the alternative value mechanism.
http://wiki.bash-hackers.org/syntax/pe#use_an_alternate_value

set -eu -o pipefail

function run_bazel() {
local output_base
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assigning "$1" to another local here would improve readability.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

fi

bazel "${bazel_opts[@]}" build "${build_opts[@]+"${build_opts[@]}"}" \
//tests/core/go_binary:all \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to test against targets in this directory instead of elsewhere. //tests/core/go_binary:all may pick up some unexpected things, depending on what we put in there in the future. It's better for this test to be isolated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright. I will create some binary with cgo here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@steeve
Copy link
Contributor

steeve commented Jul 2, 2018

This looks great! I thought I catched them all earlier but it looks like that wasn't the case!

@siddharthab
Copy link
Contributor Author

I have addressed all current comments. I also reorganized the commits so that I could run the new tests without the fixes and see how they fail.

@siddharthab siddharthab force-pushed the repro branch 2 times, most recently from 1be1596 to 56cd957 Compare July 3, 2018 06:31
@siddharthab
Copy link
Contributor Author

Two more commits to make the tests pass and some hygiene.

@siddharthab
Copy link
Contributor Author

Reorganize commits again and use bundled md5sum because macOS travis image does not have md5sum.

@siddharthab
Copy link
Contributor Author

Travis test failures are unrelated.

Copy link
Contributor

@jayconrod jayconrod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks! In the future, I think we might need more infrastructure for running tests like this, but this is good for now.

Again, thank you for working on this.

@jayconrod jayconrod merged commit ea45df1 into bazel-contrib:master Jul 3, 2018
@siddharthab siddharthab deleted the repro branch July 3, 2018 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Builds not reproducible with cgo (?) Absolute paths from stdlib are embedded in the binary
4 participants