Compare commits
7 Commits
v15.2-stat
...
parallel-c
Author | SHA1 | Date | |
---|---|---|---|
cc1c9763b2 | |||
00a8738392 | |||
0a60aedf76 | |||
ff0d3ad28f | |||
c86f506e90 | |||
46e8eb22a8 | |||
fa04d3a7a2 |
24
.github/workflows/pr-pipeline.yaml
vendored
Normal file
24
.github/workflows/pr-pipeline.yaml
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
name: gdb-static-pr-pipeline
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- '*'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
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 build-${{ matrix.architecture }} -j$((`nproc`+1))
|
@ -1,19 +1,19 @@
|
||||
name: gdb-static-pipeline
|
||||
name: gdb-static-release-pipeline
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- '*'
|
||||
push:
|
||||
tags:
|
||||
- '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:
|
||||
build:
|
||||
build_and_publish:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Install dependencies
|
||||
run: sudo apt-get install -y wget
|
||||
@ -24,14 +24,7 @@ jobs:
|
||||
- name: 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
|
||||
if: github.event_name == 'push'
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
files: build/artifacts/gdb-static*.tar.gz
|
||||
files: build/artifacts/gdb-static*.tar.gz
|
8
.gitmodules
vendored
Normal file
8
.gitmodules
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
[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
|
@ -2,6 +2,9 @@ FROM ubuntu:24.04
|
||||
|
||||
# Install dependencies
|
||||
RUN apt update && apt install -y \
|
||||
bison \
|
||||
file \
|
||||
flex \
|
||||
g++ \
|
||||
g++-aarch64-linux-gnu \
|
||||
g++-arm-linux-gnueabi \
|
||||
@ -14,10 +17,14 @@ RUN apt update && apt install -y \
|
||||
gcc-mips-linux-gnu \
|
||||
gcc-mipsel-linux-gnu \
|
||||
gcc-powerpc-linux-gnu \
|
||||
git \
|
||||
libncurses-dev \
|
||||
m4 \
|
||||
make \
|
||||
patch \
|
||||
pkg-config \
|
||||
python3.12 \
|
||||
libpython3-dev \
|
||||
texinfo \
|
||||
wget \
|
||||
xz-utils
|
||||
|
33
Makefile
33
Makefile
@ -1,8 +1,10 @@
|
||||
ARCHS := x86_64 arm aarch64 powerpc mips mipsel
|
||||
TARGETS := $(addprefix build-, $(ARCHS))
|
||||
PACK_TARGETS := $(addprefix pack-, $(ARCHS))
|
||||
SUBMODULE_PACKAGES := $(wildcard src/submodule_packages/*)
|
||||
BUILD_PACKAGES_DIR := "build/packages"
|
||||
|
||||
.PHONY: clean help download_packages build patch-gdb build-docker-image $(TARGETS) $(PACK_TARGETS)
|
||||
.PHONY: clean help download_packages build build-docker-image $(TARGETS) $(PACK_TARGETS)
|
||||
|
||||
help:
|
||||
@echo "Usage:"
|
||||
@ -23,30 +25,28 @@ build/build-docker-image.stamp: Dockerfile
|
||||
|
||||
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
|
||||
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) \
|
||||
--rm --volume .:/app/gdb gdb-static env TERM=xterm-256color \
|
||||
/app/gdb/src/download_packages.sh /app/gdb/build/packages
|
||||
/app/gdb/src/compilation/download_packages.sh /app/gdb/$(BUILD_PACKAGES_DIR)/
|
||||
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
|
||||
|
||||
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
|
||||
$(TARGETS): build-%: symlink-git-packages download-packages 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
|
||||
/app/gdb/src/compilation/build.sh $* /app/gdb/build/ /app/gdb/src
|
||||
|
||||
pack: $(PACK_TARGETS)
|
||||
|
||||
@ -55,7 +55,10 @@ $(PACK_TARGETS): pack-%: build-%
|
||||
tar -czf "build/artifacts/gdb-static-$*.tar.gz" -C "build/artifacts/$*" .; \
|
||||
fi
|
||||
|
||||
clean:
|
||||
clean-git-packages:
|
||||
git submodule foreach '[[ ! "$$sm_path" == src/submodule_packages/* ]] || git clean -xffd'
|
||||
|
||||
clean: clean-git-packages
|
||||
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
|
||||
|
@ -2,7 +2,10 @@
|
||||
|
||||
# Include utils library
|
||||
script_dir=$(dirname "$0")
|
||||
. "$script_dir/utils.sh"
|
||||
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.
|
||||
@ -40,7 +43,7 @@ function set_compliation_variables() {
|
||||
CROSS=mipsel-linux-gnu-
|
||||
export HOST=mipsel-linux-gnu
|
||||
elif [[ "$target_arch" == "x86_64" ]]; then
|
||||
CROSS=""
|
||||
CROSS=x86_64-linux-gnu-
|
||||
export HOST=x86_64-linux-gnu
|
||||
fi
|
||||
|
||||
@ -208,6 +211,64 @@ function build_ncurses() {
|
||||
popd > /dev/null
|
||||
}
|
||||
|
||||
function build_python() {
|
||||
# Build python.
|
||||
#
|
||||
# Parameters:
|
||||
# $1: python package directory
|
||||
# $2: target architecture
|
||||
#
|
||||
# Echoes:
|
||||
# The python build directory
|
||||
#
|
||||
# Returns:
|
||||
# 0: success
|
||||
# 1: failure
|
||||
local python_dir="$1"
|
||||
local target_arch="$2"
|
||||
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
|
||||
|
||||
>&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.
|
||||
#
|
||||
@ -298,7 +359,8 @@ function build_gdb() {
|
||||
|
||||
>&2 fancy_title "Building gdb for $target_arch"
|
||||
|
||||
../configure --enable-static --enable-tui --with-static-standard-libraries --disable-inprocess-agent \
|
||||
../configure -C --enable-static --with-static-standard-libraries --disable-inprocess-agent \
|
||||
--enable-tui --with-python=/app/gdb/build/packages/cpython-static/build-$target_arch/bin/python3-config \
|
||||
"--with-libiconv-prefix=$libiconv_prefix" --with-libiconv-type=static \
|
||||
"--with-gmp=$libgmp_prefix" \
|
||||
"--with-mpfr=$libmpfr_prefix" \
|
||||
@ -395,9 +457,11 @@ function build_gdb_with_dependencies() {
|
||||
# Parameters:
|
||||
# $1: target architecture
|
||||
# $2: build directory
|
||||
# $3: src directory
|
||||
|
||||
local target_arch="$1"
|
||||
local build_dir="$2"
|
||||
local source_dir="$3"
|
||||
local packages_dir="$build_dir/packages"
|
||||
local artifacts_dir="$build_dir/artifacts"
|
||||
|
||||
@ -427,15 +491,19 @@ function build_gdb_with_dependencies() {
|
||||
if [[ $? -ne 0 ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
set_ncurses_link_variables "$ncursesw_build_dir"
|
||||
|
||||
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"
|
||||
python_build_dir="$(build_python "$packages_dir/cpython-static" "$target_arch")"
|
||||
if [[ $? -ne 0 ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
build_and_install_gdb "$packages_dir/binutils-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
|
||||
@ -443,11 +511,11 @@ function build_gdb_with_dependencies() {
|
||||
|
||||
function main() {
|
||||
if [[ $# -ne 3 ]]; then
|
||||
>&2 echo "Usage: $0 <target_arch> <build_dir>"
|
||||
>&2 echo "Usage: $0 <target_arch> <build_dir> <src_dir>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
build_gdb_with_dependencies "$1" "$2"
|
||||
build_gdb_with_dependencies "$1" "$2" "$3"
|
||||
if [[ $? -ne 0 ]]; then
|
||||
>&2 echo "Error: failed to build gdb with dependencies"
|
||||
exit 1
|
@ -2,14 +2,13 @@
|
||||
|
||||
# Include utils library
|
||||
script_dir=$(dirname "$0")
|
||||
. "$script_dir/utils.sh"
|
||||
source "$script_dir/utils.sh"
|
||||
|
||||
# List of package URLs to download
|
||||
PACKAGE_URLS=(
|
||||
SOURCE_URLS=(
|
||||
"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/mpfr/mpfr-4.2.1.tar.xz"
|
||||
"https://ftp.gnu.org/gnu/gdb/gdb-15.2.tar.xz"
|
||||
"https://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.5.tar.gz"
|
||||
)
|
||||
|
||||
@ -188,7 +187,7 @@ function download_gdb_packages() {
|
||||
|
||||
fancy_title "Starting download of GDB packages"
|
||||
|
||||
for url in "${PACKAGE_URLS[@]}"; do
|
||||
for url in "${SOURCE_URLS[@]}"; do
|
||||
package_dir=$(package_url_to_dir "$url")
|
||||
download_and_extract_package "$url" "$package_dir" &
|
||||
download_pids+=($!)
|
||||
@ -203,7 +202,6 @@ function download_gdb_packages() {
|
||||
done
|
||||
|
||||
fancy_title "Finished downloading GDB packages"
|
||||
|
||||
popd
|
||||
}
|
||||
|
@ -1,70 +0,0 @@
|
||||
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
|
@ -1,57 +0,0 @@
|
||||
#!/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
src/submodule_packages/binutils-gdb
Submodule
1
src/submodule_packages/binutils-gdb
Submodule
Submodule src/submodule_packages/binutils-gdb added at f7d0fb2e22
1
src/submodule_packages/cpython-static
Submodule
1
src/submodule_packages/cpython-static
Submodule
Submodule src/submodule_packages/cpython-static added at d734d02f4c
Reference in New Issue
Block a user