-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rules_r: reproducible builds on demand
Summary: Best effort feature to produce files with identical checksum on successive builds. Activated with --features=rlang-reproducible. These are slightly more expensive and are more complex because of the need to have the same src and install paths. And depends on the compiler's willingness to produce reproducible .so files. Known to not work on macOS where the .o files can be at different positions within the .so, and on packages with C++ cc_deps. Reviewers: razvanm Reviewed By: razvanm Differential Revision: https://phabricator.grailbio.com/D12645 fbshipit-source-id: fadd8e5
- Loading branch information
Siddhartha Bagaria
authored and
grailbot
committed
Apr 17, 2018
1 parent
dafe01d
commit 5bb812b
Showing
6 changed files
with
156 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ addons: | |
|
||
script: | ||
- tests/run_tests.sh | ||
- tests/run_reproducible_build_tests.sh |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright 2018 The Bazel Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
// Uses the given file descriptor to acquire an exclusive non-blocking lock. | ||
|
||
// The lock is released when the file descriptor is closed, i.e. when the | ||
// parent process that opened the corresponding file is terminated for any | ||
// reason. A SIGKILL to the parent process might have a delay of a few | ||
// seconds, but everything else is instantaneous. | ||
|
||
#include <errno.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <sys/file.h> | ||
|
||
int main(int argc, char** argv) { | ||
int fd; | ||
|
||
if (argc != 2) { | ||
fprintf(stderr, "Usage: %s [fd]\n", argv[0]); | ||
exit(EXIT_FAILURE); | ||
} | ||
|
||
fd = (int)strtol(argv[1], (char**)NULL, 10); | ||
errno = 0; | ||
if (errno != 0) { | ||
perror("strtol"); | ||
exit(EXIT_FAILURE); | ||
} | ||
|
||
if (flock(fd, LOCK_EX | LOCK_NB)) { | ||
if (errno != EAGAIN) { | ||
perror("flock"); | ||
} | ||
exit(EXIT_FAILURE); | ||
} | ||
|
||
return 0; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
# Copyright 2018 The Bazel Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# Providing features invalidates cache; hence this test suite is separate. | ||
|
||
set -euxo pipefail | ||
|
||
cd "$(dirname "${BASH_SOURCE[0]}")" | ||
|
||
# Just to see if this mode builds. | ||
bazel build --features=rlang-reproducible :library_image |