From 0dd98382208f12e36f22ad50791180afe8232ce6 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Thu, 5 Aug 2021 19:13:46 +0000 Subject: add a script which builds i686-elf-binutils --- Makefile | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 6fcd2c5..7bfc4b0 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +PATH := $(shell pwd)/toolchain/binutils-2.37/bin/:$(PATH) + AS = i686-elf-as CC = i686-elf-gcc CFLAGS = -std=gnu99 -ffreestanding -O2 -Wall -Wextra -- cgit v1.2.3 From e2b9d3d34b54767e01c8555e7e672e7ce2dc400c Mon Sep 17 00:00:00 2001 From: dzwdz Date: Fri, 6 Aug 2021 15:38:06 +0000 Subject: a (seemingly broken) gcc build script It compiles, but the resulting gcc binary doesn't actually work. Maybe it's too new for the binutils? --- Makefile | 2 +- tools/dep_builders/gcc | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100755 tools/dep_builders/gcc (limited to 'Makefile') diff --git a/Makefile b/Makefile index 7bfc4b0..efb04eb 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -PATH := $(shell pwd)/toolchain/binutils-2.37/bin/:$(PATH) +PATH := $(shell pwd)/toolchain/binutils-2.37/bin/:$(shell pwd)/toolchain/gcc-11.2.0/bin/:$(PATH) AS = i686-elf-as CC = i686-elf-gcc diff --git a/tools/dep_builders/gcc b/tools/dep_builders/gcc new file mode 100755 index 0000000..69b4fcc --- /dev/null +++ b/tools/dep_builders/gcc @@ -0,0 +1,53 @@ +#!/bin/sh +set -eu + +TOOL="gcc" +VER="11.2.0" +# this is ugly +{ HASHES=$(cat) ; } <<'HASHES' +f0837f1bf8244a5cc23bd96ff6366712a791cfae01df8e25b137698aca26efc1 toolchain/cache/gcc-11.2.0.tar.gz +HASHES + +export PREFIX="$(pwd)/toolchain/$TOOL-$VER/" +export TARGET=i686-elf +export PATH="$(pwd)/toolchain/binutils-2.37/bin/:$PATH" + + +# ensure that we're in the repo root +if [ ! -d .git ]; then + echo please cd to the repo\'s main directory + exit +fi + +mkdir -p $PREFIX/build + + +echo "downloading missing files..." +tools/dep_builders/dl "https://ftp.gnu.org/gnu/$TOOL/$TOOL-$VER/$TOOL-$VER.tar.gz" +tools/dep_builders/dl "https://ftp.gnu.org/gnu/$TOOL/$TOOL-$VER/$TOOL-$VER.tar.gz.sig" +tools/dep_builders/dl "https://ftp.gnu.org/gnu/gnu-keyring.gpg" + +echo "verifying signatures..." +if ! gpg --verify --keyring toolchain/cache/gnu-keyring.gpg toolchain/cache/$TOOL-$VER.tar.gz.sig +then + echo "THE SIGNATURE COULDN'T BE VERIFIED. something's fishy." + exit +fi +echo "$HASHES" | sha256sum --check || exit + +echo "unpacking the tarball..." +tar xf toolchain/cache/$TOOL-$VER.tar.gz -C toolchain/cache +UNPACKED="$(pwd)/toolchain/cache/$TOOL-$VER/" + +echo "downloading required libraries..." +cd $UNPACKED +./contrib/download_prerequisites + +echo "building..." +cd $PREFIX/build + +$UNPACKED/configure --target=$TARGET --prefix="$PREFIX" --disable-nls --enable-languages=c --without-headers +make all-gcc +make all-target-libgcc +make install-gcc +make install-target-libgcc -- cgit v1.2.3 From bd50355d96bb081394f01c7d8e89debd1c040cd4 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Sat, 7 Aug 2021 15:34:03 +0200 Subject: build all parts of the toolchain to the same $PREFIX If gcc is built with a different $PREFIX than binutils, it won't even attempt using them - it will use the system assembler instead, which fails for obvious reasons. --- Makefile | 2 +- tools/dep_builders/binutils | 15 +++++++++------ tools/dep_builders/gcc | 21 +++++++++++---------- 3 files changed, 21 insertions(+), 17 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index efb04eb..959672e 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -PATH := $(shell pwd)/toolchain/binutils-2.37/bin/:$(shell pwd)/toolchain/gcc-11.2.0/bin/:$(PATH) +PATH := $(shell pwd)/toolchain/bin/:$(PATH) AS = i686-elf-as CC = i686-elf-gcc diff --git a/tools/dep_builders/binutils b/tools/dep_builders/binutils index 65d97be..210c13b 100755 --- a/tools/dep_builders/binutils +++ b/tools/dep_builders/binutils @@ -8,7 +8,9 @@ VER="2.37" c44968b97cd86499efbc4b4ab7d98471f673e5414c554ef54afa930062dbbfcb toolchain/cache/binutils-2.37.tar.gz HASHES -export PREFIX="$(pwd)/toolchain/$TOOL-$VER/" +export PREFIX="$(pwd)/toolchain/" +export CACHE="$(pwd)/toolchain/cache/" +export PATH="$(pwd)/toolchain/bin/:$PATH" export TARGET=i686-elf @@ -18,8 +20,7 @@ if [ ! -d .git ]; then exit fi -mkdir -p $PREFIX/build - +mkdir -p $PREFIX echo "downloading missing files..." tools/dep_builders/dl "https://ftp.gnu.org/gnu/$TOOL/$TOOL-$VER.tar.gz" @@ -27,7 +28,7 @@ tools/dep_builders/dl "https://ftp.gnu.org/gnu/$TOOL/$TOOL-$VER.tar.gz.sig" tools/dep_builders/dl "https://ftp.gnu.org/gnu/gnu-keyring.gpg" echo "verifying signatures..." -if ! gpg --verify --keyring toolchain/cache/gnu-keyring.gpg toolchain/cache/$TOOL-$VER.tar.gz.sig +if ! gpg --verify --keyring toolchain/cache/gnu-keyring.gpg $CACHE/$TOOL-$VER.tar.gz.sig then echo "THE SIGNATURE COULDN'T BE VERIFIED. something's fishy." exit @@ -38,7 +39,9 @@ echo "unpacking the tarball..." tar xf toolchain/cache/$TOOL-$VER.tar.gz -C toolchain/cache echo "building..." -cd $PREFIX/build -../../cache/$TOOL-$VER/configure --target=$TARGET --prefix="$PREFIX" --with-sysroot --disable-nls --disable-werror +rm -rf $CACHE/$TOOL-$VER/builddir +mkdir $CACHE/$TOOL-$VER/builddir +cd $CACHE/$TOOL-$VER/builddir +../configure --target=$TARGET --prefix="$PREFIX" --with-sysroot --disable-nls --disable-werror make make install diff --git a/tools/dep_builders/gcc b/tools/dep_builders/gcc index 69b4fcc..4c32b53 100755 --- a/tools/dep_builders/gcc +++ b/tools/dep_builders/gcc @@ -8,9 +8,10 @@ VER="11.2.0" f0837f1bf8244a5cc23bd96ff6366712a791cfae01df8e25b137698aca26efc1 toolchain/cache/gcc-11.2.0.tar.gz HASHES -export PREFIX="$(pwd)/toolchain/$TOOL-$VER/" +export PREFIX="$(pwd)/toolchain/" +export CACHE="$(pwd)/toolchain/cache/" +export PATH="$(pwd)/toolchain/bin/:$PATH" export TARGET=i686-elf -export PATH="$(pwd)/toolchain/binutils-2.37/bin/:$PATH" # ensure that we're in the repo root @@ -19,8 +20,7 @@ if [ ! -d .git ]; then exit fi -mkdir -p $PREFIX/build - +mkdir -p $PREFIX echo "downloading missing files..." tools/dep_builders/dl "https://ftp.gnu.org/gnu/$TOOL/$TOOL-$VER/$TOOL-$VER.tar.gz" @@ -28,7 +28,7 @@ tools/dep_builders/dl "https://ftp.gnu.org/gnu/$TOOL/$TOOL-$VER/$TOOL-$VER.tar.g tools/dep_builders/dl "https://ftp.gnu.org/gnu/gnu-keyring.gpg" echo "verifying signatures..." -if ! gpg --verify --keyring toolchain/cache/gnu-keyring.gpg toolchain/cache/$TOOL-$VER.tar.gz.sig +if ! gpg --verify --keyring toolchain/cache/gnu-keyring.gpg $CACHE/$TOOL-$VER.tar.gz.sig then echo "THE SIGNATURE COULDN'T BE VERIFIED. something's fishy." exit @@ -36,17 +36,18 @@ fi echo "$HASHES" | sha256sum --check || exit echo "unpacking the tarball..." -tar xf toolchain/cache/$TOOL-$VER.tar.gz -C toolchain/cache -UNPACKED="$(pwd)/toolchain/cache/$TOOL-$VER/" +tar xf toolchain/cache/$TOOL-$VER.tar.gz -C $CACHE echo "downloading required libraries..." -cd $UNPACKED +cd $CACHE/$TOOL-$VER ./contrib/download_prerequisites echo "building..." -cd $PREFIX/build +rm -rf $CACHE/$TOOL-$VER/builddir +mkdir $CACHE/$TOOL-$VER/builddir +cd $CACHE/$TOOL-$VER/builddir -$UNPACKED/configure --target=$TARGET --prefix="$PREFIX" --disable-nls --enable-languages=c --without-headers +../configure --target=$TARGET --prefix="$PREFIX" --disable-nls --enable-languages=c --without-headers make all-gcc make all-target-libgcc make install-gcc -- cgit v1.2.3