Skip to content

Commit

Permalink
Bump minimum supported macOS versions to 10.13
Browse files Browse the repository at this point in the history
As per https://developer.apple.com/support/xcode/ Xcode from 14.0 no longer supports targeting 10.9, and attempting to do so may fail in obscure ways.

10.13 is still 5+ years old, so we retain coverage for a reasonable range on macOS versions.

Closes bazelbuild#17451.

PiperOrigin-RevId: 511577111
Change-Id: I770ff101f52d16f2fc402f054579740b650986cc
  • Loading branch information
illicitonion authored and ShreeM01 committed Apr 11, 2023
1 parent ad6d3d5 commit 9ab3aba
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 5 deletions.
2 changes: 1 addition & 1 deletion scripts/bootstrap/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ cp $OUTPUT_DIR/libblaze.jar ${ARCHIVE_DIR}
# TODO(b/28965185): Remove when xcode-locator is no longer required in embedded_binaries.
log "Compiling xcode-locator..."
if [[ $PLATFORM == "darwin" ]]; then
run /usr/bin/xcrun --sdk macosx clang -mmacosx-version-min=10.9 -fobjc-arc -framework CoreServices -framework Foundation -o ${ARCHIVE_DIR}/xcode-locator tools/osx/xcode_locator.m
run /usr/bin/xcrun --sdk macosx clang -mmacosx-version-min=10.13 -fobjc-arc -framework CoreServices -framework Foundation -o ${ARCHIVE_DIR}/xcode-locator tools/osx/xcode_locator.m
else
cp tools/osx/xcode_locator_stub.sh ${ARCHIVE_DIR}/xcode-locator
fi
Expand Down
53 changes: 52 additions & 1 deletion tools/cpp/osx_cc_configure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def _compile_cc_file(repository_ctx, src_name, out_name):
"--sdk",
"macosx",
"clang",
"-mmacosx-version-min=10.9",
"-mmacosx-version-min=10.13",
"-std=c++11",
"-lc++",
"-O3",
Expand All @@ -83,6 +83,57 @@ def _compile_cc_file(repository_ctx, src_name, out_name):
"https://github.com/bazelbuild/bazel/issues with the following:\n" +
error_msg)

def _compile_cc_file(repository_ctx, src_name, out_name, timeout):
env = repository_ctx.os.environ
xcrun_result = repository_ctx.execute([
"env",
"-i",
"DEVELOPER_DIR={}".format(env.get("DEVELOPER_DIR", default = "")),
"xcrun",
"--sdk",
"macosx",
"clang",
"-mmacosx-version-min=10.13",
"-std=c++11",
"-lc++",
"-arch",
"arm64",
"-arch",
"x86_64",
"-Wl,-no_adhoc_codesign",
"-Wl,-no_uuid",
"-O3",
"-o",
out_name,
src_name,
], timeout)

if xcrun_result.return_code == 0:
xcrun_result = repository_ctx.execute([
"env",
"-i",
"codesign",
"--identifier", # Required to be reproducible across archs
out_name,
"--force",
"--sign",
"-",
out_name,
], timeout)
if xcrun_result.return_code != 0:
error_msg = (
"codesign return code {code}, stderr: {err}, stdout: {out}"
).format(
code = xcrun_result.return_code,
err = xcrun_result.stderr,
out = xcrun_result.stdout,
)
fail(out_name + " failed to generate. Please file an issue at " +
"https://github.com/bazelbuild/bazel/issues with the following:\n" +
error_msg)
else:
_compile_cc_file_single_arch(repository_ctx, src_name, out_name, timeout)

def configure_osx_toolchain(repository_ctx, cpu_value, overriden_tools):
"""Configure C++ toolchain on macOS.
Expand Down
5 changes: 3 additions & 2 deletions tools/osx/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ exports_files([
])

DARWIN_XCODE_LOCATOR_COMPILE_COMMAND = """
/usr/bin/xcrun --sdk macosx clang -mmacosx-version-min=10.9 -fobjc-arc -framework CoreServices \
-framework Foundation -o $@ $<
/usr/bin/xcrun --sdk macosx clang -mmacosx-version-min=10.13 -fobjc-arc -framework CoreServices \
-framework Foundation -arch arm64 -arch x86_64 -Wl,-no_adhoc_codesign -Wl,-no_uuid -o $@ $< && \
env -i codesign --identifier $@ --force --sign - $@
"""

genrule(
Expand Down
2 changes: 1 addition & 1 deletion tools/osx/xcode_configure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def run_xcode_locator(repository_ctx, xcode_locator_src_label):
"--sdk",
"macosx",
"clang",
"-mmacosx-version-min=10.9",
"-mmacosx-version-min=10.13",
"-fobjc-arc",
"-framework",
"CoreServices",
Expand Down

0 comments on commit 9ab3aba

Please sign in to comment.