While we have already provided the gdb/gdbserver statically compiled binaries for you, some people might want to compile it without our build scripts, or compile a newer version of gdb in the future :).
The rest of the file contains a documentation of the compilation process, in order to help you out.
NOTE: The compilation guide describes the compilation process in order to create a minimal-working version of gdb. Our build-scripts also provides further capabilites to gdb, such as python and xml support, which are not documented in this file.
Environment variables are denoted by <...> throughout this file.
Please note that when specifying a compilation dir throughout the compilation process (via the <COMPILATION_DIR_PATH> environment variable), DO NOT use relative pathing, or special bash characters such as `~`. Relative pathing / special bash characters will not get parsed correctly!
- glibc version: 2.39-0ubuntu8.3 (NOTE: When i compiled gdb using an older glibc, such as the one i had in my ubuntu-20.04 machine, i received a segfault in gdb, so the libc version is important!).
Clone gdb from from my forked respository - https://github.com/guyush1/binutils-gdb/tree/gdb-static.
Make sure to check out to the **gdb-static** branch - this branch contains all of the changes i had to do to the build system in order for it to compile gdb statically.
# Cross compiling gdb statically to other architectures.
Cross compiling gdb statically is a bit more complicated then regular static compilation. In order to cross compile gdb statically, we will need to compile libgmp and libmpfr as well as iconv.
## 1) Compiling iconv
Work according to the same process as described under the compilation to the host platform, aside from the configure script:
IV) run `../configure --enable-static CC=<CROSS_COMPILER_C> CXX=<CROSS_COMPILER_CPP> --host=<HOST_NAME>`
## 2) Compiling libgmp
Download and extract the latest edition from https://gmplib.org/.