Skip to content

Latest commit

 

History

History
60 lines (45 loc) · 2.54 KB

README.md

File metadata and controls

60 lines (45 loc) · 2.54 KB

homebrew-musl-cross

Homebrew package manager formula to install cross-compiler toolchains targeting Linux boxes.

The default installation contains toolchains for x86 64-bit Linux (x86_64-linux-musl). Others can be installed with package options (see brew info).

Note, when using the toolchain, the generated binaries will only run on a system with musl libc installed. Either musl-based distributions like Alpine Linux or distributions having musl libc installed as separate packages (e.g., Debian/Ubuntu).

Binaries statically linked with musl libc (linked with -static) have no external dependencies, even for features like DNS lookups or character set conversions that are implemented with dynamic loading on glibc. The application can be deployed as a single binary file and run on any device with the appropriate ISA and Linux kernel or Linux syscall ABI emulation layer including bare docker containers.

Tool Versions:

Partially based on:

Depends on jthat/musl-cross-make to do the heavy lifting, which is in turn based on richfelker/musl-cross-make and the clang branch of apexrtos/musl-cross-make.

Usage

  1. Install with Homebrew:
    $ brew tap jthat/musl-cross
  • To use GCC:
    $ brew install musl-cross-gcc
  • To use Clang:
    $ brew install musl-cross-clang
  1. For dynamically linked applications, ensure the correct version of musl is installed on the target device.

  2. Compile with <TARGET>-cc e.g., x86_64-linux-musl-cc, deploy, and run.

Supported Targets

  • i686-linux-musl
  • x86_64-linux-musl
  • x86_64-linux-muslx32
  • arm-linux-musleabi
  • arm-linux-musleabihf
  • aarch64-linux-musl
  • mips-linux-musl
  • mips64-linux-musl
  • powerpc-linux-musl
  • powerpc64-linux-musl
  • s390x-linux-musl

Other targets or variants can be added easily by extending the hash OPTION_TARGET_MAP in the formula as long as musl-cross-make and musl libc also support them.