Skip to content

Commit

Permalink
bazel: Fetch rust-std-nightly-x86_64-unknown-none
Browse files Browse the repository at this point in the history
We will then be able to use the build artefacts within for the
standard library, rather than needing to fetch them from source
and build them locally.

See #14.

Signed-off-by: SlyMarbo <the.sly.marbo@googlemail.com>
  • Loading branch information
SlyMarbo committed Apr 15, 2022
1 parent 334a6e3 commit e847d29
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 0 deletions.
17 changes: 17 additions & 0 deletions bazel/deps/rust.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ RUST_RUSTFMT = struct(
sum = "7fe3049fb4003f35539e622801cd62e1d20481915e4879aeb47965dafeb859bf",
)

RUST_NO_STD = struct(
name = "rust-std-nightly-x86_64-unknown-none",
sum = "35cd94ae9a6efc1839c227470041038e3c51f50db1f2c59ed7f5b32d03f4cd2f",
)

RUST_CRATE_ANNOTATIONS = {
"uart_16550": [crate.annotation(
deps = ["@crates//:x86_64"],
Expand Down Expand Up @@ -166,6 +171,18 @@ def rust_deps():
],
)

# Fetch libcore, liballoc, and libcompiler-builtins
# for the x86_64-unknown-none build target.

http_archive(
name = "rust_none_x86_64",
build_file = "//bazel/third_party:no_std.BUILD",
sha256 = RUST_NO_STD.sum,
strip_prefix = "rust-std-nightly-x86_64-unknown-none",
type = "tgz",
urls = ["https://static.rust-lang.org/dist/" + RUST_ISO_DATE + "/" + RUST_NO_STD.name],
)

# Set up the Rust crates we depend on. Most of these are fetched
# using the experimental crates_repository functionality in rules_rust.

Expand Down
28 changes: 28 additions & 0 deletions bazel/third_party/no_std.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2022 The Firefly Authors.
#
# Use of this source code is governed by a BSD 3-clause
# license that can be found in the LICENSE file.

filegroup(
name = "libcore",
srcs = glob(["rust-std-x86_64-unknown-none/lib/rustlib/x86_64-unknown-none/lib/libcore-*.rlib"]),
visibility = ["//visibility:public"],
)

filegroup(
name = "liballoc",
srcs = glob(["rust-std-x86_64-unknown-none/lib/rustlib/x86_64-unknown-none/lib/liballoc-*.rlib"]),
visibility = ["//visibility:public"],
)

filegroup(
name = "libcompiler_builtins",
srcs = glob(["rust-std-x86_64-unknown-none/lib/rustlib/x86_64-unknown-none/lib/libcompiler_builtins-*.rlib"]),
visibility = ["//visibility:public"],
)

filegroup(
name = "librustc_std_workspace_core",
srcs = glob(["rust-std-x86_64-unknown-none/lib/rustlib/x86_64-unknown-none/lib/librustc_std_workspace_core-*.rlib"]),
visibility = ["//visibility:public"],
)
1 change: 1 addition & 0 deletions tools/update-deps/rust.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func ParseRustBzl(name string) (file *build.File, date *StringField, tools []*Ru
"RUST_SRC",
"RUST_STD",
"RUST_RUSTFMT",
"RUST_NO_STD",
}

data, err := os.ReadFile(name)
Expand Down
4 changes: 4 additions & 0 deletions tools/update-deps/rust_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ func TestParseRustBzl(t *testing.T) {
Name: "rustfmt-nightly-x86_64-unknown-linux-gnu",
Sum: "6cd904d0413a858a6073f1a553d2aa46e32124574da996dcd0d8aaeb706bd035",
},
{
Name: "rust-std-nightly-x86_64-unknown-none",
Sum: "35cd94ae9a6efc1839c227470041038e3c51f50db1f2c59ed7f5b32d03f4cd2f",
},
}

wantCrates := []struct {
Expand Down
5 changes: 5 additions & 0 deletions tools/update-deps/testdata/rust_bzl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ RUST_RUSTFMT = struct(
sum = "6cd904d0413a858a6073f1a553d2aa46e32124574da996dcd0d8aaeb706bd035",
)

RUST_NO_STD = struct(
name = "rust-std-nightly-x86_64-unknown-none",
sum = "35cd94ae9a6efc1839c227470041038e3c51f50db1f2c59ed7f5b32d03f4cd2f",
)

RUST_CRATE_ANNOTATIONS = {
"uart_16550": [crate.annotation(
deps = ["@crates//:x86_64"],
Expand Down

0 comments on commit e847d29

Please sign in to comment.