Building a statically linked rustfmt binary that is portable irrespective of rust installation #6354
bradzacher
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi there!
I'm trying to build a portable rustfmt binary that will allow me to format rust code without needing to install rust on the machine. The usecase I have in mind is specifically formatting on our CI machines where we do not have rust installed.
We could install
rustup
on the machine and use it to install rust -- but that is a decent chunk of time that would be spent downloading and setting up rust just to run the formatter. A stand-alone binary could be a fraction of the size and thus allow us to be lighter and faster.For example the 1.6.0 release from GH releases is just 5mb for macos.
We can see that this binary is wired to look for
librustc
:Which means that running it without a rust install crashes out:
The exact same thing occurs when using the binary bundled with the rust language installer tarballs (eg https://static.rust-lang.org/dist/rust-1.78.0-aarch64-apple-darwin.tar.gz).
Is there any way that I can create a portable binary here that can be run without a rust install?
I'd be more than happy if we had to create this binary ourselves -- I just wasn't sure if it was even possible based on my poking around and rough understanding of how the builds worked.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions