Created
June 29, 2017 13:47
-
-
Save nekketsuuu/062c6eb9f8350e69c4094172d1a3b00f to your computer and use it in GitHub Desktop.
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
# Ubuntu 16.04 で AArch64 用のクロスコンパイル環境をつくる | |
# 2017/06/29 | |
# http://inaz2.hatenablog.com/entry/2015/12/01/204201 | |
# https://ja.stackoverflow.com/q/35941/19110 | |
# sudo docker run --name cross_compile2 -it ubuntu:xenial /bin/bash | |
apt update | |
apt upgrade | |
apt install build-essential texinfo gawk xz-utils lbzip2 perl wget emacs | |
cd root | |
wget -nc http://ftpmirror.gnu.org/binutils/binutils-2.25.tar.gz | |
wget -nc http://ftpmirror.gnu.org/gcc/gcc-5.2.0/gcc-5.2.0.tar.gz | |
wget -nc https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.16.tar.xz | |
wget -nc http://ftpmirror.gnu.org/glibc/glibc-2.22.tar.xz | |
for f in *.tar*; do tar xf $f; done | |
cd gcc-5.2.0 | |
./contrib/download_prerequisites | |
cd .. | |
# 1. Binutils | |
mkdir build-binutils-aarch64 | |
../binutils-2.25/configure --prefix=/usr/local --target=aarch64-linux-gnu --disable-multilib --disable-nls | |
make -j4 | |
make install | |
cd .. | |
# 2. Linux Kernel Headers | |
cd linux-3.16 | |
make ARCH=arm64 INSTALL_HDR_PATH=/usr/local/aarch64-linux-gnu headers_install | |
cd .. | |
# Step 3. C/C++ Compilers | |
mkdir -p build-gcc-aarch64 | |
cd build-gcc-aarch64 | |
../gcc-5.2.0/configure --prefix=/usr/local --target=aarch64-linux-gnu --enable-languages=c,c++ --disable-multilib --disable-nls | |
make -j4 gcc_cv_libc_provides_ssp=yes all-gcc | |
make install-gcc | |
cd .. | |
# Step 4. Standard C Library Headers and Startup Files | |
mkdir -p build-glibc-aarch64 | |
cd build-glibc-aarch64 | |
# echo $MACHTYPE ==> x86_64-pc-linux-gnu | |
../glibc-2.22/configure --prefix=/usr/local/aarch64-linux-gnu --build=$MACHTYPE --host=aarch64-linux-gnu --target=aarch64-linux-gnu --with-headers=/usr/local/aarch64-linux-gnu/include --disable-multilib --disable-nls libc_cv_forced_unwind=yes | |
make install-bootstrap-headers=yes install-headers | |
make -j4 csu/subdir_lib | |
install csu/crt1.o csu/crti.o csu/crtn.o /usr/local/aarch64-linux-gnu/lib | |
aarch64-linux-gnu-gcc -nostdlib -nostartfiles -shared -x c /dev/null -o /usr/local/aarch64-linux-gnu/lib/libc.so | |
touch /usr/local/aarch64-linux-gnu/include/gnu/stubs.h | |
cd .. | |
# Step 5. Compiler Support Library | |
cd build-gcc-aarch64 | |
make -j4 all-target-libgcc | |
make install-target-libgcc | |
cd .. | |
# Step 6. Standard C Library & the rest of Glibc | |
cd build-glibc-aarch64 | |
make -j4 | |
make install | |
cd .. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment