diff --git a/MODULE.bazel b/MODULE.bazel index a03eb49a01..21a6e53339 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -160,9 +160,9 @@ bazel_dep(name = "rules_multirun", version = "0.9.0", dev_dependency = True) bazel_dep(name = "bazel_ci_rules", version = "1.0.0", dev_dependency = True) bazel_dep(name = "rules_pkg", version = "1.2.0", dev_dependency = True) -# Rust toolchains to cross-compile the release artifacts for other Linux CPUs -# from Linux x86_64; see dev/release_artifacts. They target musl, which Rust can -# link statically with its bundled rust-lld, so no C cross toolchain is needed. +# Rust toolchains to build the release artifacts for Linux from Linux x86_64; +# see dev/release_artifacts. They target musl, which Rust can link statically +# with its bundled rust-lld, so no C cross toolchain is needed. rust = use_extension( "@rules_rust//rust:extensions.bzl", "rust", @@ -227,6 +227,15 @@ rust.repository_set( ], target_triple = "riscv64gc-unknown-linux-musl", ) +rust.repository_set( + name = "rust_release_linux", + target_compatible_with = [ + "@platforms//cpu:x86_64", + "@platforms//os:linux", + "//dev/platforms:musl", + ], + target_triple = "x86_64-unknown-linux-musl", +) use_repo( rust, "rust_release_linux__aarch64-unknown-linux-musl__stable", @@ -234,6 +243,7 @@ use_repo( "rust_release_linux__i686-unknown-linux-musl__stable", "rust_release_linux__powerpc64le-unknown-linux-musl__stable", "rust_release_linux__riscv64gc-unknown-linux-musl__stable", + "rust_release_linux__x86_64-unknown-linux-musl__stable", ) # Registered here so that they take precedence over rules_rust's default @@ -245,6 +255,7 @@ register_toolchains( "@rust_release_linux__i686-unknown-linux-musl__stable//:toolchain", "@rust_release_linux__powerpc64le-unknown-linux-musl__stable//:toolchain", "@rust_release_linux__riscv64gc-unknown-linux-musl__stable//:toolchain", + "@rust_release_linux__x86_64-unknown-linux-musl__stable//:toolchain", dev_dependency = True, ) diff --git a/dev/platforms/BUILD.bazel b/dev/platforms/BUILD.bazel index 17f19cc357..590d30215d 100644 --- a/dev/platforms/BUILD.bazel +++ b/dev/platforms/BUILD.bazel @@ -111,10 +111,11 @@ platform( ) platform( - name = "x86_64-unknown-linux-gnu", + name = "x86_64-unknown-linux-musl", constraint_values = [ "@platforms//cpu:x86_64", "@platforms//os:linux", + ":musl", ], ) diff --git a/dev/release_artifacts/BUILD.bazel b/dev/release_artifacts/BUILD.bazel index 26895e1190..54d26f4b83 100644 --- a/dev/release_artifacts/BUILD.bazel +++ b/dev/release_artifacts/BUILD.bazel @@ -40,7 +40,7 @@ cross_compiled_files( "//dev/platforms:i686-unknown-linux-musl", "//dev/platforms:powerpc64le-unknown-linux-musl", "//dev/platforms:riscv64gc-unknown-linux-musl", - "//dev/platforms:x86_64-unknown-linux-gnu", + "//dev/platforms:x86_64-unknown-linux-musl", ], ":is_macos_aarch64": ["//dev/platforms:x86_64-apple-darwin"], ":is_windows_x86_64": ["//dev/platforms:i686-pc-windows-msvc"], diff --git a/dev/release_artifacts/release_files.bzl b/dev/release_artifacts/release_files.bzl index e9604cd9a3..b91541df5b 100644 --- a/dev/release_artifacts/release_files.bzl +++ b/dev/release_artifacts/release_files.bzl @@ -123,7 +123,7 @@ def release_files(name, srcs, **kwargs): machine's, without extra runtime libraries. The paths, one per line, are relative to the execroot, e.g. - `bazel-out/k8-opt/bin/dev/release_artifacts/foo-x86_64-unknown-linux-gnu`. + `bazel-out/k8-opt/bin/dev/release_artifacts/foo-x86_64-unknown-linux-musl`. Paths of generated files also resolve from the workspace root through the `bazel-out` convenience symlink. This lets scripts find the files without running `bazel cquery`, which re-analyzes the build. diff --git a/tests/workflows/release_artifacts_test.py b/tests/workflows/release_artifacts_test.py index c503d7aa3b..cce70a4b63 100644 --- a/tests/workflows/release_artifacts_test.py +++ b/tests/workflows/release_artifacts_test.py @@ -22,7 +22,7 @@ def test_generate_artifacts_manifest(tmp_path: Path): artifacts_dir.mkdir(parents=True) manifest_file = tmp_path / "artifacts_manifest.bzl" - linux_bin = artifacts_dir / "exe_zip_maker-x86_64-unknown-linux-gnu" + linux_bin = artifacts_dir / "exe_zip_maker-x86_64-unknown-linux-musl" linux_bin.write_bytes(b"linux-binary-contents") linux_sha = hashlib.sha256(b"linux-binary-contents").hexdigest() @@ -76,9 +76,9 @@ def test_generate_artifacts_manifest(tmp_path: Path): "@platforms//cpu:x86_64", "@platforms//os:linux", ], - "name": "exe_zip_maker_x86_64_unknown_linux_gnu", + "name": "exe_zip_maker_x86_64_unknown_linux_musl", "sha256": linux_sha, - "urls": [f"{base_url}/exe_zip_maker-x86_64-unknown-linux-gnu"], + "urls": [f"{base_url}/exe_zip_maker-x86_64-unknown-linux-musl"], }, ] }