Skip to content

Commit d7b80ff

Browse files
authored
Fix rules_rust on Linux/s390x. (#221)
Signed-off-by: Piotr Sikora <[email protected]>
1 parent 1ba0e93 commit d7b80ff

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

bazel/dependencies.bzl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,19 @@
1515
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
1616
load("@proxy_wasm_cpp_host//bazel/cargo:crates.bzl", "proxy_wasm_cpp_host_fetch_remote_crates")
1717
load("@rules_python//python:pip.bzl", "pip_install")
18-
load("@rules_rust//rust:repositories.bzl", "rust_repositories")
18+
load("@rules_rust//rust:repositories.bzl", "rust_repositories", "rust_repository_set")
1919

2020
def proxy_wasm_cpp_host_dependencies():
2121
protobuf_deps()
22+
2223
rust_repositories()
24+
rust_repository_set(
25+
name = "rust_linux_s390x",
26+
exec_triple = "s390x-unknown-linux-gnu",
27+
extra_target_triples = ["wasm32-unknown-unknown", "wasm32-wasi"],
28+
version = "1.57.0",
29+
)
30+
2331
proxy_wasm_cpp_host_fetch_remote_crates()
2432

2533
pip_install(

bazel/repositories.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ def proxy_wasm_cpp_host_repositories():
9292
name = "rules_rust",
9393
sha256 = "8a2052e8ec707aa04a6b9e72bfc67fea44e915ecab1d2d0a4835ad51c2410c36",
9494
strip_prefix = "rules_rust-b16c26ba5faf1c58ebe94582afd20567ce676e6d",
95+
# NOTE: Update Rust version for Linux/s390x in bazel/dependencies.bzl.
9596
url = "https://github.com/bazelbuild/rules_rust/archive/b16c26ba5faf1c58ebe94582afd20567ce676e6d.tar.gz",
9697
)
9798

bazel/wasm.bzl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ wasi_rust_binary_rule = rule(
7777
attrs = _wasm_attrs(wasi_rust_transition),
7878
)
7979

80-
def wasm_rust_binary(name, tags = [], wasi = False, signing_key = [], **kwargs):
80+
def wasm_rust_binary(name, tags = [], wasi = False, signing_key = [], rustc_flags = [], **kwargs):
8181
wasm_name = "_wasm_" + name.replace(".", "_")
8282
kwargs.setdefault("visibility", ["//visibility:public"])
8383

@@ -87,6 +87,11 @@ def wasm_rust_binary(name, tags = [], wasi = False, signing_key = [], **kwargs):
8787
crate_type = "cdylib",
8888
out_binary = True,
8989
tags = ["manual"],
90+
# Rust doesn't distribute rust-lld for Linux/s390x.
91+
rustc_flags = rustc_flags + select({
92+
"//bazel:linux_s390x": ["-C", "linker=/usr/bin/lld"],
93+
"//conditions:default": [],
94+
}),
9095
**kwargs
9196
)
9297

0 commit comments

Comments
 (0)