Adding readme.md to compile tools
This commit is contained in:
72
tools/README.md
Normal file
72
tools/README.md
Normal file
@@ -0,0 +1,72 @@
|
||||
# Building the tools needed to build the kernel
|
||||
|
||||
## Install dependencies
|
||||
|
||||
### Ubuntu/Debian
|
||||
```sh
|
||||
sudo apt install build-essential bison flex libgmp3-dev libmpc-dev libmpfr-dev texinfo libisl-dev gcc-multilib
|
||||
```
|
||||
|
||||
### Fedora
|
||||
```sh
|
||||
sudo dnf install gcc gcc-c++ make bison flex gmp-devel libmpc-devel mpfr-devel texinfo isl-devel
|
||||
```
|
||||
|
||||
### Others
|
||||
For others please check [OSDev Wiki Installing Dependencies](https://wiki.osdev.org/GCC_Cross-Compiler#Installing_Dependencies) section
|
||||
|
||||
|
||||
## Compile
|
||||
> This is compilling `GCC` version `14.x` and `binutils` version `2.43.x`, make sure your OS gcc and binutils are the same major version!
|
||||
|
||||
|
||||
### Setting up the environment
|
||||
First, create the prefix folder, from your project folder execute
|
||||
```sh
|
||||
mkdir $(pwd)/toolchain/
|
||||
export PREFIX="$(pwd)/toolchain/"
|
||||
export PATH="$PREFIX/bin:$PATH"
|
||||
```
|
||||
|
||||
Set the target to be a i686
|
||||
```sh
|
||||
export TARGET=i686-elf
|
||||
```
|
||||
### Building `binutils`
|
||||
From your project folder execute:
|
||||
```sh
|
||||
mkdir -p tools/build/build-binutils
|
||||
cd tools/build/build-binutils
|
||||
../../binutils/configure --target=$TARGET --prefix="$PREFIX" --with-sysroot --disable-nls --disable-werror
|
||||
make -j$(($(nproc)-2))
|
||||
make install
|
||||
```
|
||||
|
||||
To check what each flag does consult [OSDev Wiki](https://wiki.osdev.org/GCC_Cross-Compiler#Binutils)
|
||||
|
||||
### Build `GCC`
|
||||
First, check if `binutils` is reachable from within `$PATH`
|
||||
```sh
|
||||
which i686-elf-ld | grep $PREFIX -q && echo "Found i686-elf-ld" || echo "NOT found i686-elf-ld"
|
||||
```
|
||||
|
||||
If you see `Found i686-elf-ld` you are good to got, if not you have made some mistake on the steps above.
|
||||
|
||||
Now, compile `GCC` and `libgcc`. From your project folder execute:
|
||||
```sh
|
||||
mkdir -p tools/build/build-gcc
|
||||
cd build-gcc
|
||||
../../gcc/configure --target=$TARGET --prefix="$PREFIX" --disable-nls --enable-languages=c,c++ --without-headers
|
||||
make all-gcc -j$(($(nproc)-2))
|
||||
make all-target-libgcc -j$(($(nproc)-2))
|
||||
make install-gcc
|
||||
make install-target-libgcc
|
||||
```
|
||||
|
||||
|
||||
## Finals
|
||||
Once everything is compile you should have some binaries inside `$PREFIX/bin`, mainly `i686-elf-gcc`, `i686-elf-ld`, `i686-elf-gdb`, `i686-elf-as` and `i686-elf-g++`.
|
||||
|
||||
```sh
|
||||
ls $PREFIX/bin
|
||||
```
|
||||
Reference in New Issue
Block a user