Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ common --repo_env=BAZEL_NO_APPLE_CPP_TOOLCHAIN=1

common:ci --toolchain_resolution_debug='@@bazel_tools//tools/cpp:toolchain_type'

# rules_rs experimental toolchains require @llvm//constraints/libc:gnu.2.28 on the target
# platform for gnu Linux targets. The auto-detected host platform doesn't include it, so we
# use a custom platform that inherits host cpu/os constraints and adds gnu.2.28. This works
# on both x86_64 and aarch64 Linux builders.
# --enable_platform_specific_config (in defaults.bazelrc) makes this activate automatically on Linux.
common:linux --platforms=//bazel/platforms:linux_gnu
common:linux --host_platform=//bazel/platforms:linux_gnu

common:release --build_tag_filters=release
common:release --stamp
common:release --compilation_mode=opt
Expand Down
36 changes: 19 additions & 17 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ bazel_dep(name = "rules_pkg", version = "1.1.0")
bazel_dep(name = "rules_python", version = "1.0.0")
bazel_dep(name = "rules_shell", version = "0.6.1")
bazel_dep(name = "tar.bzl", version = "0.5.5")
bazel_dep(name = "with_cfg.bzl", version = "0.14.1")
bazel_dep(name = "with_cfg.bzl", version = "0.14.6")
Comment thread
jbedard marked this conversation as resolved.

bazel_lib_toolchains = use_extension("@tar.bzl//tar:extensions.bzl", "toolchains")
use_repo(bazel_lib_toolchains, "bsd_tar_toolchains")
Expand Down Expand Up @@ -130,29 +130,29 @@ osx.from_archive(
"https://github.com/joseluisq/macosx-sdks/releases/download/26.1/MacOSX26.1.sdk.tar.xz",
],
)
use_repo(osx, "macos_sdk")

# Rust configuration
bazel_dep(name = "rules_rust", version = "0.68.1", dev_dependency = IS_RELEASE)
# Rust configuration (via rules_rs's bundled rules_rust)
rules_rust_ext = use_extension(
"@rules_rs//rs:rules_rust.bzl",
"rules_rust",
dev_dependency = IS_RELEASE,
)
use_repo(rules_rust_ext, "rules_rust")

rust = use_extension(
"@rules_rust//rust:extensions.bzl",
"rust",
toolchains = use_extension(
"@rules_rs//rs/toolchains:module_extension.bzl",
"toolchains",
dev_dependency = IS_RELEASE,
)
rust.toolchain(
toolchains.toolchain(
edition = "2024",
extra_target_triples = [
"aarch64-apple-darwin",
"x86_64-apple-darwin",
"aarch64-unknown-linux-musl",
"x86_64-unknown-linux-musl",
],
versions = ["1.88.0"],
version = "1.88.0",
)
use_repo(rust, "rust_toolchains")
use_repo(toolchains, "default_rust_toolchains")

register_toolchains(
"@rust_toolchains//:all",
"@default_rust_toolchains//:all",
dev_dependency = IS_RELEASE,
)

Expand All @@ -163,7 +163,7 @@ bazel_dep(name = "bazel_env.bzl", version = "0.5.0", dev_dependency = IS_RELEASE
bazel_dep(name = "bzip2", version = "1.0.8.bcr.3", dev_dependency = IS_RELEASE)
bazel_dep(name = "gazelle", version = "0.47.0", dev_dependency = IS_RELEASE)
bazel_dep(name = "rules_go", version = "0.60.0", dev_dependency = IS_RELEASE)
bazel_dep(name = "rules_rs", version = "0.0.26", dev_dependency = IS_RELEASE)
bazel_dep(name = "rules_rs", version = "0.0.64", dev_dependency = IS_RELEASE)
bazel_dep(name = "xz", version = "5.4.5.bcr.7", dev_dependency = IS_RELEASE)
bazel_dep(name = "zstd", version = "1.5.7", dev_dependency = IS_RELEASE)
bazel_dep(name = "rules_multitool", version = "1.9.0", dev_dependency = IS_RELEASE)
Expand All @@ -183,8 +183,10 @@ 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",
],
)
Expand Down
17 changes: 16 additions & 1 deletion bazel/platforms/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ load("//bazel/platforms/config:defs.bzl", "linker_suffix", "platforms")
"@platforms//os:{}".format(p.os),
"@platforms//cpu:{}".format(p.cpu),
"//bazel/platforms/linkers:{}".format(p.linker),
],
] + ([
"@llvm//constraints/libc:musl",
"@llvm//constraints/pie:off",
] if p.os == "linux" else []),
visibility = ["//visibility:public"],
) for p in platforms]

Expand All @@ -29,6 +32,18 @@ alias(
visibility = ["//visibility:public"],
)

# A host-compatible Linux platform with glibc 2.28+, used as the build target
# and exec platform on Linux. Inherits cpu/os from the auto-detected host so
# it works on both x86_64 and aarch64 builders without separate entries.
platform(
name = "linux_gnu",
constraint_values = [
"@llvm//constraints/libc:gnu.2.28",
],
parents = ["@platforms//host"],
visibility = ["//visibility:public"],
)

platform(
name = "rbe",
constraint_values = [
Expand Down
7 changes: 7 additions & 0 deletions e2e/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ common --@rules_cc//cc/toolchains/args/archiver_flags:use_libtool_on_macos=false
common --repo_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
common --repo_env=BAZEL_NO_APPLE_CPP_TOOLCHAIN=1

# rules_rs experimental toolchains require @llvm//constraints/libc:gnu.2.28 on the target
# platform for gnu Linux targets. The auto-detected host platform doesn't include it, so we
# use a custom platform that inherits host cpu/os constraints and adds gnu.2.28.
common --enable_platform_specific_config
common:linux --platforms=@aspect_rules_py//bazel/platforms:linux_gnu
common:linux --host_platform=@aspect_rules_py//bazel/platforms:linux_gnu

# Configure a default venv
# common --@pypi//venv=say

Expand Down
4 changes: 4 additions & 0 deletions e2e/cases/freethreaded-805/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ load("@bazel_lib//lib:transitions.bzl", "platform_transition_test")

platform(
name = "freethreaded",
constraint_values = [
# rules_rs Rust toolchains for linux-gnu targets require gnu.2.28.
"@llvm//constraints/libc:gnu.2.28",
],
flags = [
"--@aspect_rules_py//py/private/interpreter:freethreaded=true",
],
Expand Down
2 changes: 2 additions & 0 deletions e2e/cases/interpreter-features-836/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ platform(
constraint_values = [
"@platforms//os:linux",
"@platforms//cpu:x86_64",
# rules_rs Rust toolchains for linux-gnu targets require gnu.2.28.
"@llvm//constraints/libc:gnu.2.28",
],
flags = [
"--@aspect_rules_py//py/private/interpreter:exclude_feature=turtle",
Expand Down
4 changes: 4 additions & 0 deletions e2e/cases/oci/py_image_layer/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ platform(
constraint_values = [
"@platforms//os:linux",
"@platforms//cpu:aarch64",
# rules_rs Rust toolchains for linux-gnu targets require gnu.2.28.
"@llvm//constraints/libc:gnu.2.28",
],
)

Expand All @@ -17,6 +19,8 @@ platform(
constraint_values = [
"@platforms//os:linux",
"@platforms//cpu:x86_64",
# rules_rs Rust toolchains for linux-gnu targets require gnu.2.28.
"@llvm//constraints/libc:gnu.2.28",
],
)

Expand Down
4 changes: 4 additions & 0 deletions e2e/cases/oci/py_venv_image_layer/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ platform(
constraint_values = [
"@platforms//os:linux",
"@platforms//cpu:aarch64",
# rules_rs Rust toolchains for linux-gnu targets require gnu.2.28.
"@llvm//constraints/libc:gnu.2.28",
],
flags = [
"--@aspect_rules_py//uv/private/constraints/platform:platform_libc=glibc",
Expand All @@ -25,6 +27,8 @@ platform(
constraint_values = [
"@platforms//os:linux",
"@platforms//cpu:x86_64",
# rules_rs Rust toolchains for linux-gnu targets require gnu.2.28.
"@llvm//constraints/libc:gnu.2.28",
],
flags = [
"--@aspect_rules_py//uv/private/constraints/platform:platform_libc=glibc",
Expand Down
4 changes: 4 additions & 0 deletions e2e/cases/uv-deps-650/crossbuild/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ platform(
constraint_values = [
"@platforms//os:linux",
"@platforms//cpu:aarch64",
# rules_rs Rust toolchains for linux-gnu targets require gnu.2.28.
"@llvm//constraints/libc:gnu.2.28",
],
flags = [
"--@aspect_rules_py//uv/private/constraints/platform:platform_libc=glibc",
Expand All @@ -25,6 +27,8 @@ platform(
constraint_values = [
"@platforms//os:linux",
"@platforms//cpu:x86_64",
# rules_rs Rust toolchains for linux-gnu targets require gnu.2.28.
"@llvm//constraints/libc:gnu.2.28",
],
flags = [
"--@aspect_rules_py//uv/private/constraints/platform:platform_libc=glibc",
Expand Down
2 changes: 2 additions & 0 deletions py/tests/py-pex-binary/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ platform(
constraint_values = [
"@platforms//os:linux",
"@platforms//cpu:x86_64",
# rules_rs Rust toolchains for linux-gnu targets require gnu.2.28.
"@llvm//constraints/libc:gnu.2.28",
],
)

Expand Down