How to install cargo-xbuild offline?

Hello.

I want to build kernel module.
I installed rust offline. (Other Installation Methods - Rust Forge)
Because of rustup error about ssl. I can't solve the problems. So I did offline install.

I am trying to make a kernel module by referring to the link below.
(Other Installation Methods - Rust Forge)

It need to install cargo-xbuild , rust-src and rustfmt-preview using rustup and cargo.
But I can't use rustup and cargo.
How can I install cargo-xbuild , rust-src and rustfmt-preview by offline.

Thank you.

You can download the rust-src package here (adjust the version number to match the version of Rust you are using): https://static.rust-lang.org/dist/rust-src-1.50.0.tar.gz

That archive contains a rust-src/lib/rustlib/src directory. You should move the src directory into the lib/rustlib directory where your Rust toolchain is installed.

cargo-xbuild has no pre-compiled binaries available for download, so I think the easiest solution is to compile it yourself on a machine with working Cargo/rustup, and then copy it to the machine where you want to run it. Or, if you use a nightly build of Rust, you can use Cargo's build-std feature instead of cargo-xbuild.

Note that cargo-xbuild relies on Cargo, so you may still run into trouble if you need to use external crates and Cargo cannot download them.

rustfmt-preview component has been renamed to rustfmt in recent versions of Rust. It can be downloaded from static.rust-lang.org, but the exact URL depends on your platform and Rust version. This component should not be required for building a kernel module, however. It's just a tool for formatting your source code to match a standard style guide.

1 Like

Thank you. I will check it.