Code Monkey home page Code Monkey logo

rust-musl-cross's Introduction

rust-musl-cross

Docker Image Build

๐Ÿš€ Help me to become a full-time open-source developer by sponsoring me on GitHub

Docker images for compiling static Rust binaries using musl-cross-make, inspired by rust-musl-builder

Prebuilt images

Currently we have the following prebuilt Docker images on Docker Hub, supports x86_64(amd64) and aarch64(arm64) architectures.

Rust toolchain Cross Compile Target Docker Image Tag
stable aarch64-unknown-linux-musl aarch64-musl
stable arm-unknown-linux-musleabi arm-musleabi
stable arm-unknown-linux-musleabihf arm-musleabihf
stable armv5te-unknown-linux-musleabi armv5te-musleabi
stable armv7-unknown-linux-musleabi armv7-musleabi
stable armv7-unknown-linux-musleabihf armv7-musleabihf
stable i586-unknown-linux-musl i586-musl
stable i686-unknown-linux-musl i686-musl
stable mips-unknown-linux-musl mips-musl
stable mipsel-unknown-linux-musl mipsel-musl
stable mips64-unknown-linux-muslabi64 mips64-muslabi64
stable mips64el-unknown-linux-muslabi64 mips64el-muslabi64
nightly powerpc64le-unknown-linux-musl powerpc64le-musl
stable x86_64-unknown-linux-musl x86_64-musl

To use armv7-unknown-linux-musleabihf target for example, first pull the image:

docker pull messense/rust-musl-cross:armv7-musleabihf

Then you can do:

alias rust-musl-builder='docker run --rm -it -v "$(pwd)":/home/rust/src messense/rust-musl-cross:armv7-musleabihf'
rust-musl-builder cargo build --release

This command assumes that $(pwd) is readable and writable. It will output binaries in armv7-unknown-linux-musleabihf. At the moment, it doesn't attempt to cache libraries between builds, so this is best reserved for making final release builds.

How it works

rust-musl-cross uses musl-libc, musl-gcc with the help of musl-cross-make to make it easy to compile, and the new rustup target support.

Use beta/nightly Rust

Currently we install stable Rust by default, if you want to switch to beta/nightly Rust, you can do it by extending from our Docker image, for example to use beta Rust for target x86_64-unknown-linux-musl:

FROM messense/rust-musl-cross:x86_64-musl
RUN rustup update beta && \
    rustup target add --toolchain beta x86_64-unknown-linux-musl

Strip binaries

You can use the musl-strip command inside the image to strip binaries, for example:

docker run --rm -it -v "$(pwd)":/home/rust/src messense/rust-musl-cross:armv7-musleabihf musl-strip /home/rust/src/target/release/example

License

Licensed under The MIT License

rust-musl-cross's People

Contributors

messense avatar asaaki avatar tonyo avatar jan-auer avatar swagadon avatar dbrgn avatar henrikno avatar huguesbouvier avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.