Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# IDE Folders
.idea/
.vscode/

# Build folders
build/
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM ubuntu:24.04

# Install dependencies
RUN apt update && apt install -y \
g++ \
g++-aarch64-linux-gnu \
g++-arm-linux-gnueabi \
g++-powerpc-linux-gnu \
gcc \
gcc-aarch64-linux-gnu \
gcc-arm-linux-gnueabi \
gcc-powerpc-linux-gnu \
m4 \
make \
patch \
texinfo \
wget \
xz-utils

WORKDIR /app/gdb
54 changes: 54 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
ARCHS := x86_64 arm aarch64 powerpc
TARGETS := $(addprefix build-, $(ARCHS))

.PHONY: clean help download_packages build patch-gdb build-docker-image $(TARGETS)

help:
@echo "Usage:"
@echo " make build"
@echo ""

@for target in $(TARGETS); do \
echo " $$target"; \
done

@echo ""
@echo " make clean"

build/build-docker-image.stamp: Dockerfile
mkdir -p build
docker build -t gdb-static .
touch build/build-docker-image.stamp

build-docker-image: build/build-docker-image.stamp

build/download-packages.stamp: build/build-docker-image.stamp src/download_packages.sh
mkdir -p build/packages
docker run --user $(shell id -u):$(shell id -g) \
--rm --volume .:/app/gdb gdb-static env TERM=xterm-256color \
/app/gdb/src/download_packages.sh /app/gdb/build/packages
touch build/download-packages.stamp

download-packages: build/download-packages.stamp

build/patch-gdb.stamp: build/build-docker-image.stamp src/gdb_static.patch build/download-packages.stamp
docker run --user $(shell id -u):$(shell id -g) \
--rm --volume .:/app/gdb gdb-static env TERM=xterm-256color \
/app/gdb/src/patch_gdb.sh /app/gdb/build/packages/gdb /app/gdb/src/gdb_static.patch
touch build/patch-gdb.stamp

patch-gdb: build/patch-gdb.stamp

build: $(TARGETS)

$(TARGETS): build-%: download-packages patch-gdb build-docker-image
mkdir -p build
docker run --user $(shell id -u):$(shell id -g) \
--rm --volume .:/app/gdb gdb-static env TERM=xterm-256color \
/app/gdb/src/build.sh $* /app/gdb/build/ /app/gdb/src/gdb_static.patch

clean:
rm -rf build
# Kill and remove all containers of image gdb-static
docker ps -a | grep -P "^[a-f0-9]+\s+gdb-static\s+" | awk '{print $$1}' | xargs docker rm -f 2>/dev/null || true
docker rmi -f gdb-static 2>/dev/null || true
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,53 @@

The statically compiled gdb / gdbserver binaries are avaliable to download under github releases!

# Compiling gdb using docker

This repository contains a dockerfile and build scripts to compile gdb and gdbserver statically for multiple architectures.
Currently, the supported architectures are:
- x86_64
- arm
- aarch64
- powerpc (32bit)
You can easily expand it to support more architectures by adding the appropriate cross compilers to the dockerfile, and other build scripts.

NOTE: You don't need to interact with the dockerfile directly, as the Makefile will take care of everything for you.

## Building for a specific architecture

To build for a specific architecture, you can use the following command:
```bash
make build-<ARCH>
```

For example, to build for arm:
```bash
make build-arm
```

The resulting binaries will be placed under the `build/artifacts/` directory.
Each architecture will have its own directory under `build/artifacts/`. For example, the arm architecture will have the following directory structure:
```
build/
artifacts/
arm/
...
```

## Building for all architectures

To build for all architectures, you can use the following command:
```bash
make build
```

## Cleaning the build

To clean the build, you can use the following command:
```bash
make clean
```

# Notes about this file - read before proceeding!

While i already provided the gdb/gdbserver-15 statically compiled binaries handed out to you, some people might want to compile it to a different architecture, or compile a newer version of gdb in the future :). This rest of the file contains my compilation documentation so that you could save yourself some time and do it yourself, if you wish.
Expand Down Expand Up @@ -86,6 +133,8 @@ II) run `../configure CC=<CROSS_COMPILER_C> CXX=<CROSS_COMPILER_CPP> --enable-st
III) run `make -j$(nproc)`
IV) run `mkdir ./src/.libs/lib`
V) run `cp ./src/.libs/libmpfr.a ./src/.libs/lib`
VI) run `mkdir ./src/.libs/include`
VII) run `cp ../src/mpfr.h ./src/.libs/include/`

## 4) Compiling gdb

Expand Down
Loading