Skip to content

Commit

Permalink
Add s390x arch support (#2616)
Browse files Browse the repository at this point in the history
This is continuing of #2557
, added buildifier code changes for s390x arch also.
  • Loading branch information
Repana-Chowdappa authored Sep 6, 2024
1 parent e979882 commit 3d1856b
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 7 deletions.
Binary file added buildifier
Binary file not shown.

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.

20 changes: 14 additions & 6 deletions crate_universe/private/vendor_utils.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")

_BUILDIFIER_VERSION = "7.1.1"
_BUILDIFIER_VERSION = "7.3.1"
_BUILDIFIER_URL_TEMPLATE = "https://github.com/bazelbuild/buildtools/releases/download/v{version}/{bin}"
_BUILDIFIER_INTEGRITY = {
"buildifier-darwin-amd64": "sha256-d0YNlXr3oCi7GK223EP6ZLbgAGTkc+rINoq4pwOzp0M=",
"buildifier-darwin-arm64": "sha256-yZD0sDsn1qDYb/6TAUcypZwYurDE86TMVjS9OxYp/OM=",
"buildifier-linux-amd64": "sha256-VLfyzo8idhz60mRBbpEgVq6chkX1nrZYO4RrSGSh7oM=",
"buildifier-linux-arm64": "sha256-HZrx9pVqQ5/KKHii+/dguXyl3wD2aeXRlTvrDEYHrHE=",
"buildifier-windows-amd64.exe": "sha256-Mx2IPnyjbIu+KKHoUoqccRAvS+Yj+Tn6PSCk2PAEvqs=",
"buildifier-darwin-amd64": "sha256-N1+CMQPQFiCq7CCgwpxsvKmfT9ByWuMLk2VcZwT0TXE=",
"buildifier-darwin-arm64": "sha256-Wmr8asegn1RVuguJvZnVriO0F03F3J1sDtXOjKrD+BM=",
"buildifier-linux-amd64": "sha256-VHTMUSinToBng9VAgfWBZixL6K5lAi9VfpKB7V3IgAk=",
"buildifier-linux-arm64": "sha256-C/hsS//69PCO7Xe95bIILkrlA5oR4uiwOYTBc8NKVhw=",
"buildifier-linux-s390x": "sha256-4tef9YhdRSdPdlMfGtvHtzoSn1nnZ/d36PveYz2dTi4=",
"buildifier-windows-amd64.exe": "sha256-NwzVdgda0pkwqC9d4TLxod5AhMeEqCUUvU2oDIWs9Kg=",
}

def crates_vendor_deps():
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 @@ -39,6 +39,7 @@ DEFAULT_TOOLCHAIN_TRIPLES = {
"aarch64-apple-darwin": "rust_darwin_aarch64",
"aarch64-pc-windows-msvc": "rust_windows_aarch64",
"aarch64-unknown-linux-gnu": "rust_linux_aarch64",
"s390x-unknown-linux-gnu": "rust_linux_s390x",
"x86_64-apple-darwin": "rust_darwin_x86_64",
"x86_64-pc-windows-msvc": "rust_windows_x86_64",
"x86_64-unknown-freebsd": "rust_freebsd_x86_64",
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

0 comments on commit 3d1856b

Please sign in to comment.