Skip to content
Open
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
9 changes: 6 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,22 @@ RUN apt update && apt install -y \
make \
patch \
pkg-config \
python3.12 \
python3-pip \
software-properties-common \
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you keep the list alphabetically ordered (also need to move libtool as well haha)

libpython3-dev \
texinfo \
wget \
xz-utils

RUN add-apt-repository ppa:deadsnakes/ppa
RUN apt update && apt install -y python3.14

# We require aiohttp >= 3.12 (For client middleware support), which is newer than the currently
# available python3-aiohttp's version in Ubuntu.
RUN python3.12 -m pip install --break-system-packages aiohttp
RUN python3.14 -m pip install --break-system-packages aiohttp

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

WORKDIR /app/gdb

Expand Down
23 changes: 15 additions & 8 deletions src/compilation/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,20 @@ function set_up_base_lib_search_paths() {
# $3: mpfr build dir
# $4: ncursesw build dir
# $5: expat build dir
# $6: lzma build dir
local iconv_build_dir="$1"
local gmp_build_dir="$2"
local mpfr_build_dir="$3"
local ncursesw_build_dir="$4"
local expat_build_dir="$5"
local lzma_build_dir="$6"

set_up_lib_search_path $iconv_build_dir 0
set_up_lib_search_path $gmp_build_dir 0
set_up_lib_search_path $mpfr_build_dir 0
set_up_lib_search_path $ncursesw_build_dir 1
set_up_lib_search_path $expat_build_dir 1
set_up_lib_search_path $lzma_build_dir 1
}

function build_iconv() {
Expand Down Expand Up @@ -482,13 +485,14 @@ function build_python() {
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
if [[ -f "$python_lib_dir/python-config" && -f "$python_lib_dir/libpython3.14.a" ]]; then
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try to make it generic by fetching the python version via python --version or which pythonX (might need to create a symlink so that it's name won't change each time we change a version, but you get the gist)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EDIT - even a global variable exported in the dockerfile is more then fine by me :)

>&2 echo "Skipping build: libpython already built for $target_arch"
return 0
fi
Expand All @@ -499,14 +503,14 @@ function build_python() {
export LINKFORSHARED=" "
export MODULE_BUILDTYPE="static"
export CONFIG_SITE="$python_dir/config.site-static"
>&2 CFLAGS="-static" LDFLAGS="-static" ../configure \
>&2 CFLAGS="${CFLAGS} -static" LDFLAGS="${LDFLAGS} -static -llzma" ../configure \
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOL good catch

--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 \
--with-build-python=/usr/bin/python3.14 \
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment as before about making it generic

--disable-ipv6 \
--disable-shared

Expand All @@ -517,7 +521,7 @@ function build_python() {

# 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 python3.14 ../Tools/build/freeze_modules.py
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

if [[ $? -ne 0 ]]; then
return 1
fi
Expand Down Expand Up @@ -827,16 +831,19 @@ function build_gdb_with_dependencies() {
"$gmp_build_dir" \
"$mpfr_build_dir" \
"$ncursesw_build_dir" \
"$libexpat_build_dir"
"$libexpat_build_dir" \
"$lzma_build_dir"

# Optional build components
if [[ $full_build == "yes" && $full_build_python_support -eq 1 ]]; then
local libffi_install_dir="$(build_libffi "${packages_dir}/libffi" "${target_arch}")"
setup_libffi_env "${libffi_install_dir}"

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")"
local gdb_python_dir pygments_source_dir python_build_dir

gdb_python_dir="$packages_dir/binutils-gdb/gdb/python/lib/"
pygments_source_dir="$packages_dir/pygments/"
python_build_dir="$(build_python "$packages_dir/cpython-static" "$target_arch" "$gdb_python_dir" "$pygments_source_dir" )"
if [[ $? -ne 0 ]]; then
return 1
fi
Expand Down
12 changes: 8 additions & 4 deletions src/compilation/frozen_python_modules.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
_aix_support
_colorize
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you tag the needed modules for GEF via a comment - i don't want them getting removed accidentally in the future (thank you for not remembering it :) )

_opcode_metadata
_py_warnings
annotationlib
antigravity
argparse
ast
Expand All @@ -14,7 +18,7 @@ _collections_abc
colorsys
_compat_pickle
compileall
_compression
<compression.**.*>
<concurrent.**.*>
configparser
contextlib
Expand Down Expand Up @@ -75,7 +79,7 @@ operator
optparse
os
_osx_support
pathlib
<pathlib.**.*>
pdb
<__phello__.**.*>
pickle
Expand Down Expand Up @@ -114,12 +118,12 @@ socketserver
statistics
stat
stringprep
string
<string.**.*>
_strptime
struct
subprocess
symtable
sysconfig
<sysconfig.**.*>
tabnanny
tempfile
textwrap
Expand Down
33 changes: 33 additions & 0 deletions src/compilation/install_autoconf.sh
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not see anyone using this specific script.
I remember we talked (quiet a while ago) about not having the latest autoconf available giving you issues with issue #63
Is this script related to that?

Anyhow, please document the purpose of this script :)

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash

set -e

# Download and install a specific autoconf version.

# Example: "2.10"
AUTOCONF_VERSION="${1}"
if [ -z "${AUTOCONF_VERSION}" ]; then
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if [ -z "${AUTOCONF_VERSION}" ]; then
if [[ -z "${AUTOCONF_VERSION}" ]]; then

echo "No autoconf version supplied"
exit 1
fi

AUTOCONF_URL_BASE="https://ftp.gnu.org/gnu/autoconf/"
AUTOCONF_BASENAME="autoconf-${AUTOCONF_VERSION}.tar.gz"
AUTOCONF_URL="${AUTOCONF_URL_BASE}${AUTOCONF_BASENAME}"

autoconf_dir="$(mktemp -d)"
pushd "${autoconf_dir}"
echo "Using directory: ${autoconf_dir}"

echo "Downloading: ${AUTOCONF_URL}"
wget -O - "${AUTOCONF_URL}" | tar -xzf -

pushd "autoconf-${AUTOCONF_VERSION}"

./configure

make install

popd &> /dev/null

popd &> /dev/null
2 changes: 1 addition & 1 deletion src/docker_utils/download_musl_toolchains.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ async def download_file(url: str, filename: str):

def extract_tarfile(filename: str, dst: Path):
with tarfile.open(filename, "r") as tar:
tar.extractall(path=dst)
tar.extractall(path=dst, filter='tar')

async def download_tarfile(tar_url: str, extraction_dir: Path):
with tempfile.NamedTemporaryFile() as named_tempfile:
Expand Down
2 changes: 1 addition & 1 deletion src/submodule_packages/cpython-static
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good 💯

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EDIT: btw, since you added expat, we can add ncurses as well, no? we already support it in gdb static just like expat

Submodule cpython-static updated 3597 files