Created
July 24, 2018 13:36
-
-
Save Chan9390/266e8bcac13c45a2bef15e44bb0d708b to your computer and use it in GitHub Desktop.
Creating MIPS cross compiler for ARM architecture
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir crossbuild | |
cd crossbuild | |
mkdir gcc | |
mkdir eglibc | |
mkdir binutils | |
mkdir install | |
mkdir sysroot | |
export prefix=/home/pi/crossbuild/install | |
export sysroot=/home/pi/crossbuild/sysroot | |
export host=arm-linux-gnueabihf | |
export build=arm-linux-gnueabihf | |
export target=mips-linux | |
export linuxarch=mips | |
sudo apt install -y git subversion tmux | |
# Testing with gcc 6.3.0 as the gcc version of Raspbian is 6.3.0 | |
wget ftp://ftp.gnu.org/gnu/gcc/gcc-6.3.0/gcc-6.3.0.tar.gz -O gcc/gcc-6.3.0.tar.gz | |
# Testing binutils 2.28 as 'ld -v' | |
wget ftp://ftp.gnu.org/gnu/binutils/binutils-2.28.1.tar.gz -O binutils/binutils-2.28.1.tar.gz | |
# Using trunk of eglibc | |
mkdir eglibc | |
cd eglibc | |
svn co svn://svn.eglibc.org/trunk eglibc | |
cd ~/crossbuild/ | |
# Using kernel 4.14.34 as per the output of 'uname -r' | |
wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.14.34.tar.xz | |
cd binutils | |
tar -xf binutils-2.28.1.tar.gz | |
mkdir build | |
cd build | |
../binutils-2.28.1/configure --target=$target --prefix=$prefix --with-sysroot=$sysroot | |
make | |
make install | |
cd ~/crossbuild/gcc/ | |
tar -xf gcc-6.3.0.tar.gz | |
mkdir build | |
cd gcc-6.3.0/ | |
./contrib/download_prerequisites | |
cd ../build/ | |
../gcc-6.3.0/configure --target=$target --prefix=$prefix --without-headers --with-newlib --disable-shared --disable-threads --disable-libssp --disable-libgomp --disable-libmudflap --enable-languages=c | |
PATH=$prefix/bin:$PATH make all-gcc | |
PATH=$prefix/bin:$PATH make install-gcc | |
cd ~/crossbuild/ | |
tar -xf linux-4.14.34.tar.xz | |
cd linux-4.14.34/ | |
PATH=$prefix/bin:$PATH make headers_install CROSS_COMPILE=$target- INSTALL_HDR_PATH=$sysroot/usr ARCH=$linuxarch | |
cd ~/crossbuild/eglibc/ | |
cp -r eglibc/ports/ eglibc/libc/ | |
mkdir build | |
cd build | |
sudo apt install -y gawk | |
BUILD_CC=gcc CC=$prefix/bin/$target-gcc AR=$prefix/bin/$target-ar RANLIB=$prefix/bin/$target-ranlib ../eglibc/libc/configure --prefix=/usr --with-headers=$sysroot/usr/include --build=$build --host=$target --disable-profile --without-gd --without-cvs --enable-add-ons libc_cv_forced_unwind=yes | |
make install-headers install_root=$sysroot \install-bootstrap-headers=yes | |
mkdir -p $sysroot/usr/lib | |
make csu/subdir_lib | |
cd csu/ | |
cp crt1.o crti.o crtn.o $sysroot/usr/lib | |
$prefix/bin/$target-gcc -nostdlib -nostartfiles -shared -x c /dev/null -o $sysroot/usr/lib/libc.so | |
cd ~/crossbuild/ | |
cd gcc/build/ | |
rm -rf * | |
../gcc-6.3.0/configure --target=$target --prefix=$prefix --with-sysroot=$sysroot --disable-libssp --disable-libgomp --disable-libmudflap --enable-languages=c | |
PATH=$prefix/bin:$PATH make | |
PATH=$prefix/bin:$PATH make install | |
cd ~/crossbuild | |
cd eglibc/build | |
rm -rf * | |
sudo apt install gperf | |
BUILD_CC=gcc CC=$prefix/bin/$target-gcc AR=$prefix/bin/$target-ar RANLIB=$prefix/bin/$target-ranlib ../eglibc/libc/configure --prefix=/usr --with-headers=$sysroot/usr/include --build=$build --host=$target --disable-profile --without-gd --without-cvs --enable-add-ons libc_cv_forced_unwind=yes | |
PATH=$prefix/bin:$PATH make | |
PATH=$prefix/bin:$PATH make install install_root=$sysroot | |
cd ~/crossbuild | |
cd gcc/build | |
rm -rf * | |
../gcc-6.3.0/configure --target=$target --prefix=$prefix --with-sysroot=$sysroot --disable-libssp --disable-libgomp --disable-libmudflap --enable-languages=c | |
PATH=$prefix/bin:$PATH make | |
PATH=$prefix/bin:$PATH make install | |
cd ~/crossbuild | |
cp -d $prefix/$target/lib/libgcc_s.so* $sysroot/lib |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment