diff --git a/.bazelrc b/.bazelrc index de624e78..7857c605 100644 --- a/.bazelrc +++ b/.bazelrc @@ -11,17 +11,16 @@ common --define=SOME_VAR=SOME_VALUE common --@pypi//venv=default common --incompatible_enable_cc_toolchain_resolution +common --@toolchains_llvm_bootstrapped//config:experimental_stub_libgcc_s +#common --@rules_cc//cc/toolchains/args/archiver_flags:use_libtool_on_macos=false # TODO(bzlmod): Don't break proto common --per_file_copt=external/.*protobuf.*@--PROTOBUF_WAS_NOT_SUPPOSED_TO_BE_BUILT common --host_per_file_copt=external/.*protobuf.*@--PROTOBUF_WAS_NOT_SUPPOSED_TO_BE_BUILT -# Don't try and auto detect the cc toolchain, as we use our own gcc toolchains. +# Don't try and auto detect the cc toolchain, as we use our own llvm toolchains. common --repo_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 -# Don't link against libunwind on macos as it causes linking failures (https://github.com/bazel-contrib/toolchains_llvm/pull/346) -common:macos --@toolchains_llvm//toolchain/config:libunwind=False - common:ci --toolchain_resolution_debug='@@bazel_tools//tools/cpp:toolchain_type' common:release --build_tag_filters=release diff --git a/.bcr/patches/remove_dev_deps.patch b/.bcr/patches/remove_dev_deps.patch index 454654c6..4acbe208 100644 --- a/.bcr/patches/remove_dev_deps.patch +++ b/.bcr/patches/remove_dev_deps.patch @@ -1,6 +1,6 @@ ---- a/MODULE.bazel 2025-11-06 12:48:12 -+++ b/MODULE.bazel 2025-11-06 12:48:12 -@@ -40,558 +40,5 @@ +--- a/MODULE.bazel 2025-11-08 23:55:11 ++++ b/MODULE.bazel 2025-11-08 23:55:11 +@@ -40,300 +40,5 @@ # HACK: In prod the includer's patch inserts the use_repo for multitool. This # solves the problem of needing a use_repo here in prod and below in dev. @@ -37,139 +37,51 @@ -# from bazel/include/llvm.MODULE.bazel -# LLVM configuration - --bazel_dep(name = "toolchains_llvm", version = "1.4.0") -bazel_dep(name = "rules_cc", version = "0.2.11") - +-bazel_dep(name = "toolchains_llvm_bootstrapped", version = "0.2.5", dev_dependency = True) -single_version_override( -- module_name = "toolchains_llvm", +- module_name = "toolchains_llvm_bootstrapped", - patch_strip = 1, - patches = [ -- "//bazel/patches:toolchains_llvm.patch", +- "//bazel/patches:llvm_darwin_sysroot.patch", - ], -) - --llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm", dev_dependency = True) -- --execution_oses = [ -- "macos", -- "linux", --] -- --execution_cpus = [ -- "aarch64", -- "x86_64", --] -- --[ -- [ -- llvm.toolchain( -- name = "llvm_toolchain_{}_{}".format(exec_os, exec_cpu), -- exec_arch = exec_cpu, -- exec_os = exec_os if exec_os != "macos" else "darwin", -- llvm_version = "20.1.2", -- ), -- llvm.sysroot( -- name = "llvm_toolchain_{}_{}".format(exec_os, exec_cpu), -- label = "@org_chromium_sysroot_linux_x86_64//:sysroot", -- targets = ["linux-x86_64"], -- ), -- llvm.sysroot( -- name = "llvm_toolchain_{}_{}".format(exec_os, exec_cpu), -- label = "@org_chromium_sysroot_linux_arm64//:sysroot", -- targets = ["linux-aarch64"], -- ), -- llvm.sysroot( -- name = "llvm_toolchain_{}_{}".format(exec_os, exec_cpu), -- label = "@sysroot_darwin_universal//:sysroot", -- targets = [ -- "darwin-aarch64", -- "darwin-x86_64", -- ], -- ), -- use_repo(llvm, "llvm_toolchain_{}_{}".format(exec_os, exec_cpu)), -- ] -- for exec_os in execution_oses -- for exec_cpu in execution_cpus --] -- --http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -- --_SYSROOT_LINUX_BUILD_FILE = """\ --filegroup( -- name = "sysroot", -- srcs = glob(["*/**"]), -- visibility = ["//visibility:public"], --) --""" -- --http_archive( -- name = "org_chromium_sysroot_linux_arm64", -- build_file_content = _SYSROOT_LINUX_BUILD_FILE, -- sha256 = "b199942a0bd9c34800e8d7b669778ef45f2054b9f106039439383dd66efcef31", -- urls = ["https://github.com/DavidZbarsky-at/sysroot-min/releases/download/v0.0.20/debian_bullseye_arm64_sysroot.tar.xz"], --) -- --http_archive( -- name = "org_chromium_sysroot_linux_x86_64", -- build_file_content = _SYSROOT_LINUX_BUILD_FILE, -- sha256 = "b279dd2926e7d3860bb4e134997a45df5106f680e160a959b945580ba4ec755f", -- urls = ["https://github.com/DavidZbarsky-at/sysroot-min/releases/download/v0.0.20/debian_bullseye_amd64_sysroot.tar.xz"], --) -- --http_archive( -- name = "sysroot_darwin_universal", -- build_file_content = """ --filegroup( -- name = "sysroot", -- srcs = glob( -- include = ["**"], -- exclude = ["**/*:*"], -- ), -- visibility = ["//visibility:public"], --) --""", -- integrity = "sha256-9qzGIJ251Wtn/K+R7B3v5Ici6esT3CH7kc/s6xSJ5X4=", -- # The ruby header has an infinite symlink that we need to remove. -- patch_cmds = ["rm System/Library/Frameworks/Ruby.framework/Versions/Current/Headers/ruby/ruby"], -- strip_prefix = "MacOSX14.5.sdk", -- urls = ["https://github.com/alexey-lysiuk/macos-sdk/releases/download/14.5/MacOSX14.5.tar.xz"], --) -- --target_oses = [ -- "macos", -- "linux", --] -- --target_cpus = [ -- "aarch64", -- "x86_64", --] -- --platforms = [ -- { -- "exec_os": exec_os, -- "exec_cpu": exec_cpu, -- "tgt_os": tgt_os, -- "tgt_cpu": tgt_cpu, -- } -- for exec_os in execution_oses -- for exec_cpu in execution_cpus -- for tgt_os in target_oses -- for tgt_cpu in target_cpus --] -- --[register_toolchains("//bazel/platforms/toolchains:{}_{}_{}_{}_llvm".format( -- p["exec_os"], -- p["exec_cpu"], -- p["tgt_os"], -- p["tgt_cpu"], --)) for p in platforms] -- +-register_toolchains( +- "@toolchains_llvm_bootstrapped//toolchain:all", +-) +- +-#http_archive( +-# name = "sysroot_darwin_universal", +-# build_file_content = """ +-#filegroup( +-# name = "sysroot", +-# srcs = glob( +-# include = ["**"], +-# exclude = ["**/*:*"], +-# ), +-# visibility = ["//visibility:public"], +-#) +-#""", +-# integrity = "sha256-9qzGIJ251Wtn/K+R7B3v5Ici6esT3CH7kc/s6xSJ5X4=", +-# # The ruby header has an infinite symlink that we need to remove. +-# patch_cmds = ["rm System/Library/Frameworks/Ruby.framework/Versions/Current/Headers/ruby/ruby"], +-# strip_prefix = "MacOSX14.5.sdk", +-# urls = ["https://github.com/alexey-lysiuk/macos-sdk/releases/download/14.5/MacOSX14.5.tar.xz"], +-#) -######################################## -# from bazel/include/rust.MODULE.bazel -# Rust configuration - -bazel_dep(name = "rules_rust", version = "0.67.0") +-single_version_override( +- module_name = "rules_rust", +- patch_strip = 1, +- patches = [ +- "//bazel/patches:rules_rust_musl_sysroot.patch", +- ], +-) -bazel_dep(name = "openssl", version = "3.3.1.bcr.6") - -RUST_EDITION = "2024" @@ -180,187 +92,17 @@ - "@rules_rust//rust:extensions.bzl", - "rust", -) -- --# These override the default rust_repository_sets created by rust_register_toolchain. They must be named exactly as follows. --# NB: The first call for a particular name may set the `edition`, `exec_triple`, and `versions` attributes, the subsequent calls should not set it or else Bazel will fail with, --# "Error in fail: You must only set edition on the first call to repository_set for a particular name but it was set multiple times for rust_linux_x86_64" --# "Error in fail: You must only set exec_triple on the first call to repository_set for a particular name but it was set multiple times for rust_linux_x86_64" --# "Error in fail: You must only set versions on the first call to repository_set for a particular name but it was set multiple times for rust_linux_x86_64" -- --# Execution platform : linux x86 (x86_64-unknown-linux-gnu) --# -> linux x86_64 (gnu) --rust.repository_set( -- name = "rust_linux_x86_64", -- edition = RUST_EDITION, # "edition" only set in first instance of "rust_linux_x86_64" repository_set (see comment above) -- exec_triple = "x86_64-unknown-linux-gnu", # "exec_triple" only set in first instance of "rust_linux_x86_64" repository_set (see comment above) -- target_compatible_with = [ -- "//bazel/platforms/linkers:unknown", -- "@platforms//cpu:x86_64", -- "@platforms//os:linux", -- ], -- target_triple = "x86_64-unknown-linux-gnu", -- versions = [RUST_VERSION], # "versions" only set in first instance of "rust_linux_x86_64" repository_set (see comment above) --) -- --# -> linux x86_64 (musl) --rust.repository_set( -- name = "rust_linux_x86_64", -- target_compatible_with = [ -- "//bazel/platforms/linkers:unknown", -- "@platforms//cpu:x86_64", -- "@platforms//os:linux", -- ], -- target_triple = "x86_64-unknown-linux-musl", --) -- --# -> linux arm (musl) --rust.repository_set( -- name = "rust_linux_x86_64", -- target_compatible_with = [ -- "//bazel/platforms/linkers:unknown", -- "@platforms//cpu:arm64", -- "@platforms//os:linux", -- ], -- target_triple = "aarch64-unknown-linux-musl", --) -- --# -> darwin x86 --rust.repository_set( -- name = "rust_linux_x86_64", -- target_compatible_with = [ -- "@platforms//cpu:x86_64", -- "@platforms//os:macos", -- ], -- target_triple = "x86_64-apple-darwin", --) -- --# -> darwin arm --rust.repository_set( -- name = "rust_linux_x86_64", -- target_compatible_with = [ -- "@platforms//cpu:arm64", -- "@platforms//os:macos", -- ], -- target_triple = "aarch64-apple-darwin", --) -- --# Execution platform : linux arm (aarch64-unknown-linux-gnu) --# -> linux arm (gnu) --rust.repository_set( -- name = "rust_linux_aarch64", -- edition = RUST_EDITION, # "edition" only set in first instance of "rust_linux_aarch64" repository_set (see comment above) -- exec_triple = "aarch64-unknown-linux-gnu", # "exec_triple" only set in first instance of "rust_linux_aarch64" repository_set (see comment above) -- target_compatible_with = [ -- "//bazel/platforms/linkers:unknown", -- "@platforms//cpu:aarch64", -- "@platforms//os:linux", -- ], -- target_triple = "aarch64-unknown-linux-gnu", -- versions = [RUST_VERSION], # "versions" only set in first instance of "rust_linux_aarch64" repository_set (see comment above) --) -- --# -> linux arm (musl) --rust.repository_set( -- name = "rust_linux_aarch64", -- target_compatible_with = [ -- "//bazel/platforms/linkers:unknown", -- "@platforms//cpu:aarch64", -- "@platforms//os:linux", -- ], -- target_triple = "aarch64-unknown-linux-musl", --) -- --# Execution platform : darwin x86 (x86_64-apple-darwin) --# -> linux x86 (musl) --rust.repository_set( -- name = "rust_darwin_x86_64", -- edition = RUST_EDITION, # "edition" only set in first instance of "rust_darwin_x86_64" repository_set (see comment above) -- exec_triple = "x86_64-apple-darwin", # "exec_triple" only set in first instance of "rust_darwin_x86_64" repository_set (see comment above) -- target_compatible_with = [ -- "//bazel/platforms/linkers:unknown", -- "@platforms//cpu:x86_64", -- "@platforms//os:linux", -- ], -- target_triple = "x86_64-unknown-linux-musl", -- versions = [RUST_VERSION], # "versions" only set in first instance of "rust_darwin_x86_64" repository_set (see comment above) --) -- --# -> linux arm (musl) --rust.repository_set( -- name = "rust_darwin_x86_64", -- target_compatible_with = [ -- "//bazel/platforms/linkers:unknown", -- "@platforms//cpu:arm64", -- "@platforms//os:linux", -- ], -- target_triple = "aarch64-unknown-linux-musl", --) -- --# -> darwin x86 --rust.repository_set( -- name = "rust_darwin_x86_64", -- target_compatible_with = [ -- "@platforms//cpu:x86_64", -- "@platforms//os:macos", -- ], -- target_triple = "x86_64-apple-darwin", --) -- --# -> darwin arm --rust.repository_set( -- name = "rust_darwin_x86_64", -- target_compatible_with = [ -- "@platforms//cpu:arm64", -- "@platforms//os:macos", -- ], -- target_triple = "aarch64-apple-darwin", --) -- --# Execution platform : darwin arm (aarch64-apple-darwin) --# -> linux x86 (musl) --rust.repository_set( -- name = "rust_darwin_aarch64", -- edition = RUST_EDITION, # "edition" only set in first instance of "rust_darwin_aarch64" repository_set (see comment above) -- exec_triple = "aarch64-apple-darwin", # "exec_triple" only set in first instance of "rust_darwin_aarch64" repository_set (see comment above) -- target_compatible_with = [ -- "//bazel/platforms/linkers:unknown", -- "@platforms//cpu:x86_64", -- "@platforms//os:linux", -- ], -- target_triple = "x86_64-unknown-linux-musl", -- versions = [RUST_VERSION], # "versions" only set in first instance of "rust_darwin_aarch64" repository_set (see comment above) --) -- --# -> linux arm (musl) --rust.repository_set( -- name = "rust_darwin_aarch64", -- target_compatible_with = [ -- "//bazel/platforms/linkers:unknown", -- "@platforms//cpu:arm64", -- "@platforms//os:linux", -- ], -- target_triple = "aarch64-unknown-linux-musl", --) -- --# -> darwin x86 --rust.repository_set( -- name = "rust_darwin_aarch64", -- target_compatible_with = [ -- "@platforms//cpu:x86_64", -- "@platforms//os:macos", +-rust.toolchain( +- edition = RUST_EDITION, +- versions = [RUST_VERSION], +- extra_target_triples = [ +- "aarch64-apple-darwin", +- "x86_64-apple-darwin", +- "aarch64-unknown-linux-musl", +- "x86_64-unknown-linux-musl", - ], -- target_triple = "x86_64-apple-darwin", -) - --# -> darwin arm --rust.repository_set( -- name = "rust_darwin_aarch64", -- target_compatible_with = [ -- "@platforms//cpu:arm64", -- "@platforms//os:macos", -- ], -- target_triple = "aarch64-apple-darwin", --) -use_repo(rust, "rust_toolchains") - -register_toolchains("@rust_toolchains//:all") @@ -385,9 +127,9 @@ - cargo_toml = "//:Cargo.toml", - platform_triples = [ - "aarch64-apple-darwin", -- "aarch64-unknown-linux-gnu", +- "aarch64-unknown-linux-musl", - "x86_64-apple-darwin", -- "x86_64-unknown-linux-gnu", +- "x86_64-unknown-linux-musl", - ], -) -crate.annotation( diff --git a/MODULE.bazel b/MODULE.bazel index 23910a46..0acf9290 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -73,139 +73,51 @@ use_repo(host, "aspect_rules_py_uv_host") # from bazel/include/llvm.MODULE.bazel # LLVM configuration -bazel_dep(name = "toolchains_llvm", version = "1.4.0") bazel_dep(name = "rules_cc", version = "0.2.11") +bazel_dep(name = "toolchains_llvm_bootstrapped", version = "0.2.5", dev_dependency = True) single_version_override( - module_name = "toolchains_llvm", + module_name = "toolchains_llvm_bootstrapped", patch_strip = 1, patches = [ - "//bazel/patches:toolchains_llvm.patch", + "//bazel/patches:llvm_darwin_sysroot.patch", ], ) -llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm", dev_dependency = True) - -execution_oses = [ - "macos", - "linux", -] - -execution_cpus = [ - "aarch64", - "x86_64", -] - -[ - [ - llvm.toolchain( - name = "llvm_toolchain_{}_{}".format(exec_os, exec_cpu), - exec_arch = exec_cpu, - exec_os = exec_os if exec_os != "macos" else "darwin", - llvm_version = "20.1.2", - ), - llvm.sysroot( - name = "llvm_toolchain_{}_{}".format(exec_os, exec_cpu), - label = "@org_chromium_sysroot_linux_x86_64//:sysroot", - targets = ["linux-x86_64"], - ), - llvm.sysroot( - name = "llvm_toolchain_{}_{}".format(exec_os, exec_cpu), - label = "@org_chromium_sysroot_linux_arm64//:sysroot", - targets = ["linux-aarch64"], - ), - llvm.sysroot( - name = "llvm_toolchain_{}_{}".format(exec_os, exec_cpu), - label = "@sysroot_darwin_universal//:sysroot", - targets = [ - "darwin-aarch64", - "darwin-x86_64", - ], - ), - use_repo(llvm, "llvm_toolchain_{}_{}".format(exec_os, exec_cpu)), - ] - for exec_os in execution_oses - for exec_cpu in execution_cpus -] - -http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - -_SYSROOT_LINUX_BUILD_FILE = """\ -filegroup( - name = "sysroot", - srcs = glob(["*/**"]), - visibility = ["//visibility:public"], -) -""" - -http_archive( - name = "org_chromium_sysroot_linux_arm64", - build_file_content = _SYSROOT_LINUX_BUILD_FILE, - sha256 = "b199942a0bd9c34800e8d7b669778ef45f2054b9f106039439383dd66efcef31", - urls = ["https://github.com/DavidZbarsky-at/sysroot-min/releases/download/v0.0.20/debian_bullseye_arm64_sysroot.tar.xz"], -) - -http_archive( - name = "org_chromium_sysroot_linux_x86_64", - build_file_content = _SYSROOT_LINUX_BUILD_FILE, - sha256 = "b279dd2926e7d3860bb4e134997a45df5106f680e160a959b945580ba4ec755f", - urls = ["https://github.com/DavidZbarsky-at/sysroot-min/releases/download/v0.0.20/debian_bullseye_amd64_sysroot.tar.xz"], -) - -http_archive( - name = "sysroot_darwin_universal", - build_file_content = """ -filegroup( - name = "sysroot", - srcs = glob( - include = ["**"], - exclude = ["**/*:*"], - ), - visibility = ["//visibility:public"], -) -""", - integrity = "sha256-9qzGIJ251Wtn/K+R7B3v5Ici6esT3CH7kc/s6xSJ5X4=", - # The ruby header has an infinite symlink that we need to remove. - patch_cmds = ["rm System/Library/Frameworks/Ruby.framework/Versions/Current/Headers/ruby/ruby"], - strip_prefix = "MacOSX14.5.sdk", - urls = ["https://github.com/alexey-lysiuk/macos-sdk/releases/download/14.5/MacOSX14.5.tar.xz"], -) - -target_oses = [ - "macos", - "linux", -] - -target_cpus = [ - "aarch64", - "x86_64", -] - -platforms = [ - { - "exec_os": exec_os, - "exec_cpu": exec_cpu, - "tgt_os": tgt_os, - "tgt_cpu": tgt_cpu, - } - for exec_os in execution_oses - for exec_cpu in execution_cpus - for tgt_os in target_oses - for tgt_cpu in target_cpus -] - -[register_toolchains("//bazel/platforms/toolchains:{}_{}_{}_{}_llvm".format( - p["exec_os"], - p["exec_cpu"], - p["tgt_os"], - p["tgt_cpu"], -)) for p in platforms] - +register_toolchains( + "@toolchains_llvm_bootstrapped//toolchain:all", +) + +#http_archive( +# name = "sysroot_darwin_universal", +# build_file_content = """ +#filegroup( +# name = "sysroot", +# srcs = glob( +# include = ["**"], +# exclude = ["**/*:*"], +# ), +# visibility = ["//visibility:public"], +#) +#""", +# integrity = "sha256-9qzGIJ251Wtn/K+R7B3v5Ici6esT3CH7kc/s6xSJ5X4=", +# # The ruby header has an infinite symlink that we need to remove. +# patch_cmds = ["rm System/Library/Frameworks/Ruby.framework/Versions/Current/Headers/ruby/ruby"], +# strip_prefix = "MacOSX14.5.sdk", +# urls = ["https://github.com/alexey-lysiuk/macos-sdk/releases/download/14.5/MacOSX14.5.tar.xz"], +#) ######################################## # from bazel/include/rust.MODULE.bazel # Rust configuration bazel_dep(name = "rules_rust", version = "0.67.0") +single_version_override( + module_name = "rules_rust", + patch_strip = 1, + patches = [ + "//bazel/patches:rules_rust_musl_sysroot.patch", + ], +) bazel_dep(name = "openssl", version = "3.3.1.bcr.6") RUST_EDITION = "2024" @@ -216,187 +128,17 @@ rust = use_extension( "@rules_rust//rust:extensions.bzl", "rust", ) - -# These override the default rust_repository_sets created by rust_register_toolchain. They must be named exactly as follows. -# NB: The first call for a particular name may set the `edition`, `exec_triple`, and `versions` attributes, the subsequent calls should not set it or else Bazel will fail with, -# "Error in fail: You must only set edition on the first call to repository_set for a particular name but it was set multiple times for rust_linux_x86_64" -# "Error in fail: You must only set exec_triple on the first call to repository_set for a particular name but it was set multiple times for rust_linux_x86_64" -# "Error in fail: You must only set versions on the first call to repository_set for a particular name but it was set multiple times for rust_linux_x86_64" - -# Execution platform : linux x86 (x86_64-unknown-linux-gnu) -# -> linux x86_64 (gnu) -rust.repository_set( - name = "rust_linux_x86_64", - edition = RUST_EDITION, # "edition" only set in first instance of "rust_linux_x86_64" repository_set (see comment above) - exec_triple = "x86_64-unknown-linux-gnu", # "exec_triple" only set in first instance of "rust_linux_x86_64" repository_set (see comment above) - target_compatible_with = [ - "//bazel/platforms/linkers:unknown", - "@platforms//cpu:x86_64", - "@platforms//os:linux", - ], - target_triple = "x86_64-unknown-linux-gnu", - versions = [RUST_VERSION], # "versions" only set in first instance of "rust_linux_x86_64" repository_set (see comment above) -) - -# -> linux x86_64 (musl) -rust.repository_set( - name = "rust_linux_x86_64", - target_compatible_with = [ - "//bazel/platforms/linkers:unknown", - "@platforms//cpu:x86_64", - "@platforms//os:linux", - ], - target_triple = "x86_64-unknown-linux-musl", -) - -# -> linux arm (musl) -rust.repository_set( - name = "rust_linux_x86_64", - target_compatible_with = [ - "//bazel/platforms/linkers:unknown", - "@platforms//cpu:arm64", - "@platforms//os:linux", - ], - target_triple = "aarch64-unknown-linux-musl", -) - -# -> darwin x86 -rust.repository_set( - name = "rust_linux_x86_64", - target_compatible_with = [ - "@platforms//cpu:x86_64", - "@platforms//os:macos", - ], - target_triple = "x86_64-apple-darwin", -) - -# -> darwin arm -rust.repository_set( - name = "rust_linux_x86_64", - target_compatible_with = [ - "@platforms//cpu:arm64", - "@platforms//os:macos", - ], - target_triple = "aarch64-apple-darwin", -) - -# Execution platform : linux arm (aarch64-unknown-linux-gnu) -# -> linux arm (gnu) -rust.repository_set( - name = "rust_linux_aarch64", - edition = RUST_EDITION, # "edition" only set in first instance of "rust_linux_aarch64" repository_set (see comment above) - exec_triple = "aarch64-unknown-linux-gnu", # "exec_triple" only set in first instance of "rust_linux_aarch64" repository_set (see comment above) - target_compatible_with = [ - "//bazel/platforms/linkers:unknown", - "@platforms//cpu:aarch64", - "@platforms//os:linux", - ], - target_triple = "aarch64-unknown-linux-gnu", - versions = [RUST_VERSION], # "versions" only set in first instance of "rust_linux_aarch64" repository_set (see comment above) -) - -# -> linux arm (musl) -rust.repository_set( - name = "rust_linux_aarch64", - target_compatible_with = [ - "//bazel/platforms/linkers:unknown", - "@platforms//cpu:aarch64", - "@platforms//os:linux", - ], - target_triple = "aarch64-unknown-linux-musl", -) - -# Execution platform : darwin x86 (x86_64-apple-darwin) -# -> linux x86 (musl) -rust.repository_set( - name = "rust_darwin_x86_64", - edition = RUST_EDITION, # "edition" only set in first instance of "rust_darwin_x86_64" repository_set (see comment above) - exec_triple = "x86_64-apple-darwin", # "exec_triple" only set in first instance of "rust_darwin_x86_64" repository_set (see comment above) - target_compatible_with = [ - "//bazel/platforms/linkers:unknown", - "@platforms//cpu:x86_64", - "@platforms//os:linux", - ], - target_triple = "x86_64-unknown-linux-musl", - versions = [RUST_VERSION], # "versions" only set in first instance of "rust_darwin_x86_64" repository_set (see comment above) -) - -# -> linux arm (musl) -rust.repository_set( - name = "rust_darwin_x86_64", - target_compatible_with = [ - "//bazel/platforms/linkers:unknown", - "@platforms//cpu:arm64", - "@platforms//os:linux", - ], - target_triple = "aarch64-unknown-linux-musl", -) - -# -> darwin x86 -rust.repository_set( - name = "rust_darwin_x86_64", - target_compatible_with = [ - "@platforms//cpu:x86_64", - "@platforms//os:macos", - ], - target_triple = "x86_64-apple-darwin", -) - -# -> darwin arm -rust.repository_set( - name = "rust_darwin_x86_64", - target_compatible_with = [ - "@platforms//cpu:arm64", - "@platforms//os:macos", - ], - target_triple = "aarch64-apple-darwin", -) - -# Execution platform : darwin arm (aarch64-apple-darwin) -# -> linux x86 (musl) -rust.repository_set( - name = "rust_darwin_aarch64", - edition = RUST_EDITION, # "edition" only set in first instance of "rust_darwin_aarch64" repository_set (see comment above) - exec_triple = "aarch64-apple-darwin", # "exec_triple" only set in first instance of "rust_darwin_aarch64" repository_set (see comment above) - target_compatible_with = [ - "//bazel/platforms/linkers:unknown", - "@platforms//cpu:x86_64", - "@platforms//os:linux", - ], - target_triple = "x86_64-unknown-linux-musl", - versions = [RUST_VERSION], # "versions" only set in first instance of "rust_darwin_aarch64" repository_set (see comment above) -) - -# -> linux arm (musl) -rust.repository_set( - name = "rust_darwin_aarch64", - target_compatible_with = [ - "//bazel/platforms/linkers:unknown", - "@platforms//cpu:arm64", - "@platforms//os:linux", - ], - target_triple = "aarch64-unknown-linux-musl", -) - -# -> darwin x86 -rust.repository_set( - name = "rust_darwin_aarch64", - target_compatible_with = [ - "@platforms//cpu:x86_64", - "@platforms//os:macos", +rust.toolchain( + edition = RUST_EDITION, + versions = [RUST_VERSION], + extra_target_triples = [ + "aarch64-apple-darwin", + "x86_64-apple-darwin", + "aarch64-unknown-linux-musl", + "x86_64-unknown-linux-musl", ], - target_triple = "x86_64-apple-darwin", ) -# -> darwin arm -rust.repository_set( - name = "rust_darwin_aarch64", - target_compatible_with = [ - "@platforms//cpu:arm64", - "@platforms//os:macos", - ], - target_triple = "aarch64-apple-darwin", -) use_repo(rust, "rust_toolchains") register_toolchains("@rust_toolchains//:all") @@ -421,9 +163,9 @@ crate.from_cargo( cargo_toml = "//:Cargo.toml", platform_triples = [ "aarch64-apple-darwin", - "aarch64-unknown-linux-gnu", + "aarch64-unknown-linux-musl", "x86_64-apple-darwin", - "x86_64-unknown-linux-gnu", + "x86_64-unknown-linux-musl", ], ) crate.annotation( diff --git a/bazel/include/cargo.MODULE.bazel b/bazel/include/cargo.MODULE.bazel index 44b8908b..ce15a206 100644 --- a/bazel/include/cargo.MODULE.bazel +++ b/bazel/include/cargo.MODULE.bazel @@ -16,9 +16,9 @@ crate.from_cargo( cargo_toml = "//:Cargo.toml", platform_triples = [ "aarch64-apple-darwin", - "aarch64-unknown-linux-gnu", + "aarch64-unknown-linux-musl", "x86_64-apple-darwin", - "x86_64-unknown-linux-gnu", + "x86_64-unknown-linux-musl", ], ) crate.annotation( diff --git a/bazel/include/llvm.MODULE.bazel b/bazel/include/llvm.MODULE.bazel index c0d8ed51..f496683c 100644 --- a/bazel/include/llvm.MODULE.bazel +++ b/bazel/include/llvm.MODULE.bazel @@ -1,129 +1,35 @@ # LLVM configuration -bazel_dep(name = "toolchains_llvm", version = "1.4.0") bazel_dep(name = "rules_cc", version = "0.2.11") +bazel_dep(name = "toolchains_llvm_bootstrapped", version = "0.2.5", dev_dependency = True) single_version_override( - module_name = "toolchains_llvm", + module_name = "toolchains_llvm_bootstrapped", patch_strip = 1, patches = [ - "//bazel/patches:toolchains_llvm.patch", + "//bazel/patches:llvm_darwin_sysroot.patch", ], ) -llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm", dev_dependency = True) - -execution_oses = [ - "macos", - "linux", -] - -execution_cpus = [ - "aarch64", - "x86_64", -] - -[ - [ - llvm.toolchain( - name = "llvm_toolchain_{}_{}".format(exec_os, exec_cpu), - exec_arch = exec_cpu, - exec_os = exec_os if exec_os != "macos" else "darwin", - llvm_version = "20.1.2", - ), - llvm.sysroot( - name = "llvm_toolchain_{}_{}".format(exec_os, exec_cpu), - label = "@org_chromium_sysroot_linux_x86_64//:sysroot", - targets = ["linux-x86_64"], - ), - llvm.sysroot( - name = "llvm_toolchain_{}_{}".format(exec_os, exec_cpu), - label = "@org_chromium_sysroot_linux_arm64//:sysroot", - targets = ["linux-aarch64"], - ), - llvm.sysroot( - name = "llvm_toolchain_{}_{}".format(exec_os, exec_cpu), - label = "@sysroot_darwin_universal//:sysroot", - targets = [ - "darwin-aarch64", - "darwin-x86_64", - ], - ), - use_repo(llvm, "llvm_toolchain_{}_{}".format(exec_os, exec_cpu)), - ] - for exec_os in execution_oses - for exec_cpu in execution_cpus -] - -http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - -_SYSROOT_LINUX_BUILD_FILE = """\ -filegroup( - name = "sysroot", - srcs = glob(["*/**"]), - visibility = ["//visibility:public"], -) -""" - -http_archive( - name = "org_chromium_sysroot_linux_arm64", - build_file_content = _SYSROOT_LINUX_BUILD_FILE, - sha256 = "b199942a0bd9c34800e8d7b669778ef45f2054b9f106039439383dd66efcef31", - urls = ["https://github.com/DavidZbarsky-at/sysroot-min/releases/download/v0.0.20/debian_bullseye_arm64_sysroot.tar.xz"], +register_toolchains( + "@toolchains_llvm_bootstrapped//toolchain:all", ) -http_archive( - name = "org_chromium_sysroot_linux_x86_64", - build_file_content = _SYSROOT_LINUX_BUILD_FILE, - sha256 = "b279dd2926e7d3860bb4e134997a45df5106f680e160a959b945580ba4ec755f", - urls = ["https://github.com/DavidZbarsky-at/sysroot-min/releases/download/v0.0.20/debian_bullseye_amd64_sysroot.tar.xz"], -) - -http_archive( - name = "sysroot_darwin_universal", - build_file_content = """ -filegroup( - name = "sysroot", - srcs = glob( - include = ["**"], - exclude = ["**/*:*"], - ), - visibility = ["//visibility:public"], -) -""", - integrity = "sha256-9qzGIJ251Wtn/K+R7B3v5Ici6esT3CH7kc/s6xSJ5X4=", - # The ruby header has an infinite symlink that we need to remove. - patch_cmds = ["rm System/Library/Frameworks/Ruby.framework/Versions/Current/Headers/ruby/ruby"], - strip_prefix = "MacOSX14.5.sdk", - urls = ["https://github.com/alexey-lysiuk/macos-sdk/releases/download/14.5/MacOSX14.5.tar.xz"], -) - -target_oses = [ - "macos", - "linux", -] - -target_cpus = [ - "aarch64", - "x86_64", -] - -platforms = [ - { - "exec_os": exec_os, - "exec_cpu": exec_cpu, - "tgt_os": tgt_os, - "tgt_cpu": tgt_cpu, - } - for exec_os in execution_oses - for exec_cpu in execution_cpus - for tgt_os in target_oses - for tgt_cpu in target_cpus -] - -[register_toolchains("//bazel/platforms/toolchains:{}_{}_{}_{}_llvm".format( - p["exec_os"], - p["exec_cpu"], - p["tgt_os"], - p["tgt_cpu"], -)) for p in platforms] +#http_archive( +# name = "sysroot_darwin_universal", +# build_file_content = """ +#filegroup( +# name = "sysroot", +# srcs = glob( +# include = ["**"], +# exclude = ["**/*:*"], +# ), +# visibility = ["//visibility:public"], +#) +#""", +# integrity = "sha256-9qzGIJ251Wtn/K+R7B3v5Ici6esT3CH7kc/s6xSJ5X4=", +# # The ruby header has an infinite symlink that we need to remove. +# patch_cmds = ["rm System/Library/Frameworks/Ruby.framework/Versions/Current/Headers/ruby/ruby"], +# strip_prefix = "MacOSX14.5.sdk", +# urls = ["https://github.com/alexey-lysiuk/macos-sdk/releases/download/14.5/MacOSX14.5.tar.xz"], +#) \ No newline at end of file diff --git a/bazel/include/rust.MODULE.bazel b/bazel/include/rust.MODULE.bazel index e414b2dd..054b6539 100644 --- a/bazel/include/rust.MODULE.bazel +++ b/bazel/include/rust.MODULE.bazel @@ -1,6 +1,13 @@ # Rust configuration bazel_dep(name = "rules_rust", version = "0.67.0") +single_version_override( + module_name = "rules_rust", + patch_strip = 1, + patches = [ + "//bazel/patches:rules_rust_musl_sysroot.patch", + ], +) bazel_dep(name = "openssl", version = "3.3.1.bcr.6") RUST_EDITION = "2024" @@ -11,187 +18,17 @@ rust = use_extension( "@rules_rust//rust:extensions.bzl", "rust", ) - -# These override the default rust_repository_sets created by rust_register_toolchain. They must be named exactly as follows. -# NB: The first call for a particular name may set the `edition`, `exec_triple`, and `versions` attributes, the subsequent calls should not set it or else Bazel will fail with, -# "Error in fail: You must only set edition on the first call to repository_set for a particular name but it was set multiple times for rust_linux_x86_64" -# "Error in fail: You must only set exec_triple on the first call to repository_set for a particular name but it was set multiple times for rust_linux_x86_64" -# "Error in fail: You must only set versions on the first call to repository_set for a particular name but it was set multiple times for rust_linux_x86_64" - -# Execution platform : linux x86 (x86_64-unknown-linux-gnu) -# -> linux x86_64 (gnu) -rust.repository_set( - name = "rust_linux_x86_64", - edition = RUST_EDITION, # "edition" only set in first instance of "rust_linux_x86_64" repository_set (see comment above) - exec_triple = "x86_64-unknown-linux-gnu", # "exec_triple" only set in first instance of "rust_linux_x86_64" repository_set (see comment above) - target_compatible_with = [ - "//bazel/platforms/linkers:unknown", - "@platforms//cpu:x86_64", - "@platforms//os:linux", - ], - target_triple = "x86_64-unknown-linux-gnu", - versions = [RUST_VERSION], # "versions" only set in first instance of "rust_linux_x86_64" repository_set (see comment above) -) - -# -> linux x86_64 (musl) -rust.repository_set( - name = "rust_linux_x86_64", - target_compatible_with = [ - "//bazel/platforms/linkers:unknown", - "@platforms//cpu:x86_64", - "@platforms//os:linux", - ], - target_triple = "x86_64-unknown-linux-musl", -) - -# -> linux arm (musl) -rust.repository_set( - name = "rust_linux_x86_64", - target_compatible_with = [ - "//bazel/platforms/linkers:unknown", - "@platforms//cpu:arm64", - "@platforms//os:linux", +rust.toolchain( + edition = RUST_EDITION, + versions = [RUST_VERSION], + extra_target_triples = [ + "aarch64-apple-darwin", + "x86_64-apple-darwin", + "aarch64-unknown-linux-musl", + "x86_64-unknown-linux-musl", ], - target_triple = "aarch64-unknown-linux-musl", ) -# -> darwin x86 -rust.repository_set( - name = "rust_linux_x86_64", - target_compatible_with = [ - "@platforms//cpu:x86_64", - "@platforms//os:macos", - ], - target_triple = "x86_64-apple-darwin", -) - -# -> darwin arm -rust.repository_set( - name = "rust_linux_x86_64", - target_compatible_with = [ - "@platforms//cpu:arm64", - "@platforms//os:macos", - ], - target_triple = "aarch64-apple-darwin", -) - -# Execution platform : linux arm (aarch64-unknown-linux-gnu) -# -> linux arm (gnu) -rust.repository_set( - name = "rust_linux_aarch64", - edition = RUST_EDITION, # "edition" only set in first instance of "rust_linux_aarch64" repository_set (see comment above) - exec_triple = "aarch64-unknown-linux-gnu", # "exec_triple" only set in first instance of "rust_linux_aarch64" repository_set (see comment above) - target_compatible_with = [ - "//bazel/platforms/linkers:unknown", - "@platforms//cpu:aarch64", - "@platforms//os:linux", - ], - target_triple = "aarch64-unknown-linux-gnu", - versions = [RUST_VERSION], # "versions" only set in first instance of "rust_linux_aarch64" repository_set (see comment above) -) - -# -> linux arm (musl) -rust.repository_set( - name = "rust_linux_aarch64", - target_compatible_with = [ - "//bazel/platforms/linkers:unknown", - "@platforms//cpu:aarch64", - "@platforms//os:linux", - ], - target_triple = "aarch64-unknown-linux-musl", -) - -# Execution platform : darwin x86 (x86_64-apple-darwin) -# -> linux x86 (musl) -rust.repository_set( - name = "rust_darwin_x86_64", - edition = RUST_EDITION, # "edition" only set in first instance of "rust_darwin_x86_64" repository_set (see comment above) - exec_triple = "x86_64-apple-darwin", # "exec_triple" only set in first instance of "rust_darwin_x86_64" repository_set (see comment above) - target_compatible_with = [ - "//bazel/platforms/linkers:unknown", - "@platforms//cpu:x86_64", - "@platforms//os:linux", - ], - target_triple = "x86_64-unknown-linux-musl", - versions = [RUST_VERSION], # "versions" only set in first instance of "rust_darwin_x86_64" repository_set (see comment above) -) - -# -> linux arm (musl) -rust.repository_set( - name = "rust_darwin_x86_64", - target_compatible_with = [ - "//bazel/platforms/linkers:unknown", - "@platforms//cpu:arm64", - "@platforms//os:linux", - ], - target_triple = "aarch64-unknown-linux-musl", -) - -# -> darwin x86 -rust.repository_set( - name = "rust_darwin_x86_64", - target_compatible_with = [ - "@platforms//cpu:x86_64", - "@platforms//os:macos", - ], - target_triple = "x86_64-apple-darwin", -) - -# -> darwin arm -rust.repository_set( - name = "rust_darwin_x86_64", - target_compatible_with = [ - "@platforms//cpu:arm64", - "@platforms//os:macos", - ], - target_triple = "aarch64-apple-darwin", -) - -# Execution platform : darwin arm (aarch64-apple-darwin) -# -> linux x86 (musl) -rust.repository_set( - name = "rust_darwin_aarch64", - edition = RUST_EDITION, # "edition" only set in first instance of "rust_darwin_aarch64" repository_set (see comment above) - exec_triple = "aarch64-apple-darwin", # "exec_triple" only set in first instance of "rust_darwin_aarch64" repository_set (see comment above) - target_compatible_with = [ - "//bazel/platforms/linkers:unknown", - "@platforms//cpu:x86_64", - "@platforms//os:linux", - ], - target_triple = "x86_64-unknown-linux-musl", - versions = [RUST_VERSION], # "versions" only set in first instance of "rust_darwin_aarch64" repository_set (see comment above) -) - -# -> linux arm (musl) -rust.repository_set( - name = "rust_darwin_aarch64", - target_compatible_with = [ - "//bazel/platforms/linkers:unknown", - "@platforms//cpu:arm64", - "@platforms//os:linux", - ], - target_triple = "aarch64-unknown-linux-musl", -) - -# -> darwin x86 -rust.repository_set( - name = "rust_darwin_aarch64", - target_compatible_with = [ - "@platforms//cpu:x86_64", - "@platforms//os:macos", - ], - target_triple = "x86_64-apple-darwin", -) - -# -> darwin arm -rust.repository_set( - name = "rust_darwin_aarch64", - target_compatible_with = [ - "@platforms//cpu:arm64", - "@platforms//os:macos", - ], - target_triple = "aarch64-apple-darwin", -) use_repo(rust, "rust_toolchains") register_toolchains("@rust_toolchains//:all") diff --git a/bazel/patches/llvm_darwin_sysroot.patch b/bazel/patches/llvm_darwin_sysroot.patch new file mode 100644 index 00000000..dd597aac --- /dev/null +++ b/bazel/patches/llvm_darwin_sysroot.patch @@ -0,0 +1,50 @@ +diff --git a/MODULE.bazel b/MODULE.bazel +index ec9c2e8..1a3f93c 100644 +--- a/MODULE.bazel ++++ b/MODULE.bazel +@@ -73,16 +73,13 @@ http_archive( + build_file = "//third_party/libc/musl:BUILD.tpl", + ) + +-http_pkg_archive = use_repo_rule("//:http_pkg_archive.bzl", "http_pkg_archive") +-http_pkg_archive( ++http_archive( + name = "macosx15.4.sdk", +- urls = ["https://swcdn.apple.com/content/downloads/10/32/082-12052-A_AHPGDY76PT/1a419zaf3vh8o9t3c0usblyr8eystpnsh5/CLTools_macOSNMOS_SDK.pkg"], +- strip_files = [ +- "Library/Developer/CommandLineTools/SDKs/MacOSX15.4.sdk/System/Library/Frameworks/Ruby.framework/Versions/Current/Headers/ruby", +- ], +- sha256 = "f8b0600aa4ad9b0b0b150fb62691dc561f47bc33ebc40546439f1460a0680913", ++ urls = ["https://github.com/alexey-lysiuk/macos-sdk/releases/download/14.5/MacOSX14.5.tar.xz"], ++ patch_cmds = ["rm System/Library/Frameworks/Ruby.framework/Versions/Current/Headers/ruby/ruby"], ++ integrity = "sha256-9qzGIJ251Wtn/K+R7B3v5Ici6esT3CH7kc/s6xSJ5X4=", + build_file = "//third_party/macosx.sdk:BUILD.MacOSX15.4.sdk.tpl", +- strip_prefix = "Library/Developer/CommandLineTools/SDKs/MacOSX15.4.sdk", ++ strip_prefix = "MacOSX14.5.sdk", + ) + + glibc = use_extension("//runtimes/glibc/extension:glibc.bzl", "glibc") +diff --git a/third_party/llvm-project/20.x/compiler-rt/BUILD.tpl b/third_party/llvm-project/20.x/compiler-rt/BUILD.tpl +index b3b0495..a6e347c 100644 +--- a/third_party/llvm-project/20.x/compiler-rt/BUILD.tpl ++++ b/third_party/llvm-project/20.x/compiler-rt/BUILD.tpl +@@ -301,6 +301,7 @@ cc_stage2_library( + srcs = select({ + "@toolchains_llvm_bootstrapped//platforms/config:linux_x86_64": [":builtins_x86_64_sources"], + "@toolchains_llvm_bootstrapped//platforms/config:linux_aarch64": [":builtins_aarch64_sources"], ++ "@toolchains_llvm_bootstrapped//platforms/config:macos_x86_64": [":builtins_x86_64_sources"], + "@toolchains_llvm_bootstrapped//platforms/config:macos_aarch64": [":builtins_aarch64_sources"], + }, no_match_error = """ + Platform not supported for compiler-rt.builtins. +diff --git a/toolchain/args/BUILD.bazel b/toolchain/args/BUILD.bazel +index 9700506..f66d5ca 100644 +--- a/toolchain/args/BUILD.bazel ++++ b/toolchain/args/BUILD.bazel +@@ -29,6 +29,7 @@ cc_args( + "//platforms/config/libc_aware:linux_aarch64_gnu": ["aarch64-linux-gnu"], + "//platforms/config/libc_aware:linux_x86_64_musl": ["x86_64-linux-musl"], + "//platforms/config/libc_aware:linux_aarch64_musl": ["aarch64-linux-musl"], ++ "//platforms/config:macos_x86_64": ["x86_64-apple-darwin"], + "//platforms/config:macos_aarch64": ["aarch64-apple-darwin"], + }, no_match_error = "Unsupported platform"), + ) diff --git a/bazel/patches/rules_rust_musl_sysroot.patch b/bazel/patches/rules_rust_musl_sysroot.patch new file mode 100644 index 00000000..12f16315 --- /dev/null +++ b/bazel/patches/rules_rust_musl_sysroot.patch @@ -0,0 +1,24 @@ +diff --git a/rust/private/repository_utils.bzl b/rust/private/repository_utils.bzl +index 39f002d4c..3def0f431 100644 +--- a/rust/private/repository_utils.bzl ++++ b/rust/private/repository_utils.bzl +@@ -241,7 +241,6 @@ rust_stdlib_filegroup( + "lib/rustlib/{target_triple}/lib/*.rlib", + "lib/rustlib/{target_triple}/lib/*{dylib_ext}*", + "lib/rustlib/{target_triple}/lib/*{staticlib_ext}", +- "lib/rustlib/{target_triple}/lib/self-contained/**", + ], + # Some patterns (e.g. `lib/*.a`) don't match anything, see https://github.com/bazelbuild/rules_rust/pull/245 + allow_empty = True, +diff --git a/rust/toolchain.bzl b/rust/toolchain.bzl +index f3ef2f298..f54ab83b0 100644 +--- a/rust/toolchain.bzl ++++ b/rust/toolchain.bzl +@@ -50,6 +50,7 @@ def _rust_stdlib_filegroup_impl(ctx): + for file in rust_std + if file.basename.endswith(".o") and "self-contained" in file.path + ] ++ self_contained_files = [] + panic_files = [] + + std_rlibs = [f for f in rust_std if f.basename.endswith(".rlib")] diff --git a/bazel/patches/toolchains_llvm.patch b/bazel/patches/toolchains_llvm.patch deleted file mode 100644 index 8211a1cd..00000000 --- a/bazel/patches/toolchains_llvm.patch +++ /dev/null @@ -1,88 +0,0 @@ -diff --git a/toolchain/cc_toolchain_config.bzl b/toolchain/cc_toolchain_config.bzl -index 3a66da7..3f5acc4 100644 ---- a/toolchain/cc_toolchain_config.bzl -+++ b/toolchain/cc_toolchain_config.bzl -@@ -192,11 +192,18 @@ def cc_toolchain_config( - archive_flags = [] - - # Linker flags: -- if exec_os == "darwin" and not is_xcompile: -- # lld is experimental for Mach-O, so we use the native ld64 linker. -- # TODO: How do we cross-compile from Linux to Darwin? -- use_lld = False -+ ld = "ld.lld" -+ if target_os == "darwin": -+ use_lld = True -+ -+ ld = "ld64.lld" -+ ld_path = toolchain_path_prefix + "/bin/" + ld -+ compile_flags.append("-mmacosx-version-min=12.0") -+ - link_flags.extend([ -+ "-mmacosx-version-min=12.0", -+ "-Wl,-platform_version,macos,12.0,12.0", -+ "--ld-path=" + ld_path, - "-headerpad_max_install_names", - "-fobjc-link-runtime", - ]) -@@ -219,7 +226,9 @@ def cc_toolchain_config( - # not an option because it is not a cross-linker, so lld is the - # only option. - use_lld = True -+ ld_path = toolchain_path_prefix + "/bin/" + ld - link_flags.extend([ -+ "--ld-path=" + ld_path, - "-fuse-ld=lld", - "-Wl,--build-id=md5", - "-Wl,--hash-style=gnu", -@@ -252,10 +261,6 @@ def cc_toolchain_config( - if use_lld: - # For single-platform builds, we can statically link the bundled - # libraries. -- link_flags.extend([ -- "-l:libc++.a", -- "-l:libc++abi.a", -- ]) - compiler_rt_link_flags = ["-rtlib=compiler-rt"] - libunwind_link_flags = [ - "-l:libunwind.a", -@@ -306,10 +311,6 @@ def cc_toolchain_config( - "-std=" + cxx_standard, - "-stdlib=libstdc++", - ] -- -- link_flags.extend([ -- "-l:libstdc++.a", -- ]) - elif stdlib == "libc": - cxx_flags = [ - "-std=" + cxx_standard, -@@ -347,7 +348,7 @@ def cc_toolchain_config( - "dwp": tools_path_prefix + "llvm-dwp", - "gcc": wrapper_bin_prefix + "cc_wrapper.sh", - "gcov": tools_path_prefix + "llvm-profdata", -- "ld": tools_path_prefix + "ld.lld" if use_lld else "/usr/bin/ld", -+ "ld": tools_path_prefix + ld if use_lld else "/usr/bin/ld", - "llvm-cov": tools_path_prefix + "llvm-cov", - "llvm-profdata": tools_path_prefix + "llvm-profdata", - "nm": tools_path_prefix + "llvm-nm", -diff --git a/toolchain/internal/common.bzl b/toolchain/internal/common.bzl -index b5d8e57..7da2734 100644 ---- a/toolchain/internal/common.bzl -+++ b/toolchain/internal/common.bzl -@@ -34,6 +34,7 @@ _toolchain_tools = { - "clang-tidy", - "clangd", - "ld.lld", -+ "ld64.lld", - "llvm-ar", - "llvm-dwp", - "llvm-profdata", -@@ -251,6 +252,5 @@ def attr_dict(attr): - - def toolchain_tools(os): - tools = dict(_toolchain_tools) -- if os == "darwin": -- tools.update(_toolchain_tools_darwin) -+ tools.update(_toolchain_tools_darwin) - return tools diff --git a/uv/private/constraints/platform/defs.bzl b/uv/private/constraints/platform/defs.bzl index bb257927..0f84ba19 100644 --- a/uv/private/constraints/platform/defs.bzl +++ b/uv/private/constraints/platform/defs.bzl @@ -60,7 +60,7 @@ def _platform_version_at_least_impl(ctx): current = tuple([ int(x) - for x in flag_value.split(".") + for x in flag_value.strip().split(".") ]) at_least = tuple([int(x) for x in ctx.attr.at_least.split(".")]) diff --git a/uv/private/host/repository.bzl b/uv/private/host/repository.bzl index c0e38fc4..5c5a4ac6 100644 --- a/uv/private/host/repository.bzl +++ b/uv/private/host/repository.bzl @@ -24,7 +24,7 @@ def _platform(rctx): if os == "osx": res = rctx.execute(["sw_vers", "-productVersion"]) - ver = res.stdout.split(".") + ver = res.stdout.strip().split(".") return "libsystem", "{}.{}".format(ver[0], ver[1]) elif os == "linux":