-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Local Remote Execution for Rust
This change implements ~40 Rust toolchains that reuse Nix's executables and make them available via Bazel. The new setup is fully reproducible, supports musl and glibc and works from all nix-supported hosts to all sensible crosscompilation targets seamlessly through remote and local execution. For instance, you can now run this command on a MacOS host to build a statically linked executable for x86_64-linux on a remote arm worker: ```bash bazel build \ nativelink \ --extra_execution_platforms=@local-remote-execution//lre-rs:aarch64-unknown-linux-gnu \ --platforms=@local-remote-execution//lre-rs:x86_64-unknown-linux-musl ```
- Loading branch information
1 parent
ae71bc8
commit 63a2b0b
Showing
19 changed files
with
1,462 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
constraint_setting(name = "libc") | ||
|
||
constraint_value( | ||
name = "glibc", | ||
constraint_setting = ":libc", | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
constraint_value( | ||
name = "musl", | ||
constraint_setting = ":libc", | ||
visibility = ["//visibility:public"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
lib, | ||
buildImage, | ||
lre-cc, | ||
rust-toolchains, | ||
}: let | ||
Env = | ||
# Rust requires a functional C++ toolchain. | ||
lre-cc.meta.Env | ||
++ [ | ||
# This causes the rust toolchains to be available under `/nix/store/*` | ||
# paths but not under "generic" paths like `/bin` or `/usr/bin`. | ||
# This way we're guaranteed to use binary identical toolchains during | ||
# local and remote execution. | ||
"RUST=${lib.concatStringsSep ":" rust-toolchains}" | ||
]; | ||
in | ||
buildImage { | ||
name = "lre-rs"; | ||
maxLayers = 100; | ||
config = {inherit Env;}; | ||
# Passthrough so that other images can reuse the environment. | ||
meta = {inherit Env;}; | ||
|
||
# Don't set a tag here so that the image is tagged by its derivation hash. | ||
# tag = null; | ||
} |
Oops, something went wrong.