Skip to content
Open
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
4 changes: 2 additions & 2 deletions crate_universe/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crate_universe/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ cargo_metadata = "0.19.2"
cargo_toml = "0.22.1"
cargo-lock = "10.1.0"
cargo-platform = "0.1.9"
cfg-expr = "0.18.0"
cfg-expr = "0.20.4"
clap = { version = "4.5.37", features = ["derive", "env"] }
crates-index = { version = "3.7.0", default-features = false, features = [
"git",
Expand Down
2 changes: 1 addition & 1 deletion examples/all_deps_vendor/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ local_path_override(
# Rust toolchain
RUST_EDITION = "2021"

RUST_VERSION = "1.79.0"
RUST_VERSION = "1.86.0"

rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
rust.toolchain(
Expand Down
20 changes: 20 additions & 0 deletions rust/platform/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,26 @@ constraint_value(
constraint_setting = ":wasi_version",
)

constraint_setting(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would actually like to avoid adding constraint values like this into rules_rust. I've been seeing more activity on bazelbuild/platforms#38 and want to use whatever pattern comes from this issue for constraints like this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@UebelAndre Fine for me, I would then simply apply this as a patch for our org as long as there's no decision on the mentioned issue. However, I don't feel like I can contribute much there due to my lack of the overall picture and how things should be. May I ask you to put a comment in the issue about how to move forward and come to a conclusion over there?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@UebelAndre since the activity in the mentioned ticket was stalled for 3 years, is there a chance that we say ie, if nothing moves during next month we can try continue in here ? Because rules_rust are important part of bazel and QNX8 is more and more used target - it would make sense to have support for it im my opinion. Otherwise it can happen bazelbuild/platforms#38 will block this next 3 years.

name = "qnx_version",
default_constraint_value = ":qnx7", # For backwards compatibility
)

constraint_value(
name = "qnx7",
constraint_setting = ":qnx_version",
)

constraint_value(
name = "qnx7_iosock",
constraint_setting = ":qnx_version",
)

constraint_value(
name = "qnx8",
constraint_setting = ":qnx_version",
)

package_group(
name = "function_transition_allowlist",
packages = [
Expand Down
14 changes: 14 additions & 0 deletions rust/platform/triple_mappings.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@ SUPPORTED_T2_PLATFORM_TRIPLES = {

_T3_PLATFORM_TRIPLES = {
"aarch64-unknown-nto-qnx710": _support(std = True, host_tools = False),
"aarch64-unknown-nto-qnx710_iosock": _support(std = True, host_tools = False),
"aarch64-unknown-nto-qnx800": _support(std = True, host_tools = False),
"wasm64-unknown-unknown": _support(std = False, host_tools = False),
"x86_64-pc-nto-qnx710": _support(std = True, host_tools = False),
"x86_64-pc-nto-qnx710_iosock": _support(std = True, host_tools = False),
"x86_64-pc-nto-qnx800": _support(std = True, host_tools = False),
}

# The only T3 triples that are supported are ones with at least a stdlib
Expand Down Expand Up @@ -282,6 +287,12 @@ _SYSTEM_TO_STDLIB_LINKFLAGS = {
"windows": ["advapi32.lib", "ws2_32.lib", "userenv.lib", "Bcrypt.lib"],
}

_NTO_ABI_TO_CONSTRAINT = {
"qnx710": "@rules_rust//rust/platform:qnx7",
"qnx710_iosock": "@rules_rust//rust/platform:qnx7_iosock",
"qnx800": "@rules_rust//rust/platform:qnx8",
}

def cpu_arch_to_constraints(cpu_arch, *, system = None):
"""Returns a list of constraint values which represents a triple's CPU.

Expand Down Expand Up @@ -346,6 +357,9 @@ def abi_to_constraints(abi, *, arch = None, system = None):
else:
all_abi_constraints.append("@build_bazel_apple_support//constraints:device")

if system == "nto":
all_abi_constraints.append(_NTO_ABI_TO_CONSTRAINT[abi])

# TODO(bazelbuild/platforms#38): Implement when C++ toolchain is more mature and we
# figure out how they're doing this
return all_abi_constraints
Expand Down
4 changes: 3 additions & 1 deletion rust/private/rustc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ AliasableDepInfo = provider(

_error_format_values = ["human", "json", "short"]

_OS_WITH_DYLINK_SUPPORT = ["linux", "darwin", "macos", "android", "nto"]

ErrorFormatInfo = provider(
doc = "Set the --error-format flag for all rustc invocations",
fields = {"error_format": "(string) [" + ", ".join(_error_format_values) + "]"},
Expand Down Expand Up @@ -1974,7 +1976,7 @@ def _compute_rpaths(toolchain, output_dir, dep_info, use_pic):
# without a version of Bazel that includes
# https://github.com/bazelbuild/bazel/pull/13427. This is known to not be
# included in Bazel 4.1 and below.
if toolchain.target_os not in ["linux", "darwin", "macos", "android"]:
if toolchain.target_os not in _OS_WITH_DYLINK_SUPPORT:
fail("Runtime linking is not supported on {}, but found {}".format(
toolchain.target_os,
dep_info.transitive_noncrates,
Expand Down
5 changes: 5 additions & 0 deletions test/unit/platform_triple/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
load(":platform_triple_test.bzl", "platform_triple_test_suite")
load(":wasi_platform_test.bzl", "wasi_platform_test_suite")
load(":qnx_version_test.bzl", "qnx_version_constraints_test")

platform_triple_test_suite(
name = "platform_triple_test_suite",
Expand All @@ -8,3 +9,7 @@ platform_triple_test_suite(
wasi_platform_test_suite(
name = "wasi_platform_test_suite",
)

qnx_version_constraints_test(
name = "qnx_version_test_suite",
)
108 changes: 108 additions & 0 deletions test/unit/platform_triple/qnx_version_test.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
"""Tests for WASI platform constraint mappings"""

load("@bazel_skylib//lib:unittest.bzl", "asserts", "unittest")
load("//rust/platform:triple_mappings.bzl", "triple_to_constraint_set")

def _qnx_version_constraints_test_impl(ctx):
env = unittest.begin(ctx)

# Test aarch64 QNX7 constraints
qnx_version_constraints = triple_to_constraint_set("aarch64-unknown-nto-qnx710")
asserts.equals(
env,
[
"@platforms//cpu:aarch64",
"@platforms//os:qnx",
"@rules_rust//rust/platform:qnx7",
],
qnx_version_constraints,
"aarch64-unknown-nto-qnx710 doesn't map to the appropriate constraints",
)

# Test aarch64 QNX7 with iopkt constraints
qnx_version_constraints = triple_to_constraint_set("aarch64-unknown-nto-qnx710_iosock")
asserts.equals(
env,
[
"@platforms//cpu:aarch64",
"@platforms//os:qnx",
"@rules_rust//rust/platform:qnx7_iosock",
],
qnx_version_constraints,
"aarch64-unknown-nto-qnx710_iosock doesn't map to the appropriate constraints",
)

# Test aarch64 QNX8 constraints
qnx_version_constraints = triple_to_constraint_set("aarch64-unknown-nto-qnx800")
asserts.equals(
env,
[
"@platforms//cpu:aarch64",
"@platforms//os:qnx",
"@rules_rust//rust/platform:qnx8",
],
qnx_version_constraints,
"aarch64-unknown-nto-qnx800 doesn't map to the appropriate constraints",
)

# Test x86_64 QNX7 constraints
qnx_version_constraints = triple_to_constraint_set("x86_64-pc-nto-qnx710")
asserts.equals(
env,
[
"@platforms//cpu:x86_64",
"@platforms//os:qnx",
"@rules_rust//rust/platform:qnx7",
],
qnx_version_constraints,
"x86_64-pc-nto-qnx710 doesn't map to the appropriate constraints",
)

# Test x86_64 QNX7 with iosock constraints
qnx_version_constraints = triple_to_constraint_set("x86_64-pc-nto-qnx710_iosock")
asserts.equals(
env,
[
"@platforms//cpu:x86_64",
"@platforms//os:qnx",
"@rules_rust//rust/platform:qnx7_iosock",
],
qnx_version_constraints,
"x86_64-pc-nto-qnx710_iosock doesn't map to the appropriate constraints",
)

# Test x86_64 QNX8 constraints
qnx_version_constraints = triple_to_constraint_set("x86_64-pc-nto-qnx800")
asserts.equals(
env,
[
"@platforms//cpu:x86_64",
"@platforms//os:qnx",
"@rules_rust//rust/platform:qnx8",
],
qnx_version_constraints,
"x86_64-pc-nto-qnx800 doesn't map to the appropriate constraints",
)

return unittest.end(env)

_qnx_version_constraints_test = unittest.make(_qnx_version_constraints_test_impl)

def qnx_version_constraints_test(name, **kwargs):
"""Define a test suite for the QNX version to constraints mappings

Args:
name (str): The name of the test suite.
**kwargs (dict): Additional keyword arguments for the test_suite.
"""
_qnx_version_constraints_test(
name = "qnx_version_constraints_test",
)

native.test_suite(
name = name,
tests = [
":qnx_version_constraints_test",
],
**kwargs
)