Compare commits
No commits in common. "develop" and "add-mips-mipsel" have entirely different histories.
develop
...
add-mips-m
343
.github/assets/gdb-static_logo_dark.inkscape.svg
vendored
343
.github/assets/gdb-static_logo_dark.inkscape.svg
vendored
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 76 KiB |
193
.github/assets/gdb-static_logo_dark.svg
vendored
193
.github/assets/gdb-static_logo_dark.svg
vendored
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 72 KiB |
343
.github/assets/gdb-static_logo_light.inkscape.svg
vendored
343
.github/assets/gdb-static_logo_light.inkscape.svg
vendored
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 76 KiB |
193
.github/assets/gdb-static_logo_light.svg
vendored
193
.github/assets/gdb-static_logo_light.svg
vendored
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 72 KiB |
@ -1,19 +1,19 @@
|
|||||||
name: gdb-static-release-pipeline
|
name: gdb-static-pipeline
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- '*'
|
||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- 'v*'
|
- 'v*'
|
||||||
|
|
||||||
# Use a non-parallel single job pipeline because artifacts weigh too much. Instead,
|
|
||||||
# simply build the files in the same job they are released.
|
|
||||||
jobs:
|
jobs:
|
||||||
build_and_publish:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
|
||||||
submodules: recursive
|
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: sudo apt-get install -y wget
|
run: sudo apt-get install -y wget
|
||||||
@ -24,7 +24,14 @@ jobs:
|
|||||||
- name: Pack
|
- name: Pack
|
||||||
run: make pack
|
run: make pack
|
||||||
|
|
||||||
|
- name: Upload artifact
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: gdb-static
|
||||||
|
path: build/artifacts/gdb-static*.tar.gz
|
||||||
|
|
||||||
- name: Publish release
|
- name: Publish release
|
||||||
|
if: github.event_name == 'push'
|
||||||
uses: softprops/action-gh-release@v2
|
uses: softprops/action-gh-release@v2
|
||||||
with:
|
with:
|
||||||
files: build/artifacts/gdb-static*.tar.gz
|
files: build/artifacts/gdb-static*.tar.gz
|
25
.github/workflows/pr-pipeline.yaml
vendored
25
.github/workflows/pr-pipeline.yaml
vendored
@ -1,25 +0,0 @@
|
|||||||
name: gdb-static-pr-pipeline
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- '*'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
build_type: ["build", "build-with-python"]
|
|
||||||
architecture: ["x86_64", "arm", "aarch64", "powerpc", "mips", "mipsel"]
|
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
submodules: recursive
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: sudo apt-get install -y wget
|
|
||||||
|
|
||||||
- name: Build
|
|
||||||
run: make ${{ matrix.build_type }}-${{ matrix.architecture }} -j$((`nproc`+1))
|
|
14
.gitmodules
vendored
14
.gitmodules
vendored
@ -1,14 +0,0 @@
|
|||||||
[submodule "cpython-static"]
|
|
||||||
path = src/submodule_packages/cpython-static
|
|
||||||
url = git@github.com:guyush1/cpython-static.git
|
|
||||||
branch = python3.12-static
|
|
||||||
[submodule "binutils-gdb-static"]
|
|
||||||
path = src/submodule_packages/binutils-gdb
|
|
||||||
url = git@github.com:guyush1/binutils-gdb.git
|
|
||||||
branch = gdb-static
|
|
||||||
[submodule "src/submodule_packages/pygments"]
|
|
||||||
path = src/submodule_packages/pygments
|
|
||||||
url = git@github.com:pygments/pygments.git
|
|
||||||
[submodule "src/submodule_packages/libexpat"]
|
|
||||||
path = src/submodule_packages/libexpat
|
|
||||||
url = git@github.com:guyush1/libexpat.git
|
|
@ -2,9 +2,6 @@ FROM ubuntu:24.04
|
|||||||
|
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
RUN apt update && apt install -y \
|
RUN apt update && apt install -y \
|
||||||
bison \
|
|
||||||
file \
|
|
||||||
flex \
|
|
||||||
g++ \
|
g++ \
|
||||||
g++-aarch64-linux-gnu \
|
g++-aarch64-linux-gnu \
|
||||||
g++-arm-linux-gnueabi \
|
g++-arm-linux-gnueabi \
|
||||||
@ -17,15 +14,9 @@ RUN apt update && apt install -y \
|
|||||||
gcc-mips-linux-gnu \
|
gcc-mips-linux-gnu \
|
||||||
gcc-mipsel-linux-gnu \
|
gcc-mipsel-linux-gnu \
|
||||||
gcc-powerpc-linux-gnu \
|
gcc-powerpc-linux-gnu \
|
||||||
git \
|
|
||||||
libncurses-dev \
|
|
||||||
libtool \
|
|
||||||
m4 \
|
m4 \
|
||||||
make \
|
make \
|
||||||
patch \
|
patch \
|
||||||
pkg-config \
|
|
||||||
python3.12 \
|
|
||||||
libpython3-dev \
|
|
||||||
texinfo \
|
texinfo \
|
||||||
wget \
|
wget \
|
||||||
xz-utils
|
xz-utils
|
||||||
|
64
Makefile
64
Makefile
@ -1,26 +1,15 @@
|
|||||||
ARCHS := x86_64 arm aarch64 powerpc mips mipsel
|
ARCHS := x86_64 arm aarch64 powerpc mips mipsel
|
||||||
|
|
||||||
TARGETS := $(addprefix build-, $(ARCHS))
|
TARGETS := $(addprefix build-, $(ARCHS))
|
||||||
PYTHON_TARGETS := $(addprefix build-with-python-, $(ARCHS))
|
|
||||||
ALL_TARGETS := $(TARGETS) $(PYTHON_TARGETS)
|
|
||||||
|
|
||||||
PACK_TARGETS := $(addprefix pack-, $(ARCHS))
|
PACK_TARGETS := $(addprefix pack-, $(ARCHS))
|
||||||
PYTHON_PACK_TARGETS := $(addprefix pack-with-python-, $(ARCHS))
|
|
||||||
ALL_PACK_TARGETS := $(PACK_TARGETS) $(PYTHON_PACK_TARGETS)
|
|
||||||
|
|
||||||
SUBMODULE_PACKAGES := $(wildcard src/submodule_packages/*)
|
.PHONY: clean help download_packages build patch-gdb build-docker-image $(TARGETS) $(PACK_TARGETS)
|
||||||
BUILD_PACKAGES_DIR := "build/packages"
|
|
||||||
|
|
||||||
.PHONY: clean help download_packages build build-docker-image $(ALL_TARGETS) $(ALL_PACK_TARGETS)
|
|
||||||
|
|
||||||
.NOTPARALLEL: build pack
|
|
||||||
|
|
||||||
help:
|
help:
|
||||||
@echo "Usage:"
|
@echo "Usage:"
|
||||||
@echo " make build"
|
@echo " make build"
|
||||||
@echo ""
|
@echo ""
|
||||||
|
|
||||||
@for target in $(ALL_TARGETS); do \
|
@for target in $(TARGETS); do \
|
||||||
echo " $$target"; \
|
echo " $$target"; \
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -29,57 +18,44 @@ help:
|
|||||||
|
|
||||||
build/build-docker-image.stamp: Dockerfile
|
build/build-docker-image.stamp: Dockerfile
|
||||||
mkdir -p build
|
mkdir -p build
|
||||||
docker buildx build --tag gdb-static .
|
docker build -t gdb-static .
|
||||||
touch build/build-docker-image.stamp
|
touch build/build-docker-image.stamp
|
||||||
|
|
||||||
build-docker-image: build/build-docker-image.stamp
|
build-docker-image: build/build-docker-image.stamp
|
||||||
|
|
||||||
build/download-packages.stamp: build/build-docker-image.stamp src/compilation/download_packages.sh
|
build/download-packages.stamp: build/build-docker-image.stamp src/download_packages.sh
|
||||||
mkdir -p $(BUILD_PACKAGES_DIR)
|
mkdir -p build/packages
|
||||||
docker run --user $(shell id -u):$(shell id -g) \
|
docker run --user $(shell id -u):$(shell id -g) \
|
||||||
--rm --volume .:/app/gdb gdb-static env TERM=xterm-256color \
|
--rm --volume .:/app/gdb gdb-static env TERM=xterm-256color \
|
||||||
/app/gdb/src/compilation/download_packages.sh /app/gdb/$(BUILD_PACKAGES_DIR)/
|
/app/gdb/src/download_packages.sh /app/gdb/build/packages
|
||||||
touch build/download-packages.stamp
|
touch build/download-packages.stamp
|
||||||
|
|
||||||
build/symlink-git-packages.stamp: $(SUBMODULE_PACKAGES)
|
|
||||||
mkdir -p $(BUILD_PACKAGES_DIR)
|
|
||||||
ln -sf $(addprefix /app/gdb/, $(SUBMODULE_PACKAGES)) $(BUILD_PACKAGES_DIR)/
|
|
||||||
|
|
||||||
symlink-git-packages: build/symlink-git-packages.stamp
|
|
||||||
|
|
||||||
download-packages: build/download-packages.stamp
|
download-packages: build/download-packages.stamp
|
||||||
|
|
||||||
build: $(ALL_TARGETS)
|
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
|
||||||
|
|
||||||
$(TARGETS): build-%:
|
patch-gdb: build/patch-gdb.stamp
|
||||||
@$(MAKE) _build-$*
|
|
||||||
|
|
||||||
$(PYTHON_TARGETS): build-with-python-%:
|
build: $(TARGETS)
|
||||||
@WITH_PYTHON="--with-python" $(MAKE) _build-$*
|
|
||||||
|
|
||||||
_build-%: symlink-git-packages download-packages build-docker-image
|
$(TARGETS): build-%: download-packages patch-gdb build-docker-image
|
||||||
mkdir -p build
|
mkdir -p build
|
||||||
docker run --user $(shell id -u):$(shell id -g) \
|
docker run --user $(shell id -u):$(shell id -g) \
|
||||||
--rm --volume .:/app/gdb gdb-static env TERM=xterm-256color \
|
--rm --volume .:/app/gdb gdb-static env TERM=xterm-256color \
|
||||||
/app/gdb/src/compilation/build.sh $* /app/gdb/build/ /app/gdb/src $(WITH_PYTHON)
|
/app/gdb/src/build.sh $* /app/gdb/build/ /app/gdb/src/gdb_static.patch
|
||||||
|
|
||||||
pack: $(ALL_PACK_TARGETS)
|
pack: $(PACK_TARGETS)
|
||||||
|
|
||||||
$(PACK_TARGETS): pack-%:
|
$(PACK_TARGETS): pack-%: build-%
|
||||||
@$(MAKE) _pack-$*
|
if [ ! -f "build/artifacts/gdb-static-$*.tar.gz" ]; then \
|
||||||
|
tar -czf "build/artifacts/gdb-static-$*.tar.gz" -C "build/artifacts/$*" .; \
|
||||||
$(PYTHON_PACK_TARGETS): pack-with-python-%:
|
|
||||||
@TAR_EXT="with-python-" ARTIFACT_EXT="_with_python" $(MAKE) _pack-$*
|
|
||||||
|
|
||||||
_pack-%: build-%
|
|
||||||
if [ ! -f "build/artifacts/gdb-static-$(TAR_EXT)$*.tar.gz" ]; then \
|
|
||||||
tar -czf "build/artifacts/gdb-static-$(TAR_EXT)$*.tar.gz" -C "build/artifacts/$*$(ARTIFACT_EXT)" .; \
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
clean-git-packages:
|
clean:
|
||||||
git submodule foreach '[[ ! "$$sm_path" == src/submodule_packages/* ]] || git clean -xffd'
|
|
||||||
|
|
||||||
clean: clean-git-packages
|
|
||||||
rm -rf build
|
rm -rf build
|
||||||
# Kill and remove all containers of image gdb-static
|
# 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 ps -a | grep -P "^[a-f0-9]+\s+gdb-static\s+" | awk '{print $$1}' | xargs docker rm -f 2>/dev/null || true
|
||||||
|
162
README.md
162
README.md
@ -1,150 +1,54 @@
|
|||||||
<h1 align="center">
|
# Repository of static gdb and gdbserver
|
||||||
<picture>
|
|
||||||
<source media="(prefers-color-scheme: dark)" srcset="./.github/assets/gdb-static_logo_dark.svg">
|
|
||||||
<source media="(prefers-color-scheme: light)" srcset="./.github/assets/gdb-static_logo_light.svg">
|
|
||||||
<img src="./.github/assets/gdb-static_logo_light.svg" alt="gdb-static" width="210px">
|
|
||||||
</picture>
|
|
||||||
</h1>
|
|
||||||
|
|
||||||
<p align="center">
|
## **The statically compiled gdb / gdbserver binaries are avaliable to download under github releases!**
|
||||||
<i align="center">Frozen static builds of everyone's favorite debugger!🧊</i>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<h4 align="center">
|
link: [gdb-static github releases](https://github.com/guyush1/gdb-static/releases)
|
||||||
<a href="https://github.com/guyush1/gdb-static/releases/latest">
|
|
||||||
<img src="https://img.shields.io/github/v/release/guyush1/gdb-static?style=flat-square" alt="release" style="height: 20px;">
|
|
||||||
<a href="https://github.com/guyush1/gdb-static/actions/workflows/pr-pipeline.yaml">
|
|
||||||
<img src="https://img.shields.io/github/actions/workflow/status/guyush1/gdb-static/pr-pipeline.yaml?style=flat-square&label=pipeline" alt="continuous integration" style="height: 20px;">
|
|
||||||
</a>
|
|
||||||
<a href="https://github.com/guyush1/gdb-static/graphs/contributors">
|
|
||||||
<img src="https://img.shields.io/github/contributors-anon/guyush1/gdb-static?color=yellow&style=flat-square" alt="contributors" style="height: 20px;">
|
|
||||||
</a>
|
|
||||||
<br>
|
|
||||||
<img src="https://img.shields.io/badge/GDB-v16.2-orange?logo=gnu&logoColor=white&style=flat-square" alt="gdb" style="height: 20px;">
|
|
||||||
<img src="https://img.shields.io/badge/Python-built--in-blue?logo=python&logoColor=white&style=flat-square" alt="python" style="height: 20px;">
|
|
||||||
</h4>
|
|
||||||
|
|
||||||
## TL;DR
|
## For manual gdb/gdbserver compilation instructions, have a look at the compilation.md file
|
||||||
|
|
||||||
- **Download**: Get the latest release from the [releases page](https://github.com/guyush1/gdb-static/releases/latest).
|
## Compiling gdb using docker
|
||||||
|
|
||||||
## Introduction
|
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.
|
||||||
|
|
||||||
Who doesn't love GDB? It's such a powerful tool, with such a great package.
|
NOTE: You don't need to interact with the dockerfile directly, as the Makefile will take care of everything for you.
|
||||||
But sometimes, you run into one of these problems:
|
|
||||||
- You can't install GDB on your machine
|
|
||||||
- You can't install an updated version of GDB on your machine
|
|
||||||
- Some other strange embedded reasons...
|
|
||||||
|
|
||||||
This is where `gdb-static` comes in! We provide static builds of `gdb` (and `gdbserver` of course), so you can run them on any machine, without any dependencies!
|
### Building for a specific architecture
|
||||||
|
|
||||||
<details open>
|
|
||||||
<summary>
|
|
||||||
Features
|
|
||||||
</summary> <br />
|
|
||||||
|
|
||||||
- **Static Builds**: No dependencies, no installation, just download and run!
|
|
||||||
- **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.
|
|
||||||
- **Wide Architecture Support**: We support a wide range of architectures:
|
|
||||||
- aarch64
|
|
||||||
- arm
|
|
||||||
- mips
|
|
||||||
- mipsel
|
|
||||||
- powerpc
|
|
||||||
- x86_64
|
|
||||||
|
|
||||||
</details>
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
To get started with `gdb-static`, simply download the build for your architecture from the [releases page](https://github.com/guyush1/gdb-static/releases/latest), extract the archive, and copy the binary to your desired platform.
|
|
||||||
|
|
||||||
> [!NOTE]
|
|
||||||
> We provide two types of builds:
|
|
||||||
> 1. Builds with Python support, which are approximately ~30 MB in size.
|
|
||||||
> 2. Slimmer builds without Python support, which are approximately ~7 MB in size.
|
|
||||||
|
|
||||||
You may choose to copy the `gdb` binary to the platform, or use `gdbserver` to debug remotely.
|
|
||||||
|
|
||||||
## Development
|
|
||||||
|
|
||||||
> [!NOTE]
|
|
||||||
> Before building, make sure to initialize & sync the git submodules.
|
|
||||||
|
|
||||||
Alternatively, you can build `gdb-static` from source. To do so, follow the instructions below:
|
|
||||||
|
|
||||||
<details open>
|
|
||||||
<summary>
|
|
||||||
Pre-requisites
|
|
||||||
</summary> <br />
|
|
||||||
To be able to build `gdb-static`, you will need the following tools installed on your machine:
|
|
||||||
|
|
||||||
###
|
|
||||||
|
|
||||||
- Docker
|
|
||||||
- Docker buildx
|
|
||||||
- Git
|
|
||||||
</details>
|
|
||||||
|
|
||||||
<details open>
|
|
||||||
<summary>
|
|
||||||
Building for a specific architecture
|
|
||||||
</summary> <br />
|
|
||||||
|
|
||||||
To build `gdb-static` for a specific architecture, run the following command:
|
|
||||||
|
|
||||||
|
To build for a specific architecture, you can use the following command:
|
||||||
```bash
|
```bash
|
||||||
make build[-with-python]-<ARCH>
|
make build-<ARCH>
|
||||||
```
|
```
|
||||||
|
|
||||||
Where `<ARCH>` is the architecture you want to build for, and `-with-python` may be added in order to compile gdb with Python support.
|
For example, to build for arm:
|
||||||
|
|
||||||
The resulting binary will be placed in the `build/artifacts/` directory:
|
|
||||||
|
|
||||||
```bash
|
```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/
|
build/
|
||||||
└── artifacts/
|
artifacts/
|
||||||
└── <ARCH>/
|
arm/
|
||||||
└── ...
|
...
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
### Building for all architectures
|
||||||
|
|
||||||
<details open>
|
|
||||||
<summary>
|
|
||||||
Building for all architectures
|
|
||||||
</summary> <br />
|
|
||||||
|
|
||||||
To build `gdb-static` for all supported architectures, run the following command:
|
|
||||||
|
|
||||||
|
To build for all architectures, you can use the following command:
|
||||||
```bash
|
```bash
|
||||||
make build
|
make build
|
||||||
```
|
```
|
||||||
|
|
||||||
The resulting binary will be placed in the `build/artifacts/` directory.
|
### Cleaning the build
|
||||||
|
|
||||||
</details>
|
To clean the build, you can use the following command:
|
||||||
|
```bash
|
||||||
<a name="contributing_anchor"></a>
|
make clean
|
||||||
## Contributing
|
```
|
||||||
|
|
||||||
- Bug Report: If you see an error message or encounter an issue while using gdb-static, please create a [bug report](https://github.com/guyush1/gdb-static/issues/new?assignees=&labels=bug&title=%F0%9F%90%9B+Bug+Report%3A+).
|
|
||||||
|
|
||||||
- Feature Request: If you have an idea or if there is a capability that is missing and would make `gdb-static` more robust, please submit a [feature request](https://github.com/guyush1/gdb-static/issues/new?assignees=&labels=enhancement&title=%F0%9F%9A%80+Feature+Request%3A+).
|
|
||||||
|
|
||||||
## Contributors
|
|
||||||
|
|
||||||
<!---
|
|
||||||
npx contributor-faces --exclude "*bot*" --limit 70 --repo "https://github.com/guyush1/gdb-static"
|
|
||||||
|
|
||||||
change the height and width for each of the contributors from 80 to 50.
|
|
||||||
--->
|
|
||||||
|
|
||||||
[//]: contributor-faces
|
|
||||||
<a href="https://github.com/guyush1"><img src="https://avatars.githubusercontent.com/u/82650790?v=4" title="guyush1" width="80" height="80"></a>
|
|
||||||
<a href="https://github.com/RoiKlevansky"><img src="https://avatars.githubusercontent.com/u/78471889?v=4" title="RoiKlevansky" width="80" height="80"></a>
|
|
||||||
<a href="https://github.com/roddyrap"><img src="https://avatars.githubusercontent.com/u/37045659?v=4" title="roddyrap" width="80" height="80"></a>
|
|
||||||
|
|
||||||
[//]: contributor-faces
|
|
||||||
|
@ -1,58 +1,49 @@
|
|||||||
# Notes about this file - read before proceeding!
|
# Notes about this file - read before proceeding!
|
||||||
|
|
||||||
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 :).
|
While i have already provided the gdb/gdbserver-15 statically compiled binaries for you, some people might want to compile it to a different architecture (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.
|
||||||
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.
|
## <VARAIBLES> in the script
|
||||||
|
|
||||||
## <VARAIBLES> In this file
|
When specifying the compilation dir throughout the compilation process (specified as <COMPILATION_DIR_PATH> in this file), DO NOT use relative pathing, or bash characters such as `~`. They will not get parsed correctly! Instead, use absolute paths only.
|
||||||
|
|
||||||
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!
|
|
||||||
|
|
||||||
Instead, always use absolute paths.
|
|
||||||
|
|
||||||
Examples to the <VARIABLES> throughout the script:
|
Examples to the <VARIABLES> throughout the script:
|
||||||
- <CROSS_COMPILER_C> - arm-linux-gnueabi-gcc
|
<CROSS_COMPILER_C> - arm-linux-gnueabi-gcc
|
||||||
- <CROSS_COMPILER_CPP> - arm-linux-gnueabi-g++
|
<CROSS_COMPILER_CPP> - arm-linux-gnueabi-g++
|
||||||
- <HOST_NAME> - arm-linux-gnueabi
|
<HOST_NAME> - arm-linux-gnueabi
|
||||||
- <COMPILATION_DIR_PATH> - /home/username/projects/libgmp-x.y.z/build-arm/
|
<COMPILATION_DIR_PATH> - /home/username/projects/libgmp-x.y.z/build-arm/
|
||||||
|
|
||||||
Environment info:
|
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!).
|
- glibc version: 2.39-0ubuntu8.3 (NOTE: When i compiled gdb-15 using an older glibc, such as the one i had in my ubuntu-20.04 machine, i received a segfault in gdb...).
|
||||||
|
|
||||||
# Compiling gdb statically to the host platform
|
# Compiling gdb statically to the host platform
|
||||||
|
|
||||||
## 1) Compiling iconv
|
## 1) Compiling iconv
|
||||||
|
|
||||||
While compiling iconv is not a must, the libc-provided iconv (a utility to convert between encodings) may fail on different architectures,
|
While compiling iconv is not a must, the libc-provided iconv (a utility to convert between encodings) may fail on different architectures,
|
||||||
at least in my experience.
|
at least in my experiance. Thus, I recommended using a custom libiconv and compiling it into gdb.
|
||||||
Thus, I recommended using a custom libiconv and compiling it into gdb.
|
|
||||||
|
|
||||||
Download the source from https://github.com/roboticslibrary/libiconv.git
|
Download the source from https://github.com/roboticslibrary/libiconv.git
|
||||||
|
|
||||||
Make sure to check out to a stable tag (in my case - v1.17).
|
Make sure to check out to a stable tag (in my case - v1.17).
|
||||||
|
|
||||||
Work according to the following steps:
|
Work according to the following steps:
|
||||||
1. run `./gitsub.sh pull`
|
I) run `./gitsub.sh pull`
|
||||||
2. run `./autogen.sh` to create the configure script from configure.sh.
|
II) run `./autogen.sh` to create the configure script from configure.sh.
|
||||||
3. create a build dir (e.g build), and then cd into it.
|
III) create a build dir (e.g build), and then cd into it.
|
||||||
4. run `../configure --enable-static`
|
IV) run `../configure --enable-static`
|
||||||
5. run `cp -r ./include ./lib/.libs/`
|
V) run `cp -r ./include ./lib/.libs/`
|
||||||
6. run `mkdir ./lib/.libs/lib/`
|
VI) run `mkdir ./lib/.libs/lib/`
|
||||||
7. run `cp ./lib/.libs/libiconv.a ./lib/.libs/lib/`
|
VII) run `cp ./lib/.libs/libiconv.a ./lib/.libs/lib/`
|
||||||
|
|
||||||
## 2) Compiling gdb
|
## 2) Compiling gdb
|
||||||
|
|
||||||
Clone gdb from from my forked respository - https://github.com/guyush1/binutils-gdb/tree/gdb-static.
|
Clone gdb from sourceware - https://sourceware.org/git/binutils-gdb.git.
|
||||||
|
I checked out to the 15.2 tag.
|
||||||
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.
|
|
||||||
|
|
||||||
Work according to the following steps:
|
Work according to the following steps:
|
||||||
1. create a build dir.
|
I) Apply my patches (gdb_static.patch). If you are not on the exact tag i used (15.2) - you might need to apply them manually, and change some stuff.
|
||||||
2. run `../configure --enable-static --with-static-standard-libraries --disable-tui --disable-inprocess-agent --with-libiconv-prefix=<COMPILATION_DIR_PATH>/lib/.libs/ --with-libiconv-type=static`
|
II) create a build dir.
|
||||||
3. run `make all-gdb -j$(nproc)` - for gdbserver, run `make all-gdbserver -j$(nproc)`.
|
III) run `../configure --enable-static --with-static-standard-libraries --disable-tui --disable-inprocess-agent --with-libiconv-prefix=<COMPILATION_DIR_PATH>/lib/.libs/ --with-libiconv-type=static`
|
||||||
|
IV) run `make all-gdb -j$(nproc)` - for gdbserver, run `make all-gdbserver -j$(nproc)`.
|
||||||
|
|
||||||
gdb will sit under gdb/gdb.
|
gdb will sit under gdb/gdb.
|
||||||
gdbserver will sit under gdbserver/gdbserver.
|
gdbserver will sit under gdbserver/gdbserver.
|
||||||
@ -72,13 +63,13 @@ Download and extract the latest edition from https://gmplib.org/.
|
|||||||
I used the 6.3.0 edition.
|
I used the 6.3.0 edition.
|
||||||
|
|
||||||
Work according to the following steps:
|
Work according to the following steps:
|
||||||
1. Create a build dir and cd into it.
|
I) Create a build dir and cd into it.
|
||||||
2. run `../configure CC=<CROSS_COMPILER_C> CXX=<CROSS_COMPILER_CPP> --enable-static --host=<HOST_NAME>`
|
II) run `../configure CC=<CROSS_COMPILER_C> CXX=<CROSS_COMPILER_CPP> --enable-static --host=<HOST_NAME>`
|
||||||
3. run `make -j$(nproc)`
|
III) run `make -j$(nproc)`
|
||||||
4. run `mkdir ./.libs/include/`
|
IV) run `mkdir ./.libs/include/`
|
||||||
5. run `cp gmp.h ./.libs/include/`
|
V) run `cp gmp.h ./.libs/include/`
|
||||||
6. run `mkdir ./.libs/lib`
|
VI) run `mkdir ./.libs/lib`
|
||||||
7. run `cp ./.libs/libgmp.a ./.libs/lib`
|
VII) run `cp ./.libs/libgmp.a ./.libs/lib`
|
||||||
|
|
||||||
## 3) Compiling libmpfr
|
## 3) Compiling libmpfr
|
||||||
|
|
||||||
@ -86,16 +77,15 @@ Download and extract the latest edition from https://www.mpfr.org/.
|
|||||||
I used the 4.2.1 edition.
|
I used the 4.2.1 edition.
|
||||||
|
|
||||||
Work according to the following steps:
|
Work according to the following steps:
|
||||||
1. Create a build dir and cd into it.
|
I) Create a build dir and cd into it.
|
||||||
2. run `../configure CC=<CROSS_COMPILER_C> CXX=<CROSS_COMPILER_CPP> --enable-static --with-gmp-build=<COMPILATION_DIR_PATH> --host=<HOST_NAME>`
|
II) run `../configure CC=<CROSS_COMPILER_C> CXX=<CROSS_COMPILER_CPP> --enable-static --with-gmp-build=<COMPILATION_DIR_PATH> --host=<HOST_NAME>`
|
||||||
3. run `make -j$(nproc)`
|
III) run `make -j$(nproc)`
|
||||||
4. run `mkdir ./src/.libs/lib`
|
IV) run `mkdir ./src/.libs/lib`
|
||||||
5. run `cp ./src/.libs/libmpfr.a ./src/.libs/lib`
|
V) run `cp ./src/.libs/libmpfr.a ./src/.libs/lib`
|
||||||
6. run `mkdir ./src/.libs/include`
|
VI) run `mkdir ./src/.libs/include`
|
||||||
7. run `cp ../src/mpfr.h ./src/.libs/include/`
|
VII) run `cp ../src/mpfr.h ./src/.libs/include/`
|
||||||
|
|
||||||
## 4) Compiling gdb
|
## 4) Compiling gdb
|
||||||
|
|
||||||
Work according to the same process as described under the compilation to the host platform, aside from the configure script:
|
Work according to the same process as described under the compilation to the host platform, aside from the configure script:
|
||||||
|
III) run `../configure --enable-static --with-static-standard-libraries --disable-tui --disable-inprocess-agent --with-libiconv-prefix=<COMPILATION_DIR_PATH>/lib/.libs/ --with-libiconv-type=static --with-gmp=<COMPILATION_DIR_PATH>/.libs/ --with-mpfr=<COMPILATION_DIR_PATH>/src/.libs/ CC=<CROSS_COMPILER_C> CXX=<CROSS_COMPILER_CPP> --host=<HOST_NAME>`
|
||||||
2. run `../configure --enable-static --with-static-standard-libraries --disable-tui --disable-inprocess-agent --with-libiconv-prefix=<COMPILATION_DIR_PATH>/lib/.libs/ --with-libiconv-type=static --with-gmp=<COMPILATION_DIR_PATH>/.libs/ --with-mpfr=<COMPILATION_DIR_PATH>/src/.libs/ CC=<CROSS_COMPILER_C> CXX=<CROSS_COMPILER_CPP> --host=<HOST_NAME>`
|
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "gdb-static",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/guyush1/gdb-static"
|
|
||||||
}
|
|
||||||
}
|
|
394
src/build.sh
Executable file
394
src/build.sh
Executable file
@ -0,0 +1,394 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Include utils library
|
||||||
|
script_dir=$(dirname "$0")
|
||||||
|
. "$script_dir/utils.sh"
|
||||||
|
|
||||||
|
function set_compliation_variables() {
|
||||||
|
# Set compilation variables such as which compiler to use.
|
||||||
|
#
|
||||||
|
# Parameters:
|
||||||
|
# $1: target architecture
|
||||||
|
#
|
||||||
|
# Returns:
|
||||||
|
# 0: success
|
||||||
|
# 1: failure
|
||||||
|
supported_archs=("arm" "aarch64" "powerpc" "x86_64" "mips" "mipsel")
|
||||||
|
|
||||||
|
local target_arch="$1"
|
||||||
|
|
||||||
|
if [[ ! " ${supported_archs[@]} " =~ " ${target_arch} " ]]; then
|
||||||
|
>&2 echo "Error: unsupported target architecture: $target_arch"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
>&2 fancy_title "Setting compilation variables for $target_arch"
|
||||||
|
|
||||||
|
if [[ "$target_arch" == "arm" ]]; then
|
||||||
|
CROSS=arm-linux-gnueabi-
|
||||||
|
export HOST=arm-linux-gnueabi
|
||||||
|
elif [[ "$target_arch" == "aarch64" ]]; then
|
||||||
|
CROSS=aarch64-linux-gnu-
|
||||||
|
export HOST=aarch64-linux-gnu
|
||||||
|
elif [[ "$target_arch" == "powerpc" ]]; then
|
||||||
|
CROSS=powerpc-linux-gnu-
|
||||||
|
export HOST=powerpc-linux-gnu
|
||||||
|
elif [[ "$target_arch" == "mips" ]]; then
|
||||||
|
CROSS=mips-linux-gnu-
|
||||||
|
export HOST=mips-linux-gnu
|
||||||
|
elif [[ "$target_arch" == "mipsel" ]]; then
|
||||||
|
CROSS=mipsel-linux-gnu-
|
||||||
|
export HOST=mipsel-linux-gnu
|
||||||
|
elif [[ "$target_arch" == "x86_64" ]]; then
|
||||||
|
CROSS=""
|
||||||
|
export HOST=x86_64-linux-gnu
|
||||||
|
fi
|
||||||
|
|
||||||
|
export CC="${CROSS}gcc"
|
||||||
|
export CXX="${CROSS}g++"
|
||||||
|
|
||||||
|
export CFLAGS="-O2"
|
||||||
|
export CXXFLAGS="-O2"
|
||||||
|
}
|
||||||
|
|
||||||
|
function build_iconv() {
|
||||||
|
# Build libiconv.
|
||||||
|
#
|
||||||
|
# Parameters:
|
||||||
|
# $1: iconv package directory
|
||||||
|
# $2: target architecture
|
||||||
|
#
|
||||||
|
# Echoes:
|
||||||
|
# The libiconv build directory
|
||||||
|
#
|
||||||
|
# Returns:
|
||||||
|
# 0: success
|
||||||
|
# 1: failure
|
||||||
|
|
||||||
|
local iconv_dir="$1"
|
||||||
|
local target_arch="$2"
|
||||||
|
local iconv_build_dir="$(realpath "$iconv_dir/build-$target_arch")"
|
||||||
|
|
||||||
|
echo "$iconv_build_dir"
|
||||||
|
mkdir -p "$iconv_build_dir"
|
||||||
|
|
||||||
|
if [[ -f "$iconv_build_dir/lib/.libs/libiconv.a" ]]; then
|
||||||
|
>&2 echo "Skipping build: iconv already built for $target_arch"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
pushd "$iconv_build_dir" > /dev/null
|
||||||
|
|
||||||
|
>&2 fancy_title "Building libiconv for $target_arch"
|
||||||
|
|
||||||
|
../configure --enable-static "CC=$CC" "CXX=$CXX" "--host=$HOST" \
|
||||||
|
"CFLAGS=$CFLAGS" "CXXFLAGS=$CXXFLAGS" 1>&2
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
make -j$(nproc) 1>&2
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cp -r ./include ./lib/.libs/
|
||||||
|
mkdir -p ./lib/.libs/lib/
|
||||||
|
cp ./lib/.libs/libiconv.a ./lib/.libs/lib/
|
||||||
|
|
||||||
|
>&2 fancy_title "Finished building libiconv for $target_arch"
|
||||||
|
|
||||||
|
popd > /dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
function build_libgmp() {
|
||||||
|
# Build libgmp.
|
||||||
|
#
|
||||||
|
# Parameters:
|
||||||
|
# $1: libgmp package directory
|
||||||
|
# $2: target architecture
|
||||||
|
#
|
||||||
|
# Echoes:
|
||||||
|
# The libgmp build directory
|
||||||
|
#
|
||||||
|
# Returns:
|
||||||
|
# 0: success
|
||||||
|
# 1: failure
|
||||||
|
|
||||||
|
local gmp_dir="$1"
|
||||||
|
local target_arch="$2"
|
||||||
|
local gmp_build_dir="$(realpath "$gmp_dir/build-$target_arch")"
|
||||||
|
|
||||||
|
echo "$gmp_build_dir"
|
||||||
|
mkdir -p "$gmp_build_dir"
|
||||||
|
|
||||||
|
if [[ -f "$gmp_build_dir/.libs/lib/libgmp.a" ]]; then
|
||||||
|
>&2 echo "Skipping build: libgmp already built for $target_arch"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
pushd "$gmp_build_dir" > /dev/null
|
||||||
|
|
||||||
|
>&2 fancy_title "Building libgmp for $target_arch"
|
||||||
|
|
||||||
|
../configure --enable-static "CC=$CC" "CXX=$CXX" "--host=$HOST" \
|
||||||
|
"CFLAGS=$CFLAGS" "CXXFLAGS=$CXXFLAGS" 1>&2
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
make -j$(nproc) 1>&2
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p ./.libs/include/
|
||||||
|
cp gmp.h ./.libs/include/
|
||||||
|
mkdir -p ./.libs/lib/
|
||||||
|
cp ./.libs/libgmp.a ./.libs/lib/
|
||||||
|
|
||||||
|
>&2 fancy_title "Finished building libgmp for $target_arch"
|
||||||
|
|
||||||
|
popd > /dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
function build_libmpfr() {
|
||||||
|
# Build libmpfr.
|
||||||
|
#
|
||||||
|
# Parameters:
|
||||||
|
# $1: mpfr package directory
|
||||||
|
# $2: libgmp build directory
|
||||||
|
# $3: target architecture
|
||||||
|
#
|
||||||
|
# Echoes:
|
||||||
|
# The libmpfr build directory
|
||||||
|
#
|
||||||
|
# Returns:
|
||||||
|
# 0: success
|
||||||
|
# 1: failure
|
||||||
|
|
||||||
|
local mpfr_dir="$1"
|
||||||
|
local libgmp_build_dir="$2"
|
||||||
|
local target_arch="$3"
|
||||||
|
local mpfr_build_dir="$(realpath "$mpfr_dir/build-$target_arch")"
|
||||||
|
|
||||||
|
mkdir -p "$mpfr_build_dir"
|
||||||
|
echo "$mpfr_build_dir"
|
||||||
|
|
||||||
|
if [[ -f "$mpfr_build_dir/src/.libs/lib/libmpfr.a" ]]; then
|
||||||
|
>&2 echo "Skipping build: libmpfr already built for $target_arch"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
pushd "$mpfr_dir/build-$target_arch" > /dev/null
|
||||||
|
|
||||||
|
>&2 fancy_title "Building libmpfr for $target_arch"
|
||||||
|
|
||||||
|
../configure --enable-static "--with-gmp-build=$libgmp_build_dir" \
|
||||||
|
"CC=$CC" "CXX=$CXX" "--host=$HOST" \
|
||||||
|
"CFLAGS=$CFLAGS" "CXXFLAGS=$CXXFLAGS" 1>&2
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
make -j$(nproc) 1>&2
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p ./src/.libs/include
|
||||||
|
cp ../src/mpfr.h ./src/.libs/include/
|
||||||
|
mkdir -p ./src/.libs/lib
|
||||||
|
cp ./src/.libs/libmpfr.a ./src/.libs/lib/
|
||||||
|
|
||||||
|
>&2 fancy_title "Finished building libmpfr for $target_arch"
|
||||||
|
|
||||||
|
popd > /dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
function build_gdb() {
|
||||||
|
# Configure and build gdb.
|
||||||
|
#
|
||||||
|
# Parameters:
|
||||||
|
# $1: gdb directory
|
||||||
|
# $2: target architecture
|
||||||
|
# $3: libiconv prefix
|
||||||
|
# $4: libgmp prefix
|
||||||
|
# $5: libmpfr prefix
|
||||||
|
#
|
||||||
|
# Echoes:
|
||||||
|
# The gdb build directory
|
||||||
|
#
|
||||||
|
# Returns:
|
||||||
|
# 0: success
|
||||||
|
# 1: failure
|
||||||
|
|
||||||
|
local gdb_dir="$1"
|
||||||
|
local target_arch="$2"
|
||||||
|
local libiconv_prefix="$3"
|
||||||
|
local libgmp_prefix="$4"
|
||||||
|
local libmpfr_prefix="$5"
|
||||||
|
local gdb_build_dir="$(realpath "$gdb_dir/build-$target_arch")"
|
||||||
|
|
||||||
|
echo "$gdb_build_dir"
|
||||||
|
mkdir -p "$gdb_build_dir"
|
||||||
|
|
||||||
|
if [[ -f "$gdb_build_dir/gdb/gdb" ]]; then
|
||||||
|
>&2 echo "Skipping build: gdb already built for $target_arch"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
pushd "$gdb_build_dir" > /dev/null
|
||||||
|
|
||||||
|
>&2 fancy_title "Building gdb for $target_arch"
|
||||||
|
|
||||||
|
../configure --enable-static --with-static-standard-libraries --disable-tui --disable-inprocess-agent \
|
||||||
|
"--with-libiconv-prefix=$libiconv_prefix" --with-libiconv-type=static \
|
||||||
|
"--with-gmp=$libgmp_prefix" \
|
||||||
|
"--with-mpfr=$libmpfr_prefix" \
|
||||||
|
"CC=$CC" "CXX=$CXX" "--host=$HOST" \
|
||||||
|
"CFLAGS=$CFLAGS" "CXXFLAGS=$CXXFLAGS" 1>&2
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
make -j$(nproc) 1>&2
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
>&2 fancy_title "Finished building gdb for $target_arch"
|
||||||
|
|
||||||
|
popd > /dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
function install_gdb() {
|
||||||
|
# Install gdb binaries to an artifacts directory.
|
||||||
|
#
|
||||||
|
# Parameters:
|
||||||
|
# $1: gdb build directory
|
||||||
|
# $2: artifacts directory
|
||||||
|
# $3: target architecture
|
||||||
|
#
|
||||||
|
# Returns:
|
||||||
|
# 0: success
|
||||||
|
# 1: failure
|
||||||
|
|
||||||
|
local gdb_build_dir="$1"
|
||||||
|
local artifacts_dir="$2"
|
||||||
|
local target_arch="$3"
|
||||||
|
|
||||||
|
if [[ -d "$artifacts_dir/$target_arch" && -n "$(ls -A "$artifacts_dir/$target_arch")" ]]; then
|
||||||
|
>&2 echo "Skipping install: gdb already installed for $target_arch"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
temp_artifacts_dir="$(mktemp -d)"
|
||||||
|
|
||||||
|
mkdir -p "$artifacts_dir/$target_arch"
|
||||||
|
|
||||||
|
make -C "$gdb_build_dir" install "DESTDIR=$temp_artifacts_dir" 1>&2
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
rm -rf "$temp_artifacts_dir"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
while read file; do
|
||||||
|
cp "$file" "$artifacts_dir/$target_arch/"
|
||||||
|
done < <(find "$temp_artifacts_dir/usr/local/bin" -type f -executable)
|
||||||
|
|
||||||
|
rm -rf "$temp_artifacts_dir"
|
||||||
|
}
|
||||||
|
|
||||||
|
function build_and_install_gdb() {
|
||||||
|
# Build gdb and install it to an artifacts directory.
|
||||||
|
#
|
||||||
|
# Parameters:
|
||||||
|
# $1: gdb package directory
|
||||||
|
# $2: libiconv prefix
|
||||||
|
# $3: libgmp prefix
|
||||||
|
# $4: libmpfr prefix
|
||||||
|
# $5: install directory
|
||||||
|
# $6: target architecture
|
||||||
|
#
|
||||||
|
# Returns:
|
||||||
|
# 0: success
|
||||||
|
# 1: failure
|
||||||
|
|
||||||
|
local gdb_dir="$1"
|
||||||
|
local libiconv_prefix="$2"
|
||||||
|
local libgmp_prefix="$3"
|
||||||
|
local libmpfr_prefix="$4"
|
||||||
|
local artifacts_dir="$5"
|
||||||
|
local target_arch="$6"
|
||||||
|
|
||||||
|
gdb_build_dir="$(build_gdb "$gdb_dir" "$target_arch" "$libiconv_prefix" "$libgmp_prefix" "$libmpfr_prefix")"
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
install_gdb "$gdb_build_dir" "$artifacts_dir" "$target_arch"
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function build_gdb_with_dependencies() {
|
||||||
|
# Build gdb for a specific target architecture.
|
||||||
|
#
|
||||||
|
# Parameters:
|
||||||
|
# $1: target architecture
|
||||||
|
# $2: build directory
|
||||||
|
|
||||||
|
local target_arch="$1"
|
||||||
|
local build_dir="$2"
|
||||||
|
local packages_dir="$build_dir/packages"
|
||||||
|
local artifacts_dir="$build_dir/artifacts"
|
||||||
|
|
||||||
|
set_compliation_variables "$target_arch"
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p "$packages_dir"
|
||||||
|
|
||||||
|
iconv_build_dir="$(build_iconv "$packages_dir/libiconv" "$target_arch")"
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
gmp_build_dir="$(build_libgmp "$packages_dir/gmp" "$target_arch")"
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
mpfr_build_dir="$(build_libmpfr "$packages_dir/mpfr" "$gmp_build_dir" "$target_arch")"
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
build_and_install_gdb "$packages_dir/gdb" \
|
||||||
|
"$iconv_build_dir/lib/.libs/" \
|
||||||
|
"$gmp_build_dir/.libs/" \
|
||||||
|
"$mpfr_build_dir/src/.libs/" \
|
||||||
|
"$artifacts_dir" \
|
||||||
|
"$target_arch"
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function main() {
|
||||||
|
if [[ $# -ne 3 ]]; then
|
||||||
|
>&2 echo "Usage: $0 <target_arch> <build_dir>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
build_gdb_with_dependencies "$1" "$2"
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
>&2 echo "Error: failed to build gdb with dependencies"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
@ -1,637 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Include utils library
|
|
||||||
script_dir=$(dirname "$0")
|
|
||||||
source "$script_dir/utils.sh"
|
|
||||||
|
|
||||||
# Don't want random unknown things to fail in the build procecss!
|
|
||||||
set -e
|
|
||||||
|
|
||||||
function set_compliation_variables() {
|
|
||||||
# Set compilation variables such as which compiler to use.
|
|
||||||
#
|
|
||||||
# Parameters:
|
|
||||||
# $1: target architecture
|
|
||||||
#
|
|
||||||
# Returns:
|
|
||||||
# 0: success
|
|
||||||
# 1: failure
|
|
||||||
supported_archs=("arm" "aarch64" "powerpc" "x86_64" "mips" "mipsel")
|
|
||||||
|
|
||||||
local target_arch="$1"
|
|
||||||
|
|
||||||
if [[ ! " ${supported_archs[@]} " =~ " ${target_arch} " ]]; then
|
|
||||||
>&2 echo "Error: unsupported target architecture: $target_arch"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
>&2 fancy_title "Setting compilation variables for $target_arch"
|
|
||||||
|
|
||||||
if [[ "$target_arch" == "arm" ]]; then
|
|
||||||
CROSS=arm-linux-gnueabi-
|
|
||||||
export HOST=arm-linux-gnueabi
|
|
||||||
elif [[ "$target_arch" == "aarch64" ]]; then
|
|
||||||
CROSS=aarch64-linux-gnu-
|
|
||||||
export HOST=aarch64-linux-gnu
|
|
||||||
elif [[ "$target_arch" == "powerpc" ]]; then
|
|
||||||
CROSS=powerpc-linux-gnu-
|
|
||||||
export HOST=powerpc-linux-gnu
|
|
||||||
elif [[ "$target_arch" == "mips" ]]; then
|
|
||||||
CROSS=mips-linux-gnu-
|
|
||||||
export HOST=mips-linux-gnu
|
|
||||||
elif [[ "$target_arch" == "mipsel" ]]; then
|
|
||||||
CROSS=mipsel-linux-gnu-
|
|
||||||
export HOST=mipsel-linux-gnu
|
|
||||||
elif [[ "$target_arch" == "x86_64" ]]; then
|
|
||||||
CROSS=x86_64-linux-gnu-
|
|
||||||
export HOST=x86_64-linux-gnu
|
|
||||||
fi
|
|
||||||
|
|
||||||
export CC="${CROSS}gcc"
|
|
||||||
export CXX="${CROSS}g++"
|
|
||||||
|
|
||||||
export CFLAGS="-O2"
|
|
||||||
export CXXFLAGS="-O2"
|
|
||||||
|
|
||||||
# Strip the binary to reduce it's size.
|
|
||||||
export LDFLAGS="-s"
|
|
||||||
}
|
|
||||||
|
|
||||||
function set_up_lib_search_paths() {
|
|
||||||
# Set up library-related linker search paths.
|
|
||||||
#
|
|
||||||
# Parameters:
|
|
||||||
# $1: ncursesw build dir
|
|
||||||
# $2: libexpat build dir
|
|
||||||
local ncursesw_build_dir="$1"
|
|
||||||
local libexpat_build_dir="$2"
|
|
||||||
|
|
||||||
# I) Allow tui mode by adding our custom built static ncursesw library to the linker search path.
|
|
||||||
# II) Allow parsing xml files by adding libexpat library to the linker search path.
|
|
||||||
export LDFLAGS="-L$ncursesw_build_dir/lib -L$libexpat_build_dir/lib/.libs $LDFLAGS"
|
|
||||||
}
|
|
||||||
|
|
||||||
function build_iconv() {
|
|
||||||
# Build libiconv.
|
|
||||||
#
|
|
||||||
# Parameters:
|
|
||||||
# $1: iconv package directory
|
|
||||||
# $2: target architecture
|
|
||||||
#
|
|
||||||
# Echoes:
|
|
||||||
# The libiconv build directory
|
|
||||||
#
|
|
||||||
# Returns:
|
|
||||||
# 0: success
|
|
||||||
# 1: failure
|
|
||||||
|
|
||||||
local iconv_dir="$1"
|
|
||||||
local target_arch="$2"
|
|
||||||
local iconv_build_dir="$(realpath "$iconv_dir/build-$target_arch")"
|
|
||||||
|
|
||||||
echo "$iconv_build_dir"
|
|
||||||
mkdir -p "$iconv_build_dir"
|
|
||||||
|
|
||||||
if [[ -f "$iconv_build_dir/lib/.libs/libiconv.a" ]]; then
|
|
||||||
>&2 echo "Skipping build: iconv already built for $target_arch"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
pushd "$iconv_build_dir" > /dev/null
|
|
||||||
|
|
||||||
>&2 fancy_title "Building libiconv for $target_arch"
|
|
||||||
|
|
||||||
../configure --enable-static "CC=$CC" "CXX=$CXX" "--host=$HOST" \
|
|
||||||
"CFLAGS=$CFLAGS" "CXXFLAGS=$CXXFLAGS" 1>&2
|
|
||||||
if [[ $? -ne 0 ]]; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
make -j$(nproc) 1>&2
|
|
||||||
if [[ $? -ne 0 ]]; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
cp -r ./include ./lib/.libs/
|
|
||||||
mkdir -p ./lib/.libs/lib/
|
|
||||||
cp ./lib/.libs/libiconv.a ./lib/.libs/lib/
|
|
||||||
|
|
||||||
>&2 fancy_title "Finished building libiconv for $target_arch"
|
|
||||||
|
|
||||||
popd > /dev/null
|
|
||||||
}
|
|
||||||
|
|
||||||
function build_libgmp() {
|
|
||||||
# Build libgmp.
|
|
||||||
#
|
|
||||||
# Parameters:
|
|
||||||
# $1: libgmp package directory
|
|
||||||
# $2: target architecture
|
|
||||||
#
|
|
||||||
# Echoes:
|
|
||||||
# The libgmp build directory
|
|
||||||
#
|
|
||||||
# Returns:
|
|
||||||
# 0: success
|
|
||||||
# 1: failure
|
|
||||||
|
|
||||||
local gmp_dir="$1"
|
|
||||||
local target_arch="$2"
|
|
||||||
local gmp_build_dir="$(realpath "$gmp_dir/build-$target_arch")"
|
|
||||||
|
|
||||||
echo "$gmp_build_dir"
|
|
||||||
mkdir -p "$gmp_build_dir"
|
|
||||||
|
|
||||||
if [[ -f "$gmp_build_dir/.libs/lib/libgmp.a" ]]; then
|
|
||||||
>&2 echo "Skipping build: libgmp already built for $target_arch"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
pushd "$gmp_build_dir" > /dev/null
|
|
||||||
|
|
||||||
>&2 fancy_title "Building libgmp for $target_arch"
|
|
||||||
|
|
||||||
../configure --enable-static "CC=$CC" "CXX=$CXX" "--host=$HOST" \
|
|
||||||
"CFLAGS=$CFLAGS" "CXXFLAGS=$CXXFLAGS" 1>&2
|
|
||||||
if [[ $? -ne 0 ]]; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
make -j$(nproc) 1>&2
|
|
||||||
if [[ $? -ne 0 ]]; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir -p ./.libs/include/
|
|
||||||
cp gmp.h ./.libs/include/
|
|
||||||
mkdir -p ./.libs/lib/
|
|
||||||
cp ./.libs/libgmp.a ./.libs/lib/
|
|
||||||
|
|
||||||
>&2 fancy_title "Finished building libgmp for $target_arch"
|
|
||||||
|
|
||||||
popd > /dev/null
|
|
||||||
}
|
|
||||||
|
|
||||||
function build_ncurses() {
|
|
||||||
# Build libncursesw.
|
|
||||||
#
|
|
||||||
# Parameters:
|
|
||||||
# $1: libncursesw package directory
|
|
||||||
# $2: target architecture
|
|
||||||
#
|
|
||||||
# Echoes:
|
|
||||||
# The libncursesw build directory
|
|
||||||
#
|
|
||||||
# Returns:
|
|
||||||
# 0: success
|
|
||||||
# 1: failure
|
|
||||||
local ncurses_dir="$1"
|
|
||||||
local target_arch="$2"
|
|
||||||
local ncurses_build_dir="$(realpath "$ncurses_dir/build-$target_arch")"
|
|
||||||
|
|
||||||
echo "$ncurses_build_dir"
|
|
||||||
mkdir -p "$ncurses_build_dir"
|
|
||||||
|
|
||||||
if [[ -f "$ncurses_build_dir/lib/libncursesw.a" ]]; then
|
|
||||||
>&2 echo "Skipping build: libncursesw already built for $target_arch"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
pushd "$ncurses_build_dir" > /dev/null
|
|
||||||
|
|
||||||
>&2 fancy_title "Building libncursesw for $target_arch"
|
|
||||||
|
|
||||||
../configure --enable-static "CC=$CC" "CXX=$CXX" "--host=$HOST" \
|
|
||||||
"CFLAGS=$CFLAGS" "CXXFLAGS=$CXXFLAGS" "--enable-widec" 1>&2
|
|
||||||
if [[ $? -ne 0 ]]; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
make -j$(nproc) 1>&2
|
|
||||||
if [[ $? -ne 0 ]]; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
>&2 fancy_title "Finished building libncursesw for $target_arch"
|
|
||||||
|
|
||||||
popd > /dev/null
|
|
||||||
}
|
|
||||||
|
|
||||||
function build_libexpat() {
|
|
||||||
# Build libexpat.
|
|
||||||
#
|
|
||||||
# Parameters:
|
|
||||||
# $1: libexpat package directory
|
|
||||||
# $2: target architecture
|
|
||||||
#
|
|
||||||
# Echoes:
|
|
||||||
# The libexpat build directory
|
|
||||||
#
|
|
||||||
# Returns:
|
|
||||||
# 0: success
|
|
||||||
# 1: failure
|
|
||||||
local libexpat_dir="$1"
|
|
||||||
local target_arch="$2"
|
|
||||||
local libexpat_build_dir="$(realpath "$libexpat_dir/build-$target_arch")"
|
|
||||||
|
|
||||||
echo "$libexpat_build_dir"
|
|
||||||
mkdir -p "$libexpat_build_dir"
|
|
||||||
|
|
||||||
if [[ -f "$libexpat_build_dir/lib/.libs/libexpat.a" ]]; then
|
|
||||||
>&2 echo "Skipping build: libexpat already built for $target_arch"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
pushd "$libexpat_build_dir" > /dev/null
|
|
||||||
|
|
||||||
>&2 fancy_title "Building libexpat for $target_arch"
|
|
||||||
|
|
||||||
# Generate configure if it doesnt exist.
|
|
||||||
if [[ ! -f "$libexpat_build_dir/../expat/configure" ]]; then
|
|
||||||
>&2 ../expat/buildconf.sh ../expat/
|
|
||||||
fi
|
|
||||||
|
|
||||||
../expat/configure --enable-static "CC=$CC" "CXX=$CXX" "--host=$HOST" \
|
|
||||||
"CFLAGS=$CFLAGS" "CXXFLAGS=$CXXFLAGS" 1>&2
|
|
||||||
if [[ $? -ne 0 ]]; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
make -j$(nproc) 1>&2
|
|
||||||
if [[ $? -ne 0 ]]; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
>&2 fancy_title "Finished building libexpat for $target_arch"
|
|
||||||
|
|
||||||
popd > /dev/null
|
|
||||||
}
|
|
||||||
|
|
||||||
function build_python() {
|
|
||||||
# Build python.
|
|
||||||
#
|
|
||||||
# Parameters:
|
|
||||||
# $1: python package directory
|
|
||||||
# $2: target architecture
|
|
||||||
# $3: gdb's python module directory parent
|
|
||||||
# $4: pygment's toplevel source dir.
|
|
||||||
#
|
|
||||||
# Echoes:
|
|
||||||
# The python build directory
|
|
||||||
#
|
|
||||||
# Returns:
|
|
||||||
# 0: success
|
|
||||||
# 1: failure
|
|
||||||
local python_dir="$1"
|
|
||||||
local target_arch="$2"
|
|
||||||
local gdb_python_parent="$3"
|
|
||||||
local pygments_source_dir="$4"
|
|
||||||
local python_lib_dir="$(realpath "$python_dir/build-$target_arch")"
|
|
||||||
|
|
||||||
echo "$python_lib_dir"
|
|
||||||
mkdir -p "$python_lib_dir"
|
|
||||||
|
|
||||||
# Having a python-config file is an indication that we successfully built python.
|
|
||||||
if [[ -f "$python_lib_dir/python-config" ]]; then
|
|
||||||
>&2 echo "Skipping build: libpython already built for $target_arch"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
pushd "$python_lib_dir" > /dev/null
|
|
||||||
>&2 fancy_title "Building python for $target_arch"
|
|
||||||
|
|
||||||
export LINKFORSHARED=" "
|
|
||||||
export MODULE_BUILDTYPE="static"
|
|
||||||
export CONFIG_SITE="$python_dir/config.site-static"
|
|
||||||
>&2 CFLAGS="-static" LDFLAGS="-static" ../configure \
|
|
||||||
--prefix=$(realpath .) \
|
|
||||||
--disable-test-modules \
|
|
||||||
--with-ensurepip=no \
|
|
||||||
--without-decimal-contextvar \
|
|
||||||
--build=x86_64-pc-linux-gnu \
|
|
||||||
--host=$HOST \
|
|
||||||
--with-build-python=/usr/bin/python3.12 \
|
|
||||||
--disable-ipv6 \
|
|
||||||
--disable-shared
|
|
||||||
|
|
||||||
# Extract the regular standard library modules that are to be frozen and include the gdb and pygments custom libraries.
|
|
||||||
export EXTRA_FROZEN_MODULES="$(printf "%s" "$(< ${script_dir}/frozen_python_modules.txt)" | tr $'\n' ";")"
|
|
||||||
export EXTRA_FROZEN_MODULES="${EXTRA_FROZEN_MODULES};<gdb.**.*>: gdb = ${gdb_python_parent};<pygments.**.*>: pygments = ${pygments_source_dir}"
|
|
||||||
>&2 echo "Frozen Modules: ${EXTRA_FROZEN_MODULES}"
|
|
||||||
|
|
||||||
# Regenerate frozen modules with gdb env varaible. Do it after the configure because we need
|
|
||||||
# the `regen-frozen` makefile.
|
|
||||||
>&2 python3.12 ../Tools/build/freeze_modules.py
|
|
||||||
>&2 make regen-frozen
|
|
||||||
|
|
||||||
# Build python after configuring the project and regnerating frozen files.
|
|
||||||
>&2 make -j $(nproc)
|
|
||||||
if [[ $? -ne 0 ]]; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Install python (in build dir using the prefix set above), in order to have a bash (for cross-compilation) python3-config that works.
|
|
||||||
>&2 make install
|
|
||||||
if [[ $? -ne 0 ]]; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
>&2 fancy_title "Finished building python for $target_arch"
|
|
||||||
popd > /dev/null
|
|
||||||
}
|
|
||||||
|
|
||||||
function build_libmpfr() {
|
|
||||||
# Build libmpfr.
|
|
||||||
#
|
|
||||||
# Parameters:
|
|
||||||
# $1: mpfr package directory
|
|
||||||
# $2: libgmp build directory
|
|
||||||
# $3: target architecture
|
|
||||||
#
|
|
||||||
# Echoes:
|
|
||||||
# The libmpfr build directory
|
|
||||||
#
|
|
||||||
# Returns:
|
|
||||||
# 0: success
|
|
||||||
# 1: failure
|
|
||||||
|
|
||||||
local mpfr_dir="$1"
|
|
||||||
local libgmp_build_dir="$2"
|
|
||||||
local target_arch="$3"
|
|
||||||
local mpfr_build_dir="$(realpath "$mpfr_dir/build-$target_arch")"
|
|
||||||
|
|
||||||
mkdir -p "$mpfr_build_dir"
|
|
||||||
echo "$mpfr_build_dir"
|
|
||||||
|
|
||||||
if [[ -f "$mpfr_build_dir/src/.libs/lib/libmpfr.a" ]]; then
|
|
||||||
>&2 echo "Skipping build: libmpfr already built for $target_arch"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
pushd "$mpfr_dir/build-$target_arch" > /dev/null
|
|
||||||
|
|
||||||
>&2 fancy_title "Building libmpfr for $target_arch"
|
|
||||||
|
|
||||||
../configure --enable-static "--with-gmp-build=$libgmp_build_dir" \
|
|
||||||
"CC=$CC" "CXX=$CXX" "--host=$HOST" \
|
|
||||||
"CFLAGS=$CFLAGS" "CXXFLAGS=$CXXFLAGS" 1>&2
|
|
||||||
if [[ $? -ne 0 ]]; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
make -j$(nproc) 1>&2
|
|
||||||
if [[ $? -ne 0 ]]; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir -p ./src/.libs/include
|
|
||||||
cp ../src/mpfr.h ./src/.libs/include/
|
|
||||||
mkdir -p ./src/.libs/lib
|
|
||||||
cp ./src/.libs/libmpfr.a ./src/.libs/lib/
|
|
||||||
|
|
||||||
>&2 fancy_title "Finished building libmpfr for $target_arch"
|
|
||||||
|
|
||||||
popd > /dev/null
|
|
||||||
}
|
|
||||||
|
|
||||||
function build_gdb() {
|
|
||||||
# Configure and build gdb.
|
|
||||||
#
|
|
||||||
# Parameters:
|
|
||||||
# $1: gdb directory
|
|
||||||
# $2: target architecture
|
|
||||||
# $3: libiconv prefix
|
|
||||||
# $4: libgmp prefix
|
|
||||||
# $5: libmpfr prefix
|
|
||||||
# $6: whether to build with python or not
|
|
||||||
#
|
|
||||||
# Echoes:
|
|
||||||
# The gdb build directory
|
|
||||||
#
|
|
||||||
# Returns:
|
|
||||||
# 0: success
|
|
||||||
# 1: failure
|
|
||||||
|
|
||||||
local gdb_dir="$1"
|
|
||||||
local target_arch="$2"
|
|
||||||
local libiconv_prefix="$3"
|
|
||||||
local libgmp_prefix="$4"
|
|
||||||
local libmpfr_prefix="$5"
|
|
||||||
local with_python="$6"
|
|
||||||
|
|
||||||
if [[ "$with_python" == "yes" ]]; then
|
|
||||||
local python_flag="--with-python=/app/gdb/build/packages/cpython-static/build-$target_arch/bin/python3-config"
|
|
||||||
local gdb_build_dir="$(realpath "$gdb_dir/build-${target_arch}_with_python")"
|
|
||||||
else
|
|
||||||
local python_flag="--without-python"
|
|
||||||
local gdb_build_dir="$(realpath "$gdb_dir/build-${target_arch}")"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "$gdb_build_dir"
|
|
||||||
mkdir -p "$gdb_build_dir"
|
|
||||||
|
|
||||||
if [[ -f "$gdb_build_dir/gdb/gdb" ]]; then
|
|
||||||
>&2 echo "Skipping build: gdb already built for $target_arch"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
pushd "$gdb_build_dir" > /dev/null
|
|
||||||
|
|
||||||
>&2 fancy_title "Building gdb for $target_arch"
|
|
||||||
|
|
||||||
../configure -C --enable-static --with-static-standard-libraries --disable-inprocess-agent \
|
|
||||||
--enable-tui "$python_flag" \
|
|
||||||
--with-expat --with-libexpat-type="static" \
|
|
||||||
--with-gdb-datadir="/usr/share/gdb" --with-separate-debug-dir="/usr/lib/debug" \
|
|
||||||
--with-system-gdbinit="/etc/gdb/gdbinit" --with-system-gdbinit-dir="/etc/gdb/gdbinit.d" \
|
|
||||||
--with-jit-reader-dir="/usr/lib/gdb" \
|
|
||||||
"--with-libiconv-prefix=$libiconv_prefix" --with-libiconv-type=static \
|
|
||||||
"--with-gmp=$libgmp_prefix" \
|
|
||||||
"--with-mpfr=$libmpfr_prefix" \
|
|
||||||
"CC=$CC" "CXX=$CXX" "LDFLAGS=$LDFLAGS" "--host=$HOST" \
|
|
||||||
"CFLAGS=$CFLAGS" "CXXFLAGS=$CXXFLAGS" 1>&2
|
|
||||||
if [[ $? -ne 0 ]]; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
make -j$(nproc) 1>&2
|
|
||||||
if [[ $? -ne 0 ]]; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
>&2 fancy_title "Finished building gdb for $target_arch"
|
|
||||||
|
|
||||||
popd > /dev/null
|
|
||||||
}
|
|
||||||
|
|
||||||
function install_gdb() {
|
|
||||||
# Install gdb binaries to an artifacts directory.
|
|
||||||
#
|
|
||||||
# Parameters:
|
|
||||||
# $1: gdb build directory
|
|
||||||
# $2: artifacts directory
|
|
||||||
# $3: target architecture
|
|
||||||
# $4: whether gdb was built with or without python
|
|
||||||
#
|
|
||||||
# Returns:
|
|
||||||
# 0: success
|
|
||||||
# 1: failure
|
|
||||||
|
|
||||||
local gdb_build_dir="$1"
|
|
||||||
local artifacts_dir="$2"
|
|
||||||
local target_arch="$3"
|
|
||||||
local with_python="$4"
|
|
||||||
|
|
||||||
if [[ "$with_python" == "yes" ]]; then
|
|
||||||
local artifacts_location="$artifacts_dir/${target_arch}_with_python"
|
|
||||||
else
|
|
||||||
local artifacts_location="$artifacts_dir/${target_arch}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -d "$artifacts_location" && -n "$(ls -A "$artifacts_location")" ]]; then
|
|
||||||
>&2 echo "Skipping install: gdb already installed for $target_arch"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
temp_artifacts_dir="$(mktemp -d)"
|
|
||||||
|
|
||||||
mkdir -p "$artifacts_location"
|
|
||||||
|
|
||||||
make -C "$gdb_build_dir" install "DESTDIR=$temp_artifacts_dir" 1>&2
|
|
||||||
if [[ $? -ne 0 ]]; then
|
|
||||||
rm -rf "$temp_artifacts_dir"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
while read file; do
|
|
||||||
cp "$file" "$artifacts_location/"
|
|
||||||
done < <(find "$temp_artifacts_dir/usr/local/bin" -type f -executable)
|
|
||||||
|
|
||||||
rm -rf "$temp_artifacts_dir"
|
|
||||||
}
|
|
||||||
|
|
||||||
function build_and_install_gdb() {
|
|
||||||
# Build gdb and install it to an artifacts directory.
|
|
||||||
#
|
|
||||||
# Parameters:
|
|
||||||
# $1: gdb package directory
|
|
||||||
# $2: libiconv prefix
|
|
||||||
# $3: libgmp prefix
|
|
||||||
# $4: libmpfr prefix
|
|
||||||
# $5: whether to build with python or not
|
|
||||||
# $6: install directory
|
|
||||||
# $7: target architecture
|
|
||||||
#
|
|
||||||
# Returns:
|
|
||||||
# 0: success
|
|
||||||
# 1: failure
|
|
||||||
|
|
||||||
local gdb_dir="$1"
|
|
||||||
local libiconv_prefix="$2"
|
|
||||||
local libgmp_prefix="$3"
|
|
||||||
local libmpfr_prefix="$4"
|
|
||||||
local with_python="$5"
|
|
||||||
local artifacts_dir="$6"
|
|
||||||
local target_arch="$7"
|
|
||||||
|
|
||||||
gdb_build_dir="$(build_gdb "$gdb_dir" "$target_arch" "$libiconv_prefix" "$libgmp_prefix" "$libmpfr_prefix" "$with_python")"
|
|
||||||
if [[ $? -ne 0 ]]; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
install_gdb "$gdb_build_dir" "$artifacts_dir" "$target_arch" "$with_python"
|
|
||||||
if [[ $? -ne 0 ]]; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function build_gdb_with_dependencies() {
|
|
||||||
# Build gdb for a specific target architecture.
|
|
||||||
#
|
|
||||||
# Parameters:
|
|
||||||
# $1: target architecture
|
|
||||||
# $2: build directory
|
|
||||||
# $3: src directory
|
|
||||||
# $4: whether to build gdb with python or not
|
|
||||||
|
|
||||||
local target_arch="$1"
|
|
||||||
local build_dir="$2"
|
|
||||||
local source_dir="$3"
|
|
||||||
local with_python="$4"
|
|
||||||
local packages_dir="$build_dir/packages"
|
|
||||||
local artifacts_dir="$build_dir/artifacts"
|
|
||||||
|
|
||||||
set_compliation_variables "$target_arch"
|
|
||||||
if [[ $? -ne 0 ]]; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir -p "$packages_dir"
|
|
||||||
|
|
||||||
iconv_build_dir="$(build_iconv "$packages_dir/libiconv" "$target_arch")"
|
|
||||||
if [[ $? -ne 0 ]]; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
gmp_build_dir="$(build_libgmp "$packages_dir/gmp" "$target_arch")"
|
|
||||||
if [[ $? -ne 0 ]]; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
mpfr_build_dir="$(build_libmpfr "$packages_dir/mpfr" "$gmp_build_dir" "$target_arch")"
|
|
||||||
if [[ $? -ne 0 ]]; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
ncursesw_build_dir="$(build_ncurses "$packages_dir/ncurses" "$target_arch")"
|
|
||||||
if [[ $? -ne 0 ]]; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
libexpat_build_dir="$(build_libexpat "$packages_dir/libexpat" "$target_arch")"
|
|
||||||
if [[ $? -ne 0 ]]; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
set_up_lib_search_paths "$ncursesw_build_dir" "$libexpat_build_dir"
|
|
||||||
|
|
||||||
if [[ "$with_python" == "yes" ]]; then
|
|
||||||
local gdb_python_dir="$packages_dir/binutils-gdb/gdb/python/lib/"
|
|
||||||
local pygments_source_dir="$packages_dir/pygments/"
|
|
||||||
local python_build_dir="$(build_python "$packages_dir/cpython-static" "$target_arch" "$gdb_python_dir" "$pygments_source_dir")"
|
|
||||||
if [[ $? -ne 0 ]]; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
build_and_install_gdb "$packages_dir/binutils-gdb" \
|
|
||||||
"$iconv_build_dir/lib/.libs/" \
|
|
||||||
"$gmp_build_dir/.libs/" \
|
|
||||||
"$mpfr_build_dir/src/.libs/" \
|
|
||||||
"$with_python" \
|
|
||||||
"$artifacts_dir" \
|
|
||||||
"$target_arch"
|
|
||||||
if [[ $? -ne 0 ]]; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function main() {
|
|
||||||
if [[ $# -lt 3 ]]; then
|
|
||||||
>&2 echo "Usage: $0 <target_arch> <build_dir> <src_dir> [--with-python]"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
local with_python="no"
|
|
||||||
if [[ "$4" == "--with-python" ]]; then
|
|
||||||
with_python="yes"
|
|
||||||
fi
|
|
||||||
|
|
||||||
build_gdb_with_dependencies "$1" "$2" "$3" "$with_python"
|
|
||||||
if [[ $? -ne 0 ]]; then
|
|
||||||
>&2 echo "Error: failed to build gdb with dependencies"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
main "$@"
|
|
@ -1,147 +0,0 @@
|
|||||||
_aix_support
|
|
||||||
antigravity
|
|
||||||
argparse
|
|
||||||
ast
|
|
||||||
base64
|
|
||||||
bdb
|
|
||||||
bisect
|
|
||||||
calendar
|
|
||||||
cmd
|
|
||||||
codeop
|
|
||||||
code
|
|
||||||
<collections.**.*>
|
|
||||||
_collections_abc
|
|
||||||
colorsys
|
|
||||||
_compat_pickle
|
|
||||||
compileall
|
|
||||||
_compression
|
|
||||||
<concurrent.**.*>
|
|
||||||
configparser
|
|
||||||
contextlib
|
|
||||||
contextvars
|
|
||||||
copy
|
|
||||||
copyreg
|
|
||||||
cProfile
|
|
||||||
csv
|
|
||||||
dataclasses
|
|
||||||
datetime
|
|
||||||
<dbm.**.*>
|
|
||||||
decimal
|
|
||||||
difflib
|
|
||||||
dis
|
|
||||||
<encodings.**.*>
|
|
||||||
<ensurepip.**.*>
|
|
||||||
enum
|
|
||||||
filecmp
|
|
||||||
fileinput
|
|
||||||
fnmatch
|
|
||||||
fractions
|
|
||||||
ftplib
|
|
||||||
functools
|
|
||||||
__future__
|
|
||||||
genericpath
|
|
||||||
getopt
|
|
||||||
getpass
|
|
||||||
gettext
|
|
||||||
glob
|
|
||||||
graphlib
|
|
||||||
gzip
|
|
||||||
hashlib
|
|
||||||
heapq
|
|
||||||
hmac
|
|
||||||
imaplib
|
|
||||||
<importlib.**.*>
|
|
||||||
inspect
|
|
||||||
ipaddress
|
|
||||||
<json.**.*>
|
|
||||||
keyword
|
|
||||||
linecache
|
|
||||||
locale
|
|
||||||
<logging.**.*>
|
|
||||||
lzma
|
|
||||||
_markupbase
|
|
||||||
mimetypes
|
|
||||||
modulefinder
|
|
||||||
<multiprocessing.**.*>
|
|
||||||
netrc
|
|
||||||
ntpath
|
|
||||||
nturl2path
|
|
||||||
numbers
|
|
||||||
opcode
|
|
||||||
operator
|
|
||||||
optparse
|
|
||||||
os
|
|
||||||
_osx_support
|
|
||||||
pathlib
|
|
||||||
pdb
|
|
||||||
<__phello__.**.*>
|
|
||||||
pickle
|
|
||||||
pickletools
|
|
||||||
pkgutil
|
|
||||||
platform
|
|
||||||
plistlib
|
|
||||||
poplib
|
|
||||||
posixpath
|
|
||||||
pprint
|
|
||||||
profile
|
|
||||||
pstats
|
|
||||||
pty
|
|
||||||
_py_abc
|
|
||||||
pyclbr
|
|
||||||
py_compile
|
|
||||||
_pydatetime
|
|
||||||
_pydecimal
|
|
||||||
_pyio
|
|
||||||
_pylong
|
|
||||||
queue
|
|
||||||
quopri
|
|
||||||
random
|
|
||||||
<re.**.*>
|
|
||||||
reprlib
|
|
||||||
rlcompleter
|
|
||||||
sched
|
|
||||||
selectors
|
|
||||||
shelve
|
|
||||||
shlex
|
|
||||||
shutil
|
|
||||||
signal
|
|
||||||
smtplib
|
|
||||||
socket
|
|
||||||
socketserver
|
|
||||||
statistics
|
|
||||||
stat
|
|
||||||
stringprep
|
|
||||||
string
|
|
||||||
_strptime
|
|
||||||
struct
|
|
||||||
subprocess
|
|
||||||
symtable
|
|
||||||
sysconfig
|
|
||||||
tabnanny
|
|
||||||
tempfile
|
|
||||||
textwrap
|
|
||||||
this
|
|
||||||
_threading_local
|
|
||||||
threading
|
|
||||||
timeit
|
|
||||||
tokenize
|
|
||||||
token
|
|
||||||
<tomllib.**.*>
|
|
||||||
traceback
|
|
||||||
tracemalloc
|
|
||||||
trace
|
|
||||||
tty
|
|
||||||
types
|
|
||||||
typing
|
|
||||||
uuid
|
|
||||||
warnings
|
|
||||||
wave
|
|
||||||
weakref
|
|
||||||
_weakrefset
|
|
||||||
webbrowser
|
|
||||||
<wsgiref.**.*>
|
|
||||||
zipapp
|
|
||||||
<zipfile.**.*>
|
|
||||||
<zoneinfo.**.*>
|
|
||||||
<email.**.*>
|
|
||||||
<urllib.**.*>
|
|
@ -2,14 +2,14 @@
|
|||||||
|
|
||||||
# Include utils library
|
# Include utils library
|
||||||
script_dir=$(dirname "$0")
|
script_dir=$(dirname "$0")
|
||||||
source "$script_dir/utils.sh"
|
. "$script_dir/utils.sh"
|
||||||
|
|
||||||
# List of package URLs to download
|
# List of package URLs to download
|
||||||
SOURCE_URLS=(
|
PACKAGE_URLS=(
|
||||||
"https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.17.tar.gz"
|
"https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.17.tar.gz"
|
||||||
"https://ftp.gnu.org/pub/gnu/gmp/gmp-6.3.0.tar.xz"
|
"https://ftp.gnu.org/pub/gnu/gmp/gmp-6.3.0.tar.xz"
|
||||||
"https://ftp.gnu.org/pub/gnu/mpfr/mpfr-4.2.1.tar.xz"
|
"https://ftp.gnu.org/pub/gnu/mpfr/mpfr-4.2.1.tar.xz"
|
||||||
"https://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.5.tar.gz"
|
"https://ftp.gnu.org/gnu/gdb/gdb-15.2.tar.xz"
|
||||||
)
|
)
|
||||||
|
|
||||||
function unpack_tarball() {
|
function unpack_tarball() {
|
||||||
@ -64,6 +64,11 @@ function download_package() {
|
|||||||
local url="$1"
|
local url="$1"
|
||||||
local output="$2"
|
local output="$2"
|
||||||
|
|
||||||
|
if [[ -f "$output" ]]; then
|
||||||
|
>&2 echo "Skipping download: $output already exists"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
wget "$url" -O "$output"
|
wget "$url" -O "$output"
|
||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
>&2 echo "Error: failed to download $url"
|
>&2 echo "Error: failed to download $url"
|
||||||
@ -93,6 +98,11 @@ function extract_package() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ -d "$output_dir" ]]; then
|
||||||
|
>&2 echo "Skipping extraction: $output_dir already exists"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
pushd "$temp_dir" > /dev/null
|
pushd "$temp_dir" > /dev/null
|
||||||
|
|
||||||
unpack_tarball "$tarball_realpath"
|
unpack_tarball "$tarball_realpath"
|
||||||
@ -103,10 +113,6 @@ function extract_package() {
|
|||||||
|
|
||||||
popd > /dev/null
|
popd > /dev/null
|
||||||
|
|
||||||
# Make sure output dir is empty, so we could move content into it.
|
|
||||||
# The directory might not exist, so we need to pass || true so that set -e won't fail us.
|
|
||||||
rm -rf "$output_dir" || true
|
|
||||||
|
|
||||||
mv "$temp_dir/$package_dir" "$output_dir"
|
mv "$temp_dir/$package_dir" "$output_dir"
|
||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
return 1
|
return 1
|
||||||
@ -181,7 +187,7 @@ function download_gdb_packages() {
|
|||||||
|
|
||||||
fancy_title "Starting download of GDB packages"
|
fancy_title "Starting download of GDB packages"
|
||||||
|
|
||||||
for url in "${SOURCE_URLS[@]}"; do
|
for url in "${PACKAGE_URLS[@]}"; do
|
||||||
package_dir=$(package_url_to_dir "$url")
|
package_dir=$(package_url_to_dir "$url")
|
||||||
download_and_extract_package "$url" "$package_dir" &
|
download_and_extract_package "$url" "$package_dir" &
|
||||||
download_pids+=($!)
|
download_pids+=($!)
|
||||||
@ -196,6 +202,7 @@ function download_gdb_packages() {
|
|||||||
done
|
done
|
||||||
|
|
||||||
fancy_title "Finished downloading GDB packages"
|
fancy_title "Finished downloading GDB packages"
|
||||||
|
|
||||||
popd
|
popd
|
||||||
}
|
}
|
||||||
|
|
70
src/gdb_static.patch
Normal file
70
src/gdb_static.patch
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
diff --git a/Makefile.in b/Makefile.in
|
||||||
|
index f12c251f9c8..eed512b2d18 100644
|
||||||
|
--- a/Makefile.in
|
||||||
|
+++ b/Makefile.in
|
||||||
|
@@ -31593,7 +31593,7 @@ configure-readline:
|
||||||
|
$$s/$$module_srcdir/configure \
|
||||||
|
--srcdir=$${topdir}/$$module_srcdir \
|
||||||
|
$(HOST_CONFIGARGS) --build=${build_alias} --host=${host_alias} \
|
||||||
|
- --target=${target_alias} \
|
||||||
|
+ --target=${target_alias} --enable-static \
|
||||||
|
|| exit 1
|
||||||
|
@endif readline
|
||||||
|
|
||||||
|
@@ -40793,7 +40793,7 @@ configure-libcc1:
|
||||||
|
$$s/$$module_srcdir/configure \
|
||||||
|
--srcdir=$${topdir}/$$module_srcdir \
|
||||||
|
$(HOST_CONFIGARGS) --build=${build_alias} --host=${host_alias} \
|
||||||
|
- --target=${target_alias} --enable-shared \
|
||||||
|
+ --target=${target_alias} --enable-static --disable-shared \
|
||||||
|
|| exit 1
|
||||||
|
@endif libcc1
|
||||||
|
|
||||||
|
diff --git a/configure b/configure
|
||||||
|
index 6466b97f3ec..2ab23dcb81e 100755
|
||||||
|
--- a/configure
|
||||||
|
+++ b/configure
|
||||||
|
@@ -9398,7 +9398,7 @@ case " $configdirs " in
|
||||||
|
*" lto-plugin "* | *" libcc1 "* | *" gdbserver "*)
|
||||||
|
# When these are to be built as shared libraries, the same applies to
|
||||||
|
# libiberty.
|
||||||
|
- extra_host_libiberty_configure_flags=--enable-shared
|
||||||
|
+ extra_host_libiberty_configure_flags="--enable-static --disable-shared"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
|
||||||
|
index 84bc54b303e..c81269ced78 100644
|
||||||
|
--- a/gdb/Makefile.in
|
||||||
|
+++ b/gdb/Makefile.in
|
||||||
|
@@ -148,7 +148,7 @@ LIBTOOL = @LIBTOOL@
|
||||||
|
# Set this up with gcc if you have gnu ld and the loader will print out
|
||||||
|
# line numbers for undefined references.
|
||||||
|
#CC_LD = g++ -static
|
||||||
|
-CC_LD = $(LIBTOOL) $(SILENT_FLAG) --mode=link $(CXX) $(CXX_DIALECT)
|
||||||
|
+CC_LD = $(LIBTOOL) $(SILENT_FLAG) --mode=link $(CXX) -all-static $(CXX_DIALECT)
|
||||||
|
|
||||||
|
# Where is our "include" directory? Typically $(srcdir)/../include.
|
||||||
|
# This is essentially the header file directory for the library
|
||||||
|
diff --git a/gdbserver/Makefile.in b/gdbserver/Makefile.in
|
||||||
|
index 6148ccf9121..2a9c9720d1a 100644
|
||||||
|
--- a/gdbserver/Makefile.in
|
||||||
|
+++ b/gdbserver/Makefile.in
|
||||||
|
@@ -83,7 +83,7 @@ COMPILE = $(ECHO_CXX) $(COMPILE.pre) $(INTERNAL_CFLAGS) $(INCLUDE_SERVER_H) \
|
||||||
|
# Set this up with gcc if you have gnu ld and the loader will print out
|
||||||
|
# line numbers for undefinded refs.
|
||||||
|
#CC_LD = g++ -static
|
||||||
|
-CC_LD = $(CXX) $(CXX_DIALECT)
|
||||||
|
+CC_LD = $(CXX) -static $(CXX_DIALECT)
|
||||||
|
|
||||||
|
# Where is the "include" directory? Traditionally ../include or ./include
|
||||||
|
INCLUDE_DIR = ${srcdir}/../include
|
||||||
|
@@ -405,7 +405,7 @@ IPA_LIB = libinproctrace.so
|
||||||
|
|
||||||
|
$(IPA_LIB): $(sort $(IPA_OBJS)) ${CDEPS}
|
||||||
|
$(SILENCE) rm -f $(IPA_LIB)
|
||||||
|
- $(ECHO_CXXLD) $(CC_LD) -shared -fPIC -Wl,--soname=$(IPA_LIB) \
|
||||||
|
+ $(ECHO_CXXLD) $(CC_LD) -static -fPIC -Wl,--soname=$(IPA_LIB) \
|
||||||
|
-Wl,--no-undefined $(INTERNAL_CFLAGS) $(INTERNAL_LDFLAGS) \
|
||||||
|
$(CXXFLAGS) \
|
||||||
|
-o $(IPA_LIB) ${IPA_OBJS} $(LIBIBERTY_FOR_SHLIB) -ldl -pthread
|
57
src/patch_gdb.sh
Executable file
57
src/patch_gdb.sh
Executable file
@ -0,0 +1,57 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Include utils library
|
||||||
|
script_dir=$(dirname "$0")
|
||||||
|
. "$script_dir/utils.sh"
|
||||||
|
|
||||||
|
function apply_patch() {
|
||||||
|
# Apply a patch to a directory.
|
||||||
|
#
|
||||||
|
# Parameters:
|
||||||
|
# $1: directory
|
||||||
|
# $2: path of patch
|
||||||
|
#
|
||||||
|
# Returns:
|
||||||
|
# 0: success
|
||||||
|
# 1: failure
|
||||||
|
|
||||||
|
local dir="$1"
|
||||||
|
local patch="$(realpath "$2")"
|
||||||
|
|
||||||
|
pushd "$dir" > /dev/null
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if the patch was already applied
|
||||||
|
if ! patch -p1 --dry-run < "$patch" &>/dev/null; then
|
||||||
|
>&2 echo "Error: patch already applied"
|
||||||
|
popd > /dev/null
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
patch -p1 < "$patch"
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
popd > /dev/null
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
popd > /dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
function main() {
|
||||||
|
if [[ $# -ne 2 ]]; then
|
||||||
|
>&2 echo "Usage: $0 <gdb_dir> <gdb_patch>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
fancy_title "Applying GDB patch"
|
||||||
|
apply_patch "$1" "$2"
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
>&2 echo "Error: failed to apply GDB patch"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fancy_title "Finished applying GDB patch"
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
@ -1 +0,0 @@
|
|||||||
Subproject commit 25f97ccb7ff1a9d7bd0e25535d749acf6e1a87be
|
|
@ -1 +0,0 @@
|
|||||||
Subproject commit f38630702ca74b512256880f5e80130a8733a0b5
|
|
@ -1 +0,0 @@
|
|||||||
Subproject commit 2691aff4304a6d7e053199c205620136481b9dd1
|
|
@ -1 +0,0 @@
|
|||||||
Subproject commit b583de4794e94b4dc4c2da03a7c29f462482293e
|
|
Loading…
x
Reference in New Issue
Block a user