From 9e0e7f24ea56936aca5298829f2f7d5d9bbe7eee Mon Sep 17 00:00:00 2001 From: Matthew LeVan <91502660+matthew-levan@users.noreply.github.com> Date: Mon, 9 Jan 2023 13:05:24 -0500 Subject: [PATCH] Build with `bazel` on `darwin-x86_64` (#18) --- BUILD.bazel | 21 +- README.md | 10 + WORKSPACE.bazel | 1 + bazel/third_party/curl/curl.BUILD | 5 +- bazel/third_party/gmp/gmp.BUILD | 8 +- bazel/third_party/openssl/openssl.BUILD | 5 +- bazel/third_party/secp256k1/secp256k1.BUILD | 5 +- bazel/third_party/sigsegv/sigsegv.BUILD | 5 +- bazel/third_party/softfloat/softfloat.BUILD | 361 +------------------- bazel/third_party/uv/uv.BUILD | 5 +- bazel/third_party/zlib/zlib.BUILD | 5 +- bazel/toolchain/BUILD.bazel | 58 ++++ 12 files changed, 123 insertions(+), 366 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index ca71eeb12f..b119ffbdcc 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -157,6 +157,14 @@ platform( ], ) +platform( + name = "macos-arm64", + constraint_values = [ + "@platforms//os:macos", + "@platforms//cpu:arm64", + ], +) + platform( name = "clang-macos-arm64", constraint_values = [ @@ -167,10 +175,19 @@ platform( ) platform( - name = "macos-arm64", + name = "macos-x86_64", constraint_values = [ "@platforms//os:macos", - "@platforms//cpu:arm64", + "@platforms//cpu:x86_64", + ], +) + +platform( + name = "clang-macos-x86_64", + constraint_values = [ + ":clang", + "@platforms//os:macos", + "@platforms//cpu:x86_64", ], ) diff --git a/README.md b/README.md index f68cfc7a3a..988ba89b3c 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,14 @@ defined in its own package: - [`pkg/noun`](pkg/noun): The Nock virtual machine and snapshotting system. - [`pkg/vere`](pkg/vere): The I/O drivers, event log, and main event loop. +## Pre-requisites + +### macOS + +```console +$ brew install bazelisk automake libtool +``` + ## Build We use [`bazel`][bazel] to build Urbit's runtime, which is packaged as a single @@ -39,6 +47,8 @@ will run: `aarch64_linux_gnu_gcc-linux-x86_64` | `linux-arm64` | `aarch64-linux_gnu_gcc` `gcc-linux-x86_64` | `linux-x86_64` | `gcc` `clang-linux-x86_64` | `linux-x86_64` | `clang` + `clang-macos-arm64` | `macos-arm64` | `clang` + `clang-macos-x86_64` | `macos-x86_64` | `clang` Once you've identified your `(host, target)` pair, determine the version of the pair's required toolchain and ensure you have an up-to-date version of diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel index 6ecc1294a7..42549b5459 100644 --- a/WORKSPACE.bazel +++ b/WORKSPACE.bazel @@ -96,6 +96,7 @@ register_toolchains( "//bazel/toolchain:aarch64_linux_gnu_gcc-linux-x86_64-toolchain", "//bazel/toolchain:clang-linux-x86_64-toolchain", "//bazel/toolchain:clang-macos-arm64-toolchain", + "//bazel/toolchain:clang-macos-x86_64-toolchain", "//bazel/toolchain:gcc-linux-x86_64-toolchain", ) diff --git a/bazel/third_party/curl/curl.BUILD b/bazel/third_party/curl/curl.BUILD index 1b4df71662..c4be631cc4 100644 --- a/bazel/third_party/curl/curl.BUILD +++ b/bazel/third_party/curl/curl.BUILD @@ -8,7 +8,10 @@ filegroup( # TODO: check windows build. configure_make( name = "curl", - args = ["--jobs=`nproc`"], + args = select({ + "@platforms//os:macos": ["--jobs=`sysctl -n hw.logicalcpu`"], + "//conditions:default": ["--jobs=`nproc`"], + }), # We disable unneeded features. # TODO: double check that all disabled features below are in fact unneeded. configure_options = [ diff --git a/bazel/third_party/gmp/gmp.BUILD b/bazel/third_party/gmp/gmp.BUILD index 1ae0327b73..d04de1b107 100644 --- a/bazel/third_party/gmp/gmp.BUILD +++ b/bazel/third_party/gmp/gmp.BUILD @@ -8,9 +8,15 @@ filegroup( # TODO: check windows build. configure_make( name = "gmp", - args = ["--jobs=`nproc`"], + args = select({ + "@platforms//os:macos": ["--jobs=`sysctl -n hw.logicalcpu`"], + "//conditions:default": ["--jobs=`nproc`"], + }), configure_options = [ "--disable-shared", + # NOTE: --with-pic is required to build PIE binaries on macos_x86_64, + # but we leave it in for all builds as a precaution. + "--with-pic", ] + select({ # Native compilation on linux-arm64 isn't supported. "@//:linux_arm64": ["--host=aarch64-linux-gnu"], diff --git a/bazel/third_party/openssl/openssl.BUILD b/bazel/third_party/openssl/openssl.BUILD index 1e4a9b1db1..8d1f5742a3 100644 --- a/bazel/third_party/openssl/openssl.BUILD +++ b/bazel/third_party/openssl/openssl.BUILD @@ -8,7 +8,10 @@ filegroup( # TODO: use configure_make_variant() to select nmake toolchain on windows? configure_make( name = "openssl", - args = ["--jobs=`nproc`"], + args = select({ + "@platforms//os:macos": ["--jobs=`sysctl -n hw.logicalcpu`"], + "//conditions:default": ["--jobs=`nproc`"], + }), configure_command = select({ "@platforms//os:windows": "Configure", "@//:linux_arm64": "Configure", diff --git a/bazel/third_party/secp256k1/secp256k1.BUILD b/bazel/third_party/secp256k1/secp256k1.BUILD index da554ee4e8..9dc2533c79 100644 --- a/bazel/third_party/secp256k1/secp256k1.BUILD +++ b/bazel/third_party/secp256k1/secp256k1.BUILD @@ -7,7 +7,10 @@ filegroup( configure_make( name = "secp256k1", - args = ["--jobs=`nproc`"], + args = select({ + "@platforms//os:macos": ["--jobs=`sysctl -n hw.logicalcpu`"], + "//conditions:default": ["--jobs=`nproc`"], + }), autogen = True, configure_in_place = True, configure_options = [ diff --git a/bazel/third_party/sigsegv/sigsegv.BUILD b/bazel/third_party/sigsegv/sigsegv.BUILD index 31dfa32346..2362af35a4 100644 --- a/bazel/third_party/sigsegv/sigsegv.BUILD +++ b/bazel/third_party/sigsegv/sigsegv.BUILD @@ -7,7 +7,10 @@ filegroup( configure_make( name = "sigsegv", - args = ["--jobs=`nproc`"], + args = select({ + "@platforms//os:macos": ["--jobs=`sysctl -n hw.logicalcpu`"], + "//conditions:default": ["--jobs=`nproc`"], + }), configure_options = [ "--disable-shared", "--enable-static", diff --git a/bazel/third_party/softfloat/softfloat.BUILD b/bazel/third_party/softfloat/softfloat.BUILD index e3edb0596b..26f604184d 100644 --- a/bazel/third_party/softfloat/softfloat.BUILD +++ b/bazel/third_party/softfloat/softfloat.BUILD @@ -9,15 +9,14 @@ cc_library( name = "softfloat", visibility = ["//visibility:public"], deps = select({ - "@//:linux_arm64": [":softfloat_linux_arm64"], - "@//:linux_x86_64": [":softfloat_linux_x86_64"], - "@//:macos_arm64": ["softfloat_macos_arm64"], + "@platforms//cpu:arm64": [":softfloat_arm64"], + "@platforms//cpu:x86_64": [":softfloat_x86_64"], "//conditions:default": [], }), ) cc_library( - name = "softfloat_linux_arm64", + name = "softfloat_arm64", srcs = [ # See `OBJS_PRIMITIVES` in `build/Linux-ARM-VFPv2-GCC/Makefile` in the # `softfloat` repo. @@ -291,7 +290,7 @@ cc_library( ) cc_library( - name = "softfloat_linux_x86_64", + name = "softfloat_x86_64", srcs = [ # See `OBJS_PRIMITIVES` in `build/Linux-x86_64-GCC/Makefile` in the # `softfloat` repo. @@ -636,355 +635,3 @@ cc_library( ], visibility = ["//visibility:private"], ) - -cc_library( - name = "softfloat_macos_arm64", - srcs = [ - # See `OBJS_PRIMITIVES` in `build/template-FAST_INT64/Makefile` in the - # `softfloat` repo. - "source/s_eq128.c", - "source/s_le128.c", - "source/s_lt128.c", - "source/s_shortShiftLeft128.c", - "source/s_shortShiftRight128.c", - "source/s_shortShiftRightJam64.c", - "source/s_shortShiftRightJam64Extra.c", - "source/s_shortShiftRightJam128.c", - "source/s_shortShiftRightJam128Extra.c", - "source/s_shiftRightJam32.c", - "source/s_shiftRightJam64.c", - "source/s_shiftRightJam64Extra.c", - "source/s_shiftRightJam128.c", - "source/s_shiftRightJam128Extra.c", - "source/s_shiftRightJam256M.c", - "source/s_countLeadingZeros8.c", - "source/s_countLeadingZeros16.c", - "source/s_countLeadingZeros32.c", - "source/s_countLeadingZeros64.c", - "source/s_add128.c", - "source/s_add256M.c", - "source/s_sub128.c", - "source/s_sub256M.c", - "source/s_mul64ByShifted32To128.c", - "source/s_mul64To128.c", - "source/s_mul128By32.c", - "source/s_mul128To256M.c", - "source/s_approxRecip_1Ks.c", - "source/s_approxRecip32_1.c", - "source/s_approxRecipSqrt_1Ks.c", - "source/s_approxRecipSqrt32_1.c", - # See `OBJS_SPECIALIZE` in `build/template-FAST_INT64/Makefile` in the - # `softfloat` repo. - "source/8086-SSE/softfloat_raiseFlags.c", - "source/8086-SSE/s_f16UIToCommonNaN.c", - "source/8086-SSE/s_commonNaNToF16UI.c", - "source/8086-SSE/s_propagateNaNF16UI.c", - "source/8086-SSE/s_f32UIToCommonNaN.c", - "source/8086-SSE/s_commonNaNToF32UI.c", - "source/8086-SSE/s_propagateNaNF32UI.c", - "source/8086-SSE/s_f64UIToCommonNaN.c", - "source/8086-SSE/s_commonNaNToF64UI.c", - "source/8086-SSE/s_propagateNaNF64UI.c", - "source/8086-SSE/extF80M_isSignalingNaN.c", - "source/8086-SSE/s_extF80UIToCommonNaN.c", - "source/8086-SSE/s_commonNaNToExtF80UI.c", - "source/8086-SSE/s_propagateNaNExtF80UI.c", - "source/8086-SSE/f128M_isSignalingNaN.c", - "source/8086-SSE/s_f128UIToCommonNaN.c", - "source/8086-SSE/s_commonNaNToF128UI.c", - "source/8086-SSE/s_propagateNaNF128UI.c", - # See `OBJS_OTHERS` in `build/template-FAST_INT64/Makefile` in the - # `softfloat` repo. - "source/s_roundToUI32.c", - "source/s_roundToUI64.c", - "source/s_roundToI32.c", - "source/s_roundToI64.c", - "source/s_normSubnormalF16Sig.c", - "source/s_roundPackToF16.c", - "source/s_normRoundPackToF16.c", - "source/s_addMagsF16.c", - "source/s_subMagsF16.c", - "source/s_mulAddF16.c", - "source/s_normSubnormalF32Sig.c", - "source/s_roundPackToF32.c", - "source/s_normRoundPackToF32.c", - "source/s_addMagsF32.c", - "source/s_subMagsF32.c", - "source/s_mulAddF32.c", - "source/s_normSubnormalF64Sig.c", - "source/s_roundPackToF64.c", - "source/s_normRoundPackToF64.c", - "source/s_addMagsF64.c", - "source/s_subMagsF64.c", - "source/s_mulAddF64.c", - "source/s_normSubnormalExtF80Sig.c", - "source/s_roundPackToExtF80.c", - "source/s_normRoundPackToExtF80.c", - "source/s_addMagsExtF80.c", - "source/s_subMagsExtF80.c", - "source/s_normSubnormalF128Sig.c", - "source/s_roundPackToF128.c", - "source/s_normRoundPackToF128.c", - "source/s_addMagsF128.c", - "source/s_subMagsF128.c", - "source/s_mulAddF128.c", - "source/softfloat_state.c", - "source/ui32_to_f16.c", - "source/ui32_to_f32.c", - "source/ui32_to_f64.c", - "source/ui32_to_extF80.c", - "source/ui32_to_extF80M.c", - "source/ui32_to_f128.c", - "source/ui32_to_f128M.c", - "source/ui64_to_f16.c", - "source/ui64_to_f32.c", - "source/ui64_to_f64.c", - "source/ui64_to_extF80.c", - "source/ui64_to_extF80M.c", - "source/ui64_to_f128.c", - "source/ui64_to_f128M.c", - "source/i32_to_f16.c", - "source/i32_to_f32.c", - "source/i32_to_f64.c", - "source/i32_to_extF80.c", - "source/i32_to_extF80M.c", - "source/i32_to_f128.c", - "source/i32_to_f128M.c", - "source/i64_to_f16.c", - "source/i64_to_f32.c", - "source/i64_to_f64.c", - "source/i64_to_extF80.c", - "source/i64_to_extF80M.c", - "source/i64_to_f128.c", - "source/i64_to_f128M.c", - "source/f16_to_ui32.c", - "source/f16_to_ui64.c", - "source/f16_to_i32.c", - "source/f16_to_i64.c", - "source/f16_to_ui32_r_minMag.c", - "source/f16_to_ui64_r_minMag.c", - "source/f16_to_i32_r_minMag.c", - "source/f16_to_i64_r_minMag.c", - "source/f16_to_f32.c", - "source/f16_to_f64.c", - "source/f16_to_extF80.c", - "source/f16_to_extF80M.c", - "source/f16_to_f128.c", - "source/f16_to_f128M.c", - "source/f16_roundToInt.c", - "source/f16_add.c", - "source/f16_sub.c", - "source/f16_mul.c", - "source/f16_mulAdd.c", - "source/f16_div.c", - "source/f16_rem.c", - "source/f16_sqrt.c", - "source/f16_eq.c", - "source/f16_le.c", - "source/f16_lt.c", - "source/f16_eq_signaling.c", - "source/f16_le_quiet.c", - "source/f16_lt_quiet.c", - "source/f16_isSignalingNaN.c", - "source/f32_to_ui32.c", - "source/f32_to_ui64.c", - "source/f32_to_i32.c", - "source/f32_to_i64.c", - "source/f32_to_ui32_r_minMag.c", - "source/f32_to_ui64_r_minMag.c", - "source/f32_to_i32_r_minMag.c", - "source/f32_to_i64_r_minMag.c", - "source/f32_to_f16.c", - "source/f32_to_f64.c", - "source/f32_to_extF80.c", - "source/f32_to_extF80M.c", - "source/f32_to_f128.c", - "source/f32_to_f128M.c", - "source/f32_roundToInt.c", - "source/f32_add.c", - "source/f32_sub.c", - "source/f32_mul.c", - "source/f32_mulAdd.c", - "source/f32_div.c", - "source/f32_rem.c", - "source/f32_sqrt.c", - "source/f32_eq.c", - "source/f32_le.c", - "source/f32_lt.c", - "source/f32_eq_signaling.c", - "source/f32_le_quiet.c", - "source/f32_lt_quiet.c", - "source/f32_isSignalingNaN.c", - "source/f64_to_ui32.c", - "source/f64_to_ui64.c", - "source/f64_to_i32.c", - "source/f64_to_i64.c", - "source/f64_to_ui32_r_minMag.c", - "source/f64_to_ui64_r_minMag.c", - "source/f64_to_i32_r_minMag.c", - "source/f64_to_i64_r_minMag.c", - "source/f64_to_f16.c", - "source/f64_to_f32.c", - "source/f64_to_extF80.c", - "source/f64_to_extF80M.c", - "source/f64_to_f128.c", - "source/f64_to_f128M.c", - "source/f64_roundToInt.c", - "source/f64_add.c", - "source/f64_sub.c", - "source/f64_mul.c", - "source/f64_mulAdd.c", - "source/f64_div.c", - "source/f64_rem.c", - "source/f64_sqrt.c", - "source/f64_eq.c", - "source/f64_le.c", - "source/f64_lt.c", - "source/f64_eq_signaling.c", - "source/f64_le_quiet.c", - "source/f64_lt_quiet.c", - "source/f64_isSignalingNaN.c", - "source/extF80_to_ui32.c", - "source/extF80_to_ui64.c", - "source/extF80_to_i32.c", - "source/extF80_to_i64.c", - "source/extF80_to_ui32_r_minMag.c", - "source/extF80_to_ui64_r_minMag.c", - "source/extF80_to_i32_r_minMag.c", - "source/extF80_to_i64_r_minMag.c", - "source/extF80_to_f16.c", - "source/extF80_to_f32.c", - "source/extF80_to_f64.c", - "source/extF80_to_f128.c", - "source/extF80_roundToInt.c", - "source/extF80_add.c", - "source/extF80_sub.c", - "source/extF80_mul.c", - "source/extF80_div.c", - "source/extF80_rem.c", - "source/extF80_sqrt.c", - "source/extF80_eq.c", - "source/extF80_le.c", - "source/extF80_lt.c", - "source/extF80_eq_signaling.c", - "source/extF80_le_quiet.c", - "source/extF80_lt_quiet.c", - "source/extF80_isSignalingNaN.c", - "source/extF80M_to_ui32.c", - "source/extF80M_to_ui64.c", - "source/extF80M_to_i32.c", - "source/extF80M_to_i64.c", - "source/extF80M_to_ui32_r_minMag.c", - "source/extF80M_to_ui64_r_minMag.c", - "source/extF80M_to_i32_r_minMag.c", - "source/extF80M_to_i64_r_minMag.c", - "source/extF80M_to_f16.c", - "source/extF80M_to_f32.c", - "source/extF80M_to_f64.c", - "source/extF80M_to_f128M.c", - "source/extF80M_roundToInt.c", - "source/extF80M_add.c", - "source/extF80M_sub.c", - "source/extF80M_mul.c", - "source/extF80M_div.c", - "source/extF80M_rem.c", - "source/extF80M_sqrt.c", - "source/extF80M_eq.c", - "source/extF80M_le.c", - "source/extF80M_lt.c", - "source/extF80M_eq_signaling.c", - "source/extF80M_le_quiet.c", - "source/extF80M_lt_quiet.c", - "source/f128_to_ui32.c", - "source/f128_to_ui64.c", - "source/f128_to_i32.c", - "source/f128_to_i64.c", - "source/f128_to_ui32_r_minMag.c", - "source/f128_to_ui64_r_minMag.c", - "source/f128_to_i32_r_minMag.c", - "source/f128_to_i64_r_minMag.c", - "source/f128_to_f16.c", - "source/f128_to_f32.c", - "source/f128_to_extF80.c", - "source/f128_to_f64.c", - "source/f128_roundToInt.c", - "source/f128_add.c", - "source/f128_sub.c", - "source/f128_mul.c", - "source/f128_mulAdd.c", - "source/f128_div.c", - "source/f128_rem.c", - "source/f128_sqrt.c", - "source/f128_eq.c", - "source/f128_le.c", - "source/f128_lt.c", - "source/f128_eq_signaling.c", - "source/f128_le_quiet.c", - "source/f128_lt_quiet.c", - "source/f128_isSignalingNaN.c", - "source/f128M_to_ui32.c", - "source/f128M_to_ui64.c", - "source/f128M_to_i32.c", - "source/f128M_to_i64.c", - "source/f128M_to_ui32_r_minMag.c", - "source/f128M_to_ui64_r_minMag.c", - "source/f128M_to_i32_r_minMag.c", - "source/f128M_to_i64_r_minMag.c", - "source/f128M_to_f16.c", - "source/f128M_to_f32.c", - "source/f128M_to_extF80M.c", - "source/f128M_to_f64.c", - "source/f128M_roundToInt.c", - "source/f128M_add.c", - "source/f128M_sub.c", - "source/f128M_mul.c", - "source/f128M_mulAdd.c", - "source/f128M_div.c", - "source/f128M_rem.c", - "source/f128M_sqrt.c", - "source/f128M_eq.c", - "source/f128M_le.c", - "source/f128M_lt.c", - "source/f128M_eq_signaling.c", - "source/f128M_le_quiet.c", - "source/f128M_lt_quiet.c", - # See `$(OTHER_HEADERS)` in `build/template-FAST_INT64/Makefile` in the - # `softfloat` repo. - "source/include/opts-GCC.h", - # See `$(OBJS_ALL)` target in `build/template-FAST_INT64/Makefile` in the - # `softfloat` repo. - "build/template-FAST_INT64/platform.h", - "source/include/primitiveTypes.h", - "source/include/primitives.h", - # See `$(OBJS_SPECIALIZE) $(OBJS_OTHERS)` target in - # `build/template-FAST_INT64/Makefile` in the `softfloat` repo. - "source/include/softfloat_types.h", - "source/include/internals.h", - "source/8086-SSE/specialize.h", - ], - hdrs = [ - "source/include/softfloat.h", - ], - copts = [ - "-Iexternal/softfloat/build/template-FAST_INT64", - "-Iexternal/softfloat/source/8086-SSE", - "-Werror-implicit-function-declaration", - "-O2", - ], - # `SOFTFLOAT_FAST_INT64` is used in `softfloat.h` and therefore needs to be - # passed to dependencies. - defines = ["SOFTFLOAT_FAST_INT64"], - includes = [ - "build/template-FAST_INT64", - "source/8086-SSE", - "source/include", - ], - local_defines = [ - "URBIT_RUNTIME_OS_DARWIN", - "SOFTFLOAT_ROUND_ODD", - "INLINE_LEVEL=5", - "SOFTFLOAT_FAST_DIV32TO16", - "SOFTFLOAT_FAST_DIV64TO32", - ], - visibility = ["//visibility:private"], -) diff --git a/bazel/third_party/uv/uv.BUILD b/bazel/third_party/uv/uv.BUILD index 07063afd2d..362bbdbe8f 100644 --- a/bazel/third_party/uv/uv.BUILD +++ b/bazel/third_party/uv/uv.BUILD @@ -8,7 +8,10 @@ filegroup( # TODO: check windows build. configure_make( name = "uv", - args = ["--jobs=`nproc`"], + args = select({ + "@platforms//os:macos": ["--jobs=`sysctl -n hw.logicalcpu`"], + "//conditions:default": ["--jobs=`nproc`"], + }), autogen = True, configure_in_place = True, configure_options = [ diff --git a/bazel/third_party/zlib/zlib.BUILD b/bazel/third_party/zlib/zlib.BUILD index e360545ef9..d17ee3a093 100644 --- a/bazel/third_party/zlib/zlib.BUILD +++ b/bazel/third_party/zlib/zlib.BUILD @@ -7,7 +7,10 @@ filegroup( configure_make( name = "zlib", - args = ["--jobs=`nproc`"], + args = select({ + "@platforms//os:macos": ["--jobs=`sysctl -n hw.logicalcpu`"], + "//conditions:default": ["--jobs=`nproc`"], + }), configure_options = ["--static"], lib_source = ":all", out_static_libs = ["libz.a"], diff --git a/bazel/toolchain/BUILD.bazel b/bazel/toolchain/BUILD.bazel index 91bfe0a415..0eacaa973a 100644 --- a/bazel/toolchain/BUILD.bazel +++ b/bazel/toolchain/BUILD.bazel @@ -243,3 +243,61 @@ toolchain( toolchain = ":clang-macos-arm64", toolchain_type = ":toolchain_type", ) + +# +# clang-macos-x86_64 +# + +# Toolchain identifier. +_macos_x86_64_clang = "toolchain-clang-macos-x86_64" + +cc_toolchain_config( + name = "clang-macos-x86_64-config", + # NOTE: building with `libtool` does not work on macOS due to lack of + # support in the `configure_make` rule provided by `rules_foreign_cc`. + # Therefore, we require setting `ar` as the archiver tool on macOS. + ar = "/usr/bin/ar", + # By default, Bazel passes the `rcsD` flags to `ar`, but macOS's `ar` + # implementation doesn't support `D`. We remove it with this attribute + # and corresponding `ar_flags_feature` in `cfg.bzl`. + # See https://github.com/bazelbuild/bazel/issues/15875. + ar_flags = "rcs", + cc = "/usr/bin/clang", + compiler = "clang", + compiler_version = "//:clang_version", + ld = "/usr/bin/ld", + sys_includes = [ + "/Library/Developer/CommandLineTools/usr/lib/clang/{compiler_version}/include", + "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/", + ], + target_cpu = "x86_64", + toolchain_identifier = _macos_x86_64_clang, +) + +cc_toolchain( + name = "clang-macos-x86_64", + all_files = ":empty", + compiler_files = ":empty", + dwp_files = ":empty", + linker_files = ":empty", + objcopy_files = ":empty", + strip_files = ":empty", + supports_param_files = 0, + toolchain_config = ":clang-macos-x86_64-config", + toolchain_identifier = _macos_x86_64_clang, +) + +toolchain( + name = "clang-macos-x86_64-toolchain", + exec_compatible_with = [ + "//:clang", + "@platforms//os:macos", + "@platforms//cpu:x86_64", + ], + target_compatible_with = [ + "@platforms//os:macos", + "@platforms//cpu:x86_64", + ], + toolchain = ":clang-macos-x86_64", + toolchain_type = ":toolchain_type", +)