OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 4:47 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Cross-compiler build fails when trying to install libgcc
PostPosted: Mon May 30, 2022 9:09 am 
Offline

Joined: Sat Apr 30, 2022 5:57 am
Posts: 18
Not sure if this is the right section (not sure what they're called) for this, so tell me if I put this in the wrong section.

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:14104: 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:
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 ../


And here's a link to the Github repository: https://github.com/ThatCodingGuy86/Unna ... 2/tree/dev

(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)


Top
 Profile  
 
 Post subject: Re: Cross-compiler build fails when trying to install libgcc
PostPosted: Mon May 30, 2022 4:35 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
ThatCodingGuy89 wrote:
The full error is:

make[1]: *** No rule to make target 'install'. Stop.
make[1]: Leaving directory '[gcc-source]/i686-elf/libgcc'
Makefile:14104: recipe for target 'install-target-libgcc' failed

Usually this means there was an error earlier in the process that scrolled away. Do you have the complete log? Can you share it?


Top
 Profile  
 
 Post subject: Re: Cross-compiler build fails when trying to install libgcc
PostPosted: Tue May 31, 2022 1:37 am 
Offline
Member
Member
User avatar

Joined: Fri Jun 11, 2021 6:02 am
Posts: 96
Location: Belgium
I would add
Code:
set -e
at the top of your script(s). This option makes the shell exit immediately on any error so it won't try to run later commands in a potentially broken state.

You may also want to add
Code:
set -x
, which prints each command that is being executed to stderr.

_________________
My OS is Norost B (website, Github, sourcehut)
My filesystem is NRFS (Github, sourcehut)


Top
 Profile  
 
 Post subject: Re: Cross-compiler build fails when trying to install libgcc
PostPosted: Tue May 31, 2022 2:17 am 
Offline

Joined: Sat Apr 30, 2022 5:57 am
Posts: 18
Octocontrabass wrote:
ThatCodingGuy89 wrote:
The full error is:

make[1]: *** No rule to make target 'install'. Stop.
make[1]: Leaving directory '[gcc-source]/i686-elf/libgcc'
Makefile:14104: recipe for target 'install-target-libgcc' failed

Usually this means there was an error earlier in the process that scrolled away. Do you have the complete log? Can you share it?


For some reason it won't attach the file. Could you tell me how exactly this is supposed to work?

I assumed you can just drag the file over and hit "add file" and then "submit", but nothing happens.


Top
 Profile  
 
 Post subject: Re: Cross-compiler build fails when trying to install libgcc
PostPosted: Tue May 31, 2022 2:36 am 
Offline

Joined: Sat Apr 30, 2022 5:57 am
Posts: 18
Upon doing what Demindiro suggested, my script seems to fail when trying to download a package, seemingly libssl. The full filename that it tried to download is `libssl1.1_1.1.1-1ubuntu2.1~18.04.15_amd64.deb`.

I also noticed a few errors (some major that should have stopped the script) with previous attempts at building:

It seems that binutils failed to build at some point and GCC completely didn't notice this:

Code:
make[4]: *** No rule to make target '../libctf/libctf.la', needed by 'objdump'.  Stop.
make[4]: Leaving directory '/home/testuser/UnnamedOS-V2/binutils-src/build-binutils/binutils'
Makefile:1431: recipe for target 'install-recursive' failed
make[3]: *** [install-recursive] Error 1
make[3]: Leaving directory '/home/testuser/UnnamedOS-V2/binutils-src/build-binutils/binutils'
Makefile:1572: recipe for target 'install' failed
make[2]: *** [install] Error 2
make[2]: Leaving directory '/home/testuser/UnnamedOS-V2/binutils-src/build-binutils/binutils'
Makefile:4103: recipe for target 'install-binutils' failed
make[1]: *** [install-binutils] Error 2
make[1]: Leaving directory '/home/testuser/UnnamedOS-V2/binutils-src/build-binutils'
Makefile:2541: recipe for target 'install' failed
make: *** [install] Error 2


And a few more errors while building GCC:

Code:
i686-elf-as is not in the PATH

checking for isl 0.15 or later... no
required isl version is 0.15 or later


Top
 Profile  
 
 Post subject: Re: Cross-compiler build fails when trying to install libgcc
PostPosted: Tue May 31, 2022 8:56 am 
Offline

Joined: Sat Apr 30, 2022 5:57 am
Posts: 18
Oh. Apparently I'm an idiot. I forgot to update my packages, so it wasn't installing a few dependencies of binutils, and as such, the GCC build failed. It should work now. Should being the operative word.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 60 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group