Skip to content

Commit c97ae7c

Browse files
authored
Improvements to cross compiler instructions (#118)
* Update E_Cross_Compilers.md * Update E_Cross_Compilers.md * Update E_Cross_Compilers.md * Update E_Cross_Compilers.md * Update E_Cross_Compilers.md * Update E_Cross_Compilers.md Changes requested.
1 parent 2843ea4 commit c97ae7c

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

99_Appendices/E_Cross_Compilers.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ cd binutils_build
7272
From this temporary directory we can use the configure script to generate the build files, like so:
7373

7474
```bash
75-
/path/to/binutils_src/configure --target=$TARGET --with-sysroot --disable-nls --disable-werror
75+
/path/to/binutils_src/configure --prefix=$PREFIX --target=$TARGET --with-sysroot --disable-nls --disable-werror
7676
```
7777

7878
At this point the configure script has generated a makefile for us with our requested options, now we can do the usual series of commands:
@@ -88,7 +88,7 @@ That's it! Now all the binutils tools are installed in the `PREFIX` directory an
8888

8989
The process for building GCC is very similar to binutils. Note that we need to have a version of binutils for our target triplet before trying to build GCC. These binaries must also be in the path, which we did before. Let's create a new folder for the build files (`build_gcc`) and move into it.
9090

91-
Now we can use the configure script like before:
91+
Now we can use the configure command:
9292

9393
```bash
9494
/path/to/gcc_sources/configure --target=$TARGET --prefix=$PREFIX --disable-nls --enable-languages=c,c++ --without-headers
@@ -99,6 +99,7 @@ For brevity we'll only explain the new flags:
9999
- `--enable-languages=c,c++`: select which language frontends to enable, these two are the default. We can disable c++ but if we plan to cross compile more things than our kernel this can be nice to have.
100100
- `--without-headers`: tells the compiler not to rely on any headers from the host and instead generate its own.
101101

102+
It will download the missing dependencies for us. Now is possible to re-run the `configure` command.
102103
Once the script is finished we can run a few make targets to build the compiler and its support libraries. By default running `make`/`make all` is not recommended as this builds everything for a full userspace compiler. We don't need all that and it can take a lot of time. For a freestanding program like a kernel we only need the compiler and libgcc.
103104

104105
```bash
@@ -128,13 +129,15 @@ Of course we can use any emulator we want, but in our example we rely on qemu. T
128129

129130
* ninja-build
130131
* python3-sphinx
132+
* python3-pip
133+
* python3-venv
131134
* sphinx-rtd-theme
132-
* If we want to use the gtk ui, we also need libgtk3-dev
135+
* If we want to use the gtk ui, we also need libgtk-3-dev
133136

134137
As usual let's create a new folder called `build_qemu` and move into it. The configure command is:
135138

136139
```bash
137-
/path/qemu_src/configure --prefix=$PREFIX --target-list=riscv64-softmmu --enable-gtk --enable-gtk-clipboard --enable-tools --enable-vhost-net
140+
/path/qemu_src/configure --prefix=$PREFIX --target-list=riscv64-softmmu,x86_64-softmmu --enable-gtk --enable-gtk-clipboard --enable-tools --enable-vhost-net
138141
```
139142
where:
140143

@@ -154,7 +157,7 @@ Qemu is quite a large program, so it's recommended to make use of all cores when
154157

155158
## GDB
156159

157-
The steps for building GDB are similar to binutils and GCC. We'll create a temporary working directory and move into it. Gdb has a few extra dependencies we'll need (name can be different depending on the distribution used):
160+
The steps for building GDB are similar to binutils and GCC. We'll create a temporary working directory and move into it. Gdb has a few extra dependencies we'll need (name can be different depending on the distribution used, the names below are for _Debian_ based distributions):
158161

159162
* libncurses-dev
160163
* libsource-highlight-dev

0 commit comments

Comments
 (0)