Skip to content

Use musl finally #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Apr 25, 2025
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 .github/workflows/pr-pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:

jobs:
build:
env:
TTY_ARG: "" # Disable interactive build mode in cicd since it does not contain a tty device.

strategy:
matrix:
build_type: ["build", "build-with-python"]
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/release-pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
# simply build the files in the same job they are released.
jobs:
build_and_publish:
env:
TTY_ARG: "" # Disable interactive build mode in cicd since it does not contain a tty device.

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -27,4 +30,4 @@ jobs:
- name: Publish release
uses: softprops/action-gh-release@v2
with:
files: build/artifacts/gdb-static*.tar.gz
files: build/artifacts/gdb-static*.tar.gz
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@
[submodule "src/submodule_packages/libexpat"]
path = src/submodule_packages/libexpat
url = git@github.com:guyush1/libexpat.git
[submodule "xz"]
path = src/submodule_packages/xz
url = https://github.com/tukaani-project/xz.git
11 changes: 9 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
FROM ubuntu:24.04

# Install dependencies
RUN apt update && apt install -y \
autopoint \
binutils-multiarch \
bison \
file \
flex \
Expand All @@ -18,16 +19,22 @@ RUN apt update && apt install -y \
gcc-mipsel-linux-gnu \
gcc-powerpc-linux-gnu \
git \
libncurses-dev \
libtool \
m4 \
make \
patch \
pkg-config \
python3.12 \
python3-requests \
libpython3-dev \
texinfo \
wget \
xz-utils

COPY src/docker_utils/download_musl_toolchains.py .
RUN python3.12 -u download_musl_toolchains.py

WORKDIR /app/gdb

ENTRYPOINT ["/entrypoint.sh"]
CMD ["bash"]
10 changes: 7 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ ALL_PACK_TARGETS := $(PACK_TARGETS) $(PYTHON_PACK_TARGETS)
SUBMODULE_PACKAGES := $(wildcard src/submodule_packages/*)
BUILD_PACKAGES_DIR := "build/packages"

# We would like to run in interactive mode when avaliable (non-ci usually).
# This is disabled by the ci automation manually.
TTY_ARG ?= -it

.PHONY: clean help download_packages build build-docker-image $(ALL_TARGETS) $(ALL_PACK_TARGETS)

.NOTPARALLEL: build pack
Expand All @@ -27,7 +31,7 @@ help:
@echo ""
@echo " make clean"

build/build-docker-image.stamp: Dockerfile
build/build-docker-image.stamp: Dockerfile src/docker_utils/download_musl_toolchains.py
mkdir -p build
docker buildx build --tag gdb-static .
touch build/build-docker-image.stamp
Expand All @@ -36,7 +40,7 @@ build-docker-image: build/build-docker-image.stamp

build/download-packages.stamp: build/build-docker-image.stamp src/compilation/download_packages.sh
mkdir -p $(BUILD_PACKAGES_DIR)
docker run --user $(shell id -u):$(shell id -g) \
docker run $(TTY_ARG) --user $(shell id -u):$(shell id -g) \
--rm --volume .:/app/gdb gdb-static env TERM=xterm-256color \
/app/gdb/src/compilation/download_packages.sh /app/gdb/$(BUILD_PACKAGES_DIR)/
touch build/download-packages.stamp
Expand All @@ -59,7 +63,7 @@ $(PYTHON_TARGETS): build-with-python-%:

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

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ This is where `gdb-static` comes in! We provide static builds of `gdb` (and `gdb
</summary> <br />

- **Static Builds**: No dependencies, no installation, just download and run!
- **Musl Based**: We use Musl in order to create distribution-independant binaries that can work anywhere.
- **Latest Versions**: We keep our builds up-to-date with the latest versions of GDB.
- **Builtin Python (Optional)**: We provide builds with Python support built-in.
- **XML Support**: Our builds come with XML support built-in, which is useful for some GDB commands.
Expand Down
12 changes: 7 additions & 5 deletions compilation.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ Please note that when specifying a compilation dir throughout the compilation pr
Instead, always use absolute paths.

Examples to the <VARIABLES> throughout the script:
- <CROSS_COMPILER_C> - arm-linux-gnueabi-gcc
- <CROSS_COMPILER_CPP> - arm-linux-gnueabi-g++
- <HOST_NAME> - arm-linux-gnueabi
- <CROSS_COMPILER_C> - arm-linux-musleabi-gcc
- <CROSS_COMPILER_CPP> - arm-linux-musleabi-g++
- <HOST_NAME> - arm-linux-musleabi
- <COMPILATION_DIR_PATH> - /home/username/projects/libgmp-x.y.z/build-arm/

Environment info:
- 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!).
## Choosing the right compiler

It is recommended to use a musl-based compiler. Unlike glibc, musl is not dependant on your distribution.
Using regular gcc that is glibc based should work most of the time, but we had some people reporting crashes mainly in gdbserver, so we switched to musl-based toolchains.

# Compiling gdb statically to the host platform

Expand Down
Loading