This is the second generation of musl-cross-make, a fast, simple,but advanced makefile-based approach for producing musl-targetingcross compilers. Features include:
Single-stage GCC build, used to build both musl libc and its ownshared target libs depending on libc.
No hard-coded absolute paths; resulting cross compilers can becopied/moved anywhere.
Ability to build multiple cross compilers for different targetsusing a single set of patched source trees.
Nothing is installed until runningmake install, and theinstallation location can be chosen at install time.
Automatic download of source packages, including GCC prerequisites(GMP, MPC, MPFR), using https and checking hashes.
Automatic patching with canonical musl support patches and patcheswhich provide bug fixes and features musl depends on for some archtargets.
The build system can be configured by providing aconfig.mak file inthe top-level directory. The only mandatory variable isTARGET, whichshould contain a gcc target tuple (such asi486-linux-musl), but manymore options are available. See the providedconfig.mak.dist andpresets/* for examples.
To compile, runmake. To install to$(OUTPUT), runmake install.
The default value for$(OUTPUT) is output; after installing here youcan move the cross compiler toolchain to another location as desired.
The following is a non-exhaustive list of$(TARGET) tuples that arebelieved to work:
aarch64[_be]-linux-muslarm[eb]-linux-musleabi[hf]i*86-linux-muslmicroblaze[el]-linux-muslmips-linux-muslmips[el]-linux-musl[sf]mips64[el]-linux-musl[n32][sf]powerpc-linux-musl[sf]powerpc64[le]-linux-muslriscv64-linux-musls390x-linux-muslsh*[eb]-linux-musl[fdpic][sf]x86_64-linux-musl[x32]
The current musl-cross-make is factored into two layers:
The top-level Makefile which is responsible for downloading,verifying, extracting, and patching sources, and for setting up abuild directory, and
Litecross, the cross compiler build system, which is itself aMakefile symlinked into the build directory.
Most of the real magic takes place in litecross. It begins by settingup symlinks to all the source trees provided to it by the caller, thenbuilds a combinedsrc_toolchain directory of symlinks that combinesthe contents of the top-level gcc and binutils source trees andsymlinks to gmp, mpc, and mpfr. One configured invocation themconfigures all the GNU toolchain components together in a manner thatdoes not require any of them to be installed in order for the othersto use them.
Rather than building the whole toolchain tree at once, though,litecross starts by building just the gcc directory and itsprerequisites, to get anxgcc that can be used to configure musl. Itthen configures musl, installs musl's headers to a staging "buildsysroot", and buildslibgcc.a using those headers. At this point ithas all the prerequisites to build musllibc.a andlibc.so, which therest of the gcc target-libs depend on; once they are built, the fulltoolchainmake all can proceed.
Litecross does not actually depend on the musl-cross-make top-levelbuild system; it can be used with any pre-extracted, properly patchedset of source trees.
The primary goals of this project are to:
Provide canonical musl support patches for GCC and binutils.
Serve as a canonical example of how GCC should be built to targetmusl.
Streamline the production of musl-targeting cross compilers so thatmusl users can easily produce musl-linked applications or bootstrapnew systems using musl.
Assist musl and toolchain developers in development and testing.
While the patches applied to GCC and binutils are all intended not tobreak non-musl configurations, musl-cross-make itself is specific tomusl. Changes to add support for exotic target variants outside ofwhat upstream musl supports are probably out-of-scope unless they arenon-invasive. Changes to fix issues building musl-cross-make to run onnon-Linux systems are well within scope as long as they are clean.
Most importantly, this is a side project to benefit musl and itsusers. It's not intended to be something high-maintenance or to divertdevelopment effort away from musl itself.
In addition to canonical musl support patches for GCC,musl-cross-make's patch set provides:
- Static-linked PIE support
- Addition of
--enable-default-pie - Fixes for SH-specific bugs and bitrot in GCC
- Support for J2 Core CPU target in GCC & binutils
- SH/FDPIC ABI support
Most of these patches are integrated in gcc trunk/binutils master.They should also be usable with Gregor's original musl-cross or otherbuild systems, if desired.
Some functionality (SH/FDPIC, and support for J2 specific features) ispresently only available with gcc 5.2.0 and later, and binutils 2.25.1and later.
The musl-cross-make build tools and documentation are licensed underthe MIT/Expat license as found in theLICENSE file.
Note that this license does not cover the patches (patches/) orresulting binary artifacts.
Each patch (patches/) is distributed under the terms of the licenseof the upstream project to which it is applied.
Similarly, any resulting binary artifacts produced using this buildtooling retain the original licensing from the upstream projects. Theauthors of musl-cross-make do not make any additional copyright claimsto these artifacts.
Unless you explicitly state otherwise, any contribution submitted forinclusion in musl-cross-make by you shall be licensed as above withoutany additional terms or conditions.