bazelbuild / bazelbuild/rules_rust
Static compilation of rust binaries using musl
- Dominant language
- Starlark
- Stars
- 843
- Forks
- 651
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 15
Description
Hiya, this is more a platform for discussion than anything else. I wanted to post this issue here because I'm interested in contributing to it, but I wanted some guidance first.
**TL;DR: I'd like to be able to statically link rust binaries by compiling with musl.**
Following the instructions here: https://doc.rust-lang.org/edition-guide/rust-2018/platform-and-target-support/musl-support-for-fully-static-binaries.html , it seems the `x86_64-unknown-linux-musl` target is what I should be using.
I've tried compiling the `examples` workspace with the following:
```
load("@io_bazel_rules_rust//rust:repositories.bzl", "rust_repository_set")
rust_repository_set(
name = "rust_linux_x86_64",
exec_triple = "x86_64-unknown-linux-musl",
extra_target_triples = ["wasm32-unknown-unknown"],
version = "1.44.0",
edition = "2018",
)
```
But this has resulted in output like the following:
```
$ cd examples && bazel build //hello_world/...
INFO: Analyzed 2 targets (0 packages loaded, 0 targets configured).
INFO: Found 2 targets...
INFO: From Compiling Rust rlib hello_lib (2 files):
process wrapper error: failed to exec the new process: No such file or directory.
ERROR: /home/smklein/repos/rules_rust/examples/hello_lib/BUILD:11:13: output 'hello_lib/libhello_lib-590739884.rlib' was not created
ERROR: /home/smklein/repos/rules_rust/examples/hello_lib/BUILD:11:13: not all outputs were created or valid
INFO: Elapsed time: 0.259s, Critical Path: 0.05s
INFO: 1 process: 1 linux-sandbox.
FAILED: Build did NOT complete successfully
```
Is this expected behavior? Where should I start looking if I was interested in adding support for compilation against this alternative C library?
Contributor guide
Assessment
This issue has not been assessed yet.