Skip to content

Toolchain

Michael Forney edited this page Jun 18, 2019 · 8 revisions

Prerequisites

To build a gcc/binutils toolchain with musl-cross-make from an oasis system, you'll need make as well as the core system.

Clone

First, checkout the musl-cross-make sources.

git clone https://github.com/richfelker/musl-cross-make /src/musl-cross-make
cd /src/musl-cross-make

Currently, you'll need to apply some patches to build kernel headers with sbase.

git pull --no-edit https://github.com/oasislinux/musl-cross-make

Configure

A basic config.mak to build a static native toolchain might look like this.

NATIVE = 1
TARGET = x86_64-linux-musl

DL_CMD = curl -Lo

COMMON_CONFIG += CC='cc -static --static'
COMMON_CONFIG += CXX='c++ -static --static'

COMMON_CONFIG += CFLAGS='-O2 -pipe'
COMMON_CONFIG += CXXFLAGS='-O2 -pipe'
COMMON_CONFIG += LDFLAGS='-s'

COMMON_CONFIG += --build=$(TARGET)
COMMON_CONFIG += --with-build-sysroot=/
COMMON_CONFIG += --disable-nls
COMMON_CONFIG += --enable-deterministic-archives
COMMON_CONFIG += --with-debug-prefix-map=$(CURDIR)=

GCC_CONFIG += --with-native-system-header-dir=/include
GCC_CONFIG += --disable-bootstrap
GCC_CONFIG += --disable-libgomp
GCC_CONFIG += --disable-libquadmath
GCC_CONFIG += --disable-lto

KERNEL_VARS += HOSTCC='cc -static'

# only static
COMMON_CONFIG += --disable-shared
MUSL_CONFIG += --disable-shared

You should configure this to your needs as save as config.mak in the musl-cross-make repository.

Build

make

Install

See Repository for details about merging external software into your root repository. By default, musl-cross-make installs to output, so just choose that as your worktree name. If you previously merged the prebuilt oasis-toolchain repository, make sure you use the previously created toolchain branch so that the old toolchain files get deleted.

make install

Delete stuff we don't want in our filesystem.

find output '(' -name '*.py' -o -name '*.la' ')' -exec rm {} +
Clone this wiki locally