Build Toolchain for MIPS

less than 1 minute read

There are many ways to create a toolchain, the most easiest way to do this might be with buildroot, always grab the latest long term support release from official download web page.

Create a defconfig named rtl819x_defconfig with:

# Target options
BR2_mipsel=y
BR2_mips_32r2=y
BR2_MIPS_SOFT_FLOAT=y
BR2_DEFCONFIG="$(CONFIG_DIR)/rtl819x_defconfig"

# Build options
BR2_SHARED_STATIC_LIBS=y

# Security Hardening
BR2_PIC_PIE=y
BR2_SSP_STRONG=y
BR2_RELRO_FULL=y
BR2_FORTIFY_SOURCE_1=y

# Host GDB Options
#
BR2_PACKAGE_HOST_GDB=y
BR2_PACKAGE_HOST_GDB_PYTHON3=y

#
# Toolchain
#
BR2_TOOLCHAIN=y
BR2_TOOLCHAIN_USES_GLIBC=y

# Toolchain Buildroot Options
BR2_TOOLCHAIN_BUILDROOT_VENDOR="buildroot"
BR2_TOOLCHAIN_BUILDROOT_GLIBC=y

# Kernel Header Options
BR2_KERNEL_HEADERS_VERSION=y
BR2_DEFAULT_KERNEL_VERSION="3.10.90"
BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_3_10=y

# GCC Options
BR2_GCC_VERSION_10_X=y
BR2_TOOLCHAIN_BUILDROOT_CXX=y

BR2_INIT_NONE=y
# BR2_PACKAGE_BUSYBOX is not set
BR2_PACKAGE_LIBBSD=y

BR2_PACKAGE_ELFUTILS=y
BR2_PACKAGE_LIBUNWIND=y

And then build the mips toolchain with command:

make rtl819x_defconfig
make sdk

The toolchain will be placed to output/images/mipsel-buildroot-linux-gnu_sdk-buildroot.tar.gz