Compare commits

...

3 Commits

Author SHA1 Message Date
6c39867556 Merge pull request 'Fix toolchain compilation (closes #3)' (#6) from toolchain into master
Reviewed-on: #6
2023-10-19 07:51:05 -07:00
990c614235 Remove option that breaks on macOS 2023-10-19 07:33:56 -07:00
83e516b98e Fix toolchain compilation (closes #3)
There's still some cleanup to do (like making the script cache automatically, removing unneeded flags and adding more redundancy) but those will be taken care of as part of #5 later.
2023-10-19 07:19:17 -07:00
2 changed files with 86 additions and 66 deletions

View File

@ -2,8 +2,8 @@ override MAKEFLAGS += -rR
override IMAGE_NAME := asagiri
override ARCH := aarch64
override CC := aarch64-elf-gcc
override LD := aarch64-elf-ld
override CC := aarch64-none-elf-gcc
override LD := aarch64-none-elf-ld
override DEFAULT_HOST_CFLAGS := -g -O3 -pipe
.PHONY: all
@ -52,4 +52,4 @@ clean:
.PHONY: distclean
distclean: clean
rm -rf limine ovmf
$(MAKE) -C yukari distclean
$(MAKE) -C yukari distclean

146
compile-toolchain.sh Executable file → Normal file
View File

@ -1,63 +1,83 @@
#!/bin/sh
set -e
export PREFIX="$HOME/cross-aarch64"
export TARGET="aarch64-elf"
export PATH="$PREFIX/bin:$PATH"
# Get thread count
if [ "$(uname)" == "Darwin" ]; then
export NPROC="sysctl -n hw.physicalcpu"
else
export NPROC="nproc"
fi
# Create prefix path
mkdir -p $PREFIX
# Create compilation directory
cd /tmp
rm -rf toolchain
mkdir -p toolchain
cd toolchain
# Get sources
wget https://ftp.gnu.org/gnu/binutils/binutils-2.41.tar.gz
wget https://ftp.gnu.org/gnu/gcc/gcc-13.2.0/gcc-13.2.0.tar.gz
# Build binutils for aarch64
# might need texinfo
mkdir -p binutils-src
tar -xvf binutils-2.41.tar.gz -C binutils-src/
mkdir -p binutils
cd binutils
../binutils-src/*/configure --target=$TARGET --prefix=$PREFIX \
--enable-shared --enable-threads=posix --enable-libmpx --with-system-zlib --enable-__cxa_atexit \
--disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-plugin \
--disable-linker-build-id --enable-lto --enable-install-libiberty --with-linker-hash-style=gnu --with-gnu-ld\
--enable-gnu-indirect-function --disable-multilib --disable-werror --enable-checking=release --enable-default-pie \
--enable-default-ssp --enable-gnu-unique-object --with-zstd=no
make -j$($NPROC)
make install
# Build gcc for aarch64
cd ..
mkdir -p gcc-src
tar -xvf gcc-13.2.0.tar.gz -C gcc-src/
cd gcc-src/*/
./contrib/download_prerequisites
cd ../../
mkdir -p gcc
cd gcc
../gcc-src/*/configure --target=$TARGET --prefix=$PREFIX --enable-languages=c \
--enable-shared --enable-threads=posix --enable-libmpx --with-system-zlib --enable-__cxa_atexit \
--disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-plugin \
--disable-linker-build-id --enable-lto --enable-install-libiberty --with-linker-hash-style=gnu --with-gnu-ld\
--enable-gnu-indirect-function --disable-multilib --disable-werror --enable-checking=release --enable-default-pie \
--enable-default-ssp --enable-gnu-unique-object
make -j$($NPROC) all-gcc
make install-gcc
cd
rm -rf /tmp/toolchain
echo "Toolchain installation is complete!"
echo "Please add this to your bashrc or zshrc or whatever"
echo "export \$PATH=\"$PREFIX/bin:\$PATH\""
#!/bin/sh
set -euo pipefail
export PREFIX="$HOME/cross-aarch64"
export TARGET="aarch64-none-elf"
export PATH="$PREFIX/bin:$PATH"
# Get thread count
if [ "$(uname)" == "Darwin" ]; then
export NPROC="sysctl -n hw.physicalcpu"
else
export NPROC="nproc"
fi
existGCC=0
existBIN=0
if [ -e binutils-2.41.tar.gz ]; then
existBIN=1
fi
if [ -e gcc-13.2.0.tar.gz ]; then
existGCC=1
fi
startLoc=$(pwd)
# Create prefix path
mkdir -p $PREFIX
# Create compilation directory
cd /tmp
rm -rf toolchain
mkdir -p toolchain
cd toolchain
# Get sources
if [[ "${existBIN}" != "1" ]]; then
wget https://ftp.gnu.org/gnu/binutils/binutils-2.41.tar.gz
else
cp "${startLoc}/binutils-2.41.tar.gz" .
fi
if [[ "${existGCC}" != "1" ]]; then
wget https://ftp.gnu.org/gnu/gcc/gcc-13.2.0/gcc-13.2.0.tar.gz
else
cp "${startLoc}/gcc-13.2.0.tar.gz" .
fi
# Build binutils for aarch64
# might need texinfo
mkdir -p binutils-src
tar -xvf binutils-2.41.tar.gz -C binutils-src/
mkdir -p binutils
cd binutils
../binutils-src/*/configure --target=$TARGET --prefix=$PREFIX --libexecdir=$PREFIX/lib \
--enable-shared --enable-threads=posix --enable-libmpx --with-system-zlib --enable-__cxa_atexit \
--disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-plugin \
--disable-linker-build-id --enable-lto --enable-install-libiberty --with-linker-hash-style=gnu --with-gnu-ld\
--enable-gnu-indirect-function --disable-multilib --disable-werror --enable-checking=release --enable-default-pie \
--enable-default-ssp --enable-gnu-unique-object --with-zstd=no --with-arch=armv8-a --enable-fix-cortex-a53-835769 \
--enable-fix-cortex-a53-843419
make -j$($NPROC)
make install
# Build gcc for aarch64
cd ..
mkdir -p gcc-src
tar -xvf gcc-13.2.0.tar.gz -C gcc-src/
cd gcc-src/*/
./contrib/download_prerequisites
cd ../../
mkdir -p gcc
cd gcc
../gcc-src/*/configure --target=$TARGET --prefix=$PREFIX --disable-shared --disable-nls --disable-threads --disable-tls \
--enable-checking=release --enable-languages=c,c++ --with-newlib --with-gnu-as --with-gnu-ld
make -j$($NPROC) all-gcc
make install-gcc
make -j$($NPROC) all-target-libgcc
make install-target-libgcc
cd
rm -rf /tmp/toolchain
echo "Toolchain installation is complete!"
echo "Please add this to your bashrc or zshrc or whatever"
echo "export PATH=\"$PREFIX/bin:\$PATH\""