|
93 | 93 | shell: bash
|
94 | 94 | run: bazelisk version
|
95 | 95 |
|
| 96 | + # Bazel has multiple Xcode calls with hardcoded timeouts. Many of these |
| 97 | + # end up timing out on our github runners, causing flakes on every mac |
| 98 | + # build that invoked Bazel. To work around this, we manually inoke these |
| 99 | + # calls before running Bazel to make sure they end up in Xcode's cache for |
| 100 | + # quicker runs later. All of these calls are obtained from xcrun calls in |
| 101 | + # https://github.com/bazelbuild/bazel/blob/e8a69f5d5acaeb6af760631490ecbf73e8a04eeb/tools/cpp/osx_cc_configure.bzl. |
| 102 | + # See https://github.com/bazelbuild/bazel/issues/17437 for more details. |
| 103 | + # TODO(b/269503614) Remove this once Bazel provides an official solution. |
| 104 | + - name: Warm up Xcode |
| 105 | + if: ${{ runner.os == 'macOS' }} |
| 106 | + shell: bash |
| 107 | + run: | |
| 108 | + mkdir -p mac_bazel_workaround |
| 109 | + bazelisk ${{ steps.bazel.outputs.bazel-startup-flags }} build @bazel_tools//tools/osx:xcode_locator.m $BAZEL_FLAGS |
| 110 | + XCODE_LOCATOR_FLAGS="--sdk macosx clang -mmacosx-version-min=10.9 -fobjc-arc -framework CoreServices -framework Foundation" |
| 111 | + SINGLE_ARCH_COMPILE_FLAGS="--sdk macosx clang -mmacosx-version-min=10.9 -std=c++11 -lc++ -O3" |
| 112 | + COMPILE_FLAGS="$SINGLE_ARCH_COMPILE_FLAGS -arch arm64 -arch x86_64 -Wl,-no_adhoc_codesign -Wl,-no_uuid -O3" |
| 113 | + time env -i DEVELOPER_DIR=$DEVELOPER_DIR xcrun $XCODE_LOCATOR_FLAGS -o mac_bazel_workaround/xcode-locator-bin $(bazel info output_base)/external/bazel_tools/tools/osx/xcode_locator.m |
| 114 | + time env -i DEVELOPER_DIR=$DEVELOPER_DIR xcrun $SINGLE_ARCH_COMPILE_FLAGS -o mac_bazel_workaround/libtool_check_unique $(bazel info output_base)/external/bazel_tools/tools/objc/libtool_check_unique.cc |
| 115 | + time env -i DEVELOPER_DIR=$DEVELOPER_DIR xcrun $COMPILE_FLAGS -o mac_bazel_workaround/libtool_check_unique $(bazel info output_base)/external/bazel_tools/tools/objc/libtool_check_unique.cc |
| 116 | + time env -i DEVELOPER_DIR=$DEVELOPER_DIR xcrun $SINGLE_ARCH_COMPILE_FLAGS -o mac_bazel_workaround/wrapped_clang $(bazel info output_base)/external/bazel_tools/tools/osx/crosstool/wrapped_clang.cc |
| 117 | + time env -i DEVELOPER_DIR=$DEVELOPER_DIR xcrun $COMPILE_FLAGS -o mac_bazel_workaround/wrapped_clang $(bazel info output_base)/external/bazel_tools/tools/osx/crosstool/wrapped_clang.cc |
| 118 | +
|
96 | 119 | - name: Run Bash
|
97 | 120 | if: ${{ inputs.bash }}
|
98 | 121 | run: ${{ inputs.bash }}
|
|
0 commit comments