fork/rules_rust

git clone https://git.julia.blue/fork/rules_rust

Marvin HansenUpdated Bazelmod cross compilation to catch MacOS sys dependency issues (#2926)11343929

cleanup
3.8 KiB111 linesraw
1module(
2    name = "hello_cross",
3    version = "0.0.0",
4)
5
6###############################################################################
7# Bazel Dependencies # https://registry.bazel.build/
8###############################################################################
9# Get latest rules_rust release from:
10# https://github.com/bazelbuild/rules_rust/releases
11bazel_dep(name = "rules_rust", version = "0.52.0")
12local_path_override(
13    module_name = "rules_rust",
14    path = "../../..",
15)
16
17# https://github.com/bazelbuild/platforms/releases
18bazel_dep(name = "platforms", version = "0.0.10")
19
20# https://github.com/bazel-contrib/toolchains_llvm
21bazel_dep(name = "toolchains_llvm", version = "1.2.0", dev_dependency = True)
22
23# https://github.com/bazelbuild/bazel/blob/master/tools/build_defs/repo/http.bzl
24http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
25
26###############################################################################
27# LLVM Toolchain #
28###############################################################################
29# INTEL/AMD64 Sysroot. LastModified: 2024-04-26T19:15
30# https://commondatastorage.googleapis.com/chrome-linux-sysroot/
31http_archive(
32    name = "sysroot_linux_x64",
33    build_file = "//build/sysroot:BUILD.bazel",
34    sha256 = "5df5be9357b425cdd70d92d4697d07e7d55d7a923f037c22dc80a78e85842d2c",
35    urls = ["https://commondatastorage.googleapis.com/chrome-linux-sysroot/toolchain/4f611ec025be98214164d4bf9fbe8843f58533f7/debian_bullseye_amd64_sysroot.tar.xz"],
36)
37
38# ARM 64 Sysroot. LastModified: 2024-04-26T18:33
39# https://commondatastorage.googleapis.com/chrome-linux-sysroot/
40http_archive(
41    name = "sysroot_linux_aarch64",
42    build_file = "//build/sysroot:BUILD.bazel",
43    sha256 = "d303cf3faf7804c9dd24c9b6b167d0345d41d7fe4bfb7d34add3ab342f6a236c",
44    urls = ["https://commondatastorage.googleapis.com/chrome-linux-sysroot/toolchain/906cc7c6bf47d4bd969a3221fc0602c6b3153caa/debian_bullseye_arm64_sysroot.tar.xz"],
45)
46
47# LLVM Versions and platforms
48# https://github.com/bazel-contrib/toolchains_llvm/blob/master/toolchain/internal/llvm_distributions.bzl
49llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm", dev_dependency = True)
50llvm.toolchain(
51    name = "llvm_toolchain",
52    llvm_versions = {
53        "": "16.0.0",
54        "darwin-x86_64": "15.0.7",  # For CI runner only; remove if you don't have an Intel Mac.
55    },
56    stdlib = {
57        "linux-aarch64": "stdc++",
58        "linux-x86_64": "stdc++",
59    },
60)
61llvm.sysroot(
62    name = "llvm_toolchain",
63    label = "@sysroot_linux_x64//:sysroot",
64    targets = ["linux-x86_64"],
65)
66llvm.sysroot(
67    name = "llvm_toolchain",
68    label = "@sysroot_linux_aarch64//:sysroot",
69    targets = ["linux-aarch64"],
70)
71use_repo(llvm, "llvm_toolchain")
72
73register_toolchains(
74    "@llvm_toolchain//:all",
75    dev_dependency = True,
76)
77
78###############################################################################
79# Rust Toolchain #
80###############################################################################
81RUST_EDITION = "2021"  # NOTE: 2024 will be released with Rust 1.86.0
82
83RUST_VERSION = "1.81.0"
84
85rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
86rust.toolchain(
87    edition = RUST_EDITION,
88    extra_target_triples = [
89        "aarch64-unknown-linux-gnu",
90        "x86_64-unknown-linux-gnu",
91    ],
92    versions = [RUST_VERSION],
93)
94use_repo(rust, "rust_toolchains")
95
96register_toolchains("@rust_toolchains//:all")
97
98###############################################################################
99# Rust Dependencies #
100###############################################################################
101crate = use_extension("@rules_rust//crate_universe:extension.bzl", "crate")
102crate.spec(
103    package = "mimalloc",
104    version = "0.1.43",
105)
106crate.spec(
107    package = "lz4-sys",
108    version = "1.11.1",
109)
110crate.from_specs()
111use_repo(crate, "crates")