Skip to content

Commit

Permalink
Bootstrapping: don't use convenience symlinks
Browse files Browse the repository at this point in the history
When `compile.sh` builds bazel using bazel, it
copies the resulting binary to `output/bazel`.
However sometimes the convenience symlink
`bazel-bin` is not created, probably because an
old one is still around and cannot be deleted.

That is clearly a bug, but to work around it, the
bootstrap builder shouldn't attempt to rely on the
creation of these symlinks in the first place.

This change updates compile.sh to use `bazel info`
to locate the `bazel-bin` directory's real path,
and attempt to copy the bazel binary from there.

This works around
bazelbuild#1827

--
MOS_MIGRATED_REVID=134398451
  • Loading branch information
laszlocsomor authored and meteorcloudy committed Sep 27, 2016
1 parent bb5901b commit 9f7180f
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 19 deletions.
9 changes: 7 additions & 2 deletions compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,13 @@ if [ $DO_COMPILE ]; then
new_step 'Building Bazel with Bazel'
display "."
log "Building output/bazel"
bazel_build "src:bazel${EXE_EXT}"
cp -f "bazel-bin/src/bazel${EXE_EXT}" "output/bazel${EXE_EXT}"
bazel_build "src:bazel${EXE_EXT}" \
|| fail "Could not build Bazel"
bazel_bin_path="$(get_bazel_bin_path)/src/bazel${EXE_EXT}"
[ -e "$bazel_bin_path" ] \
|| fail "Could not find freshly built Bazel binary at '$bazel_bin_path'"
cp -f "$bazel_bin_path" "output/bazel${EXE_EXT}" \
|| fail "Could not copy '$bazel_bin_path' to 'output/bazel${EXE_EXT}'"
chmod 0755 "output/bazel${EXE_EXT}"
BAZEL="$(pwd)/output/bazel${EXE_EXT}"
fi
Expand Down
33 changes: 20 additions & 13 deletions scripts/bootstrap/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,31 @@ else
fi

if [ -z "${BAZEL-}" ]; then
function bazel_build() {
bootstrap_build ${BAZEL_ARGS-} \
--verbose_failures \
--javacopt="-g -source ${JAVA_VERSION} -target ${JAVA_VERSION}" \
"${EMBED_LABEL_ARG[@]}" \
"${@}"
function run_bootstrapping_bazel() {
local command=$1
shift
run_bazel_jar $command \
${BAZEL_ARGS-} --verbose_failures \
--javacopt="-g -source ${JAVA_VERSION} -target ${JAVA_VERSION}" "${@}"
}
else
function bazel_build() {
${BAZEL} --bazelrc=${BAZELRC} ${BAZEL_DIR_STARTUP_OPTIONS} build \
${BAZEL_ARGS-} \
--verbose_failures \
--javacopt="-g -source ${JAVA_VERSION} -target ${JAVA_VERSION}" \
"${EMBED_LABEL_ARG[@]}" \
"${@}"
function run_bootstrapping_bazel() {
local command=$1
shift
${BAZEL} --bazelrc=${BAZELRC} ${BAZEL_DIR_STARTUP_OPTIONS} $command \
${BAZEL_ARGS-} --verbose_failures \
--javacopt="-g -source ${JAVA_VERSION} -target ${JAVA_VERSION}" "${@}"
}
fi

function bazel_build() {
run_bootstrapping_bazel build "${EMBED_LABEL_ARG[@]}" "$@"
}

function get_bazel_bin_path() {
run_bootstrapping_bazel info "bazel-bin" || echo "bazel-bin"
}

function md5_outputs() {
[ -n "${BAZEL_TEST_XTRACE:-}" ] && set +x # Avoid garbage in the output
# runfiles/MANIFEST & runfiles_manifest contain absolute path, ignore.
Expand Down
2 changes: 1 addition & 1 deletion scripts/bootstrap/buildenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ function fail() {
exitCode=1
fi
echo >&2
echo "$@" >&2
echo "ERROR: $@" >&2
exit $exitCode
}

Expand Down
7 changes: 4 additions & 3 deletions scripts/bootstrap/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,9 @@ else
cp tools/osx/xcode_locator_stub.sh ${ARCHIVE_DIR}/_embedded_binaries/xcode-locator
fi

# bazel build using bootstrap version
function bootstrap_build() {
function run_bazel_jar() {
local command=$1
shift
"${JAVA_HOME}/bin/java" \
-XX:+HeapDumpOnOutOfMemoryError -Xverify:none -Dfile.encoding=ISO-8859-1 \
-XX:HeapDumpPath=${OUTPUT_DIR} \
Expand All @@ -319,7 +320,7 @@ function bootstrap_build() {
--nofatal_event_bus_exceptions \
${BAZEL_DIR_STARTUP_OPTIONS} \
${BAZEL_BOOTSTRAP_STARTUP_OPTIONS:-} \
build \
$command \
--ignore_unsupported_sandboxing \
--startup_time=329 --extract_data_time=523 \
--rc_source=/dev/null --isatty=1 \
Expand Down

0 comments on commit 9f7180f

Please sign in to comment.