Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add s390x arch support #2616

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view

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

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

8 changes: 8 additions & 0 deletions crate_universe/private/vendor_utils.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ _BUILDIFIER_SHA256S = {
"buildifier-darwin-amd64": "2cb0a54683633ef6de4e0491072e22e66ac9c6389051432b76200deeeeaf93fb",
"buildifier-darwin-arm64": "4da23315f0dccabf878c8227fddbccf35545b23b3cb6225bfcf3107689cc4364",
"buildifier-linux-amd64": "3ed7358c7c6a1ca216dc566e9054fd0b97a1482cb0b7e61092be887d42615c5d",
"buildifier-linux-s390x": "3ed7358c7c6a1ca216dc566e9054fd0b97a1482cb0b7e61092be887d42615c5d",
"buildifier-linux-arm64": "c657c628fca72b7e0446f1a542231722a10ba4321597bd6f6249a5da6060b6ff",
"buildifier-windows-amd64.exe": "45e13b2951e4c611d346dacdaf0aafaa484045a3e7300fbc5dd01a896a688177",
}
Expand Down Expand Up @@ -54,6 +55,12 @@ def crates_vendor_deps_targets():
visibility = ["//visibility:public"],
)

native.config_setting(
name = "linux_s390x",
constraint_values = ["@platforms//os:linux", "@platforms//cpu:s390x"],
visibility = ["//visibility:public"],
)

native.config_setting(
name = "macos_amd64",
constraint_values = ["@platforms//os:macos", "@platforms//cpu:x86_64"],
Expand All @@ -77,6 +84,7 @@ def crates_vendor_deps_targets():
actual = select({
":linux_amd64": "@cargo_bazel.buildifier-linux-amd64//file",
":linux_arm64": "@cargo_bazel.buildifier-linux-arm64//file",
":linux_s390x": "@cargo_bazel.buildifier-linux-s390x//file",
":macos_amd64": "@cargo_bazel.buildifier-darwin-amd64//file",
":macos_arm64": "@cargo_bazel.buildifier-darwin-arm64//file",
":windows": "@cargo_bazel.buildifier-windows-amd64.exe//file",
Expand Down
2 changes: 1 addition & 1 deletion rust/platform/triple.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def get_host_triple(repository_ctx, abi = None):
# Detect the host's cpu architecture

supported_architectures = {
"linux": ["aarch64", "x86_64"],
"linux": ["aarch64", "x86_64", "s390x"],
"macos": ["aarch64", "x86_64"],
"windows": ["aarch64", "x86_64"],
}
Expand Down
1 change: 1 addition & 0 deletions rust/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ DEFAULT_TOOLCHAIN_TRIPLES = {
"x86_64-pc-windows-msvc": "rust_windows_x86_64",
"x86_64-unknown-freebsd": "rust_freebsd_x86_64",
"x86_64-unknown-linux-gnu": "rust_linux_x86_64",
"s390x-unknown-linux-gnu": "rust_linux_s390x",
}

def rules_rust_dependencies():
Expand Down
14 changes: 14 additions & 0 deletions test/unit/native_deps/native_deps_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@ def _bin_has_native_dep_and_alwayslink_test_impl(ctx):
"bazel-out/x64_windows-{}/bin/{}test/unit/native_deps/alwayslink.lo.lib".format(compilation_mode, workspace_prefix),
"-Wl,--no-whole-archive",
]
elif toolchain.target_arch == "s390x":
want = [
"-lstatic=native_dep",
"link-arg=-Wl,--whole-archive",
"link-arg=bazel-out/s390x-{}/bin/{}test/unit/native_deps/libalwayslink.lo".format(compilation_mode, workspace_prefix),
"link-arg=-Wl,--no-whole-archive",
]
else:
want = [
"-lstatic=native_dep",
Expand Down Expand Up @@ -207,6 +214,13 @@ def _cdylib_has_native_dep_and_alwayslink_test_impl(ctx):
"bazel-out/x64_windows-{}/bin/{}test/unit/native_deps/alwayslink.lo.lib".format(compilation_mode, workspace_prefix),
"-Wl,--no-whole-archive",
]
elif toolchain.target_arch == "s390x":
want = [
"-lstatic=native_dep{}".format(pic_suffix),
"link-arg=-Wl,--whole-archive",
"link-arg=bazel-out/s390x-{}/bin/{}test/unit/native_deps/libalwayslink{}.lo".format(compilation_mode, workspace_prefix, pic_suffix),
"link-arg=-Wl,--no-whole-archive",
]
else:
want = [
"-lstatic=native_dep{}".format(pic_suffix),
Expand Down