Anyways, I was trying to build a cross-compiler (using the instructions from this wiki page: https://wiki.osdev.org/GCC_Cross-Compiler),
and it failed after trying to make the target 'install-target-libgcc'. The full error is:
make[1]: *** No rule to make target 'install'. Stop.
make[1]: Leaving directory '[gcc-source]/i686-elf/libgcc'
Makefile recipe for target 'install-target-libgcc' failed
I've been trying to automate building the cross-compiler, so I can test the OS by just running 2 scripts. (toolchain.sh and build.sh)
This is probably where something's wrong, as I followed the exact instructions on a different install of Ubuntu before.
I'm not sure where I went wrong though, so here's the full code for toolchain.sh:
Code: Select all
echo "Installing GCC dependencies..."
sudo apt install bison
sudo apt install flex
sudo apt install libgmp3-dev
sudo apt install libmpc-dev
sudo apt install libmpfr-dev
sudo apt install texinfo
echo "Downloading Binutils source..."
mkdir binutils-src
wget -P ./binutils-src/ "https://ftp.gnu.org/gnu/binutils/binutils-2.38.tar.gz"
echo "Downloading GCC source..."
mkdir gcc-src
wget -P ./gcc-src/ "https://ftp.gnu.org/gnu/gcc/gcc-12.1.0/gcc-12.1.0.tar.gz"
echo "Extracting the Binutils source..."
cd binutils-src
tar -xvzf binutils-2.38.tar.gz
cd ../
echo "Extracting the GCC source..."
cd gcc-src
tar -xvzf gcc-12.1.0.tar.gz
cd ../
echo "Building the GCC cross-compiler..."
echo "Setting up flags..."
export PREFIX="$HOME/opt/cross"
export TARGET=i686-elf
export PATH="$PREFIX/bin:$PATH"
echo "Building binutils..."
cd binutils-src
mkdir build-binutils
cd build-binutils
../binutils-2.38/configure --target=$TARGET --prefix="$PREFIX" --with-sysroot --disable-nls --disable-werror
make
make install
cd ../../
echo "Building the GCC cross-compiler..."
cd gcc-src
which -- $TARGET-as || echo $TARGET-as is not in the PATH
mkdir build-gcc
cd build-gcc
../gcc-12.1.0/configure --target=$TARGET --prefix="$PREFIX" --disable-nls --enable-languages=c,c++ --without-headers
make all-gcc
make all-target-libgcc
make install-gcc
make install-target-libgcc
cd ../
(build instructions are in the `main` branch, you just have to execute `toolchain.sh` before executing `build.sh`, otherwise it will error because the cross-compiler doesn't exist)