From 08e83816ffaf1f8fe23db3c74fa561a978906b1e Mon Sep 17 00:00:00 2001 From: Roddy Rappaport Date: Fri, 26 Dec 2025 16:05:01 +0200 Subject: [PATCH 1/4] Updated Python to 3.14.2 --- src/compilation/build.sh | 2 +- src/submodule_packages/cpython-static | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compilation/build.sh b/src/compilation/build.sh index f7816ac..7cc7b05 100755 --- a/src/compilation/build.sh +++ b/src/compilation/build.sh @@ -513,7 +513,7 @@ function build_python() { LDFLAGS="${LDFLAGS} -static" \ CURSES_LIBS="-lncursesw" \ PANEL_LIBS="-lpanelw" \ - LIBS="${LIBS} -lexpat -llzma -lpanelw -lncursesw" \ + LIBS="${LIBS} -lexpat -lffi -llzma -lpanelw -lncursesw" \ ../configure \ --prefix="$(realpath .)" \ --disable-test-modules \ diff --git a/src/submodule_packages/cpython-static b/src/submodule_packages/cpython-static index 8e9b426..c082bc4 160000 --- a/src/submodule_packages/cpython-static +++ b/src/submodule_packages/cpython-static @@ -1 +1 @@ -Subproject commit 8e9b426c456e34e102e6992135cc40297bcd2477 +Subproject commit c082bc4966220880b9d5bbefd025e7a1aba4ab8b From 247538eeeecbaebc6911e97702fa10a7f4420ffc Mon Sep 17 00:00:00 2001 From: Roddy Rappaport Date: Fri, 26 Dec 2025 17:51:23 +0200 Subject: [PATCH 2/4] Added missing library for Python repl It's necessary for the executable to run, so even if GDB doesn't use it we should probably want it. --- src/compilation/static-python.site | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/compilation/static-python.site b/src/compilation/static-python.site index 73bad77..3a10843 100644 --- a/src/compilation/static-python.site +++ b/src/compilation/static-python.site @@ -3,6 +3,10 @@ ac_cv_file__dev_ptmx=yes ac_cv_file__dev_ptc=no ac_cv_header_zlib_h=no +# Fix the module import path, by telling Python it should look for modules in +# the regular scope, not the installed scope. +host_prefix=/usr + # Custom flag that we added to configure, causes the check for zstd to automatically # fail and mark the library as missing. This is so that it wouldn't try to dynamically # link to it when linking python/gdb. From ab9379ee60cfef6760248c3891872b670b0da916 Mon Sep 17 00:00:00 2001 From: Roddy Rappaport Date: Fri, 26 Dec 2025 19:54:50 +0200 Subject: [PATCH 3/4] Compiling zlib manually and linking it with Python This allows us to link it with the static Python, enabling zlib and gzip support. --- .gitmodules | 3 ++ src/compilation/build.sh | 58 ++++++++++++++++++++++++++++-- src/compilation/static-python.site | 8 +---- src/submodule_packages/zlib | 1 + 4 files changed, 60 insertions(+), 10 deletions(-) create mode 160000 src/submodule_packages/zlib diff --git a/.gitmodules b/.gitmodules index 7cc82ba..f48ea54 100644 --- a/.gitmodules +++ b/.gitmodules @@ -18,3 +18,6 @@ [submodule "src/submodule_packages/libffi"] path = src/submodule_packages/libffi url = git@github.com:libffi/libffi.git +[submodule "src/submodule_packages/zlib"] + path = src/submodule_packages/zlib + url = git@github.com:madler/zlib.git diff --git a/src/compilation/build.sh b/src/compilation/build.sh index 7cc7b05..4925fde 100755 --- a/src/compilation/build.sh +++ b/src/compilation/build.sh @@ -84,12 +84,14 @@ function set_up_base_lib_search_paths() { # $4: ncursesw build dir # $5: expat build dir # $6: lzma build dir + # $7: zlib 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" + local zlib_build_dir="$7" set_up_lib_search_path $iconv_build_dir 0 set_up_lib_search_path $gmp_build_dir 0 @@ -97,6 +99,7 @@ function set_up_base_lib_search_paths() { 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 + set_up_lib_search_path $zlib_build_dir 1 } function build_iconv() { @@ -429,6 +432,47 @@ function build_libffi() { popd > /dev/null } +function build_zlib() { + # Build zlib, for the zlib compression support (Also gz). + # + # Parameters: + # $1: zlib package directory + # $2: Target architecture + local zlib_dir="$1" + local target_arch="$2" + + pushd "${zlib_dir}" > /dev/null + + local zlib_build_dir="$(realpath "$zlib_dir/build-$target_arch")" + mkdir -p "${zlib_build_dir}" + pushd "${zlib_build_dir}" > /dev/null + + local zlib_install_dir="${zlib_build_dir}/output/" + echo "${zlib_install_dir}" + + if [[ -f "${zlib_install_dir}/lib/libz.a" ]]; then + >&2 echo "Skipping build: zlib already built for $target_arch" + return 0 + fi + + >&2 fancy_title "Building zlib for $target_arch" + + >&2 ../configure --static --prefix="${zlib_install_dir}" + if [[ $? != 0 ]]; then + return 1 + fi + + >&2 make install + if [[ $? != 0 ]]; then + return 1 + fi + + >&2 fancy_title "Finished building zlib for $target_arch" + + popd > /dev/null + popd > /dev/null +} + function add_to_pkg_config_path() { # This method add directories to the list that pkg-config looks for .pc (package config) files # when finding the correct flags for modules. @@ -501,7 +545,7 @@ function build_python() { pushd "$python_lib_dir" > /dev/null >&2 fancy_title "Building python for $target_arch" - # If we don't specify CURSES_LIBS and/or PANEL_LIBS Python accidentally (I assume) initializes + # If we don't specify the .*_LIBS variables Python accidentally (I assume) initializes # the variable(s) as 'none required' and then failes when trying to use the variable(s) when # linking because 'none' & 'required' aren't valid files or flags to gcc. # We also need to pass these libs in the LIBS variable in order to pass the libraries to python-config. @@ -513,7 +557,8 @@ function build_python() { LDFLAGS="${LDFLAGS} -static" \ CURSES_LIBS="-lncursesw" \ PANEL_LIBS="-lpanelw" \ - LIBS="${LIBS} -lexpat -lffi -llzma -lpanelw -lncursesw" \ + ZLIB_LIBS="-lz" \ + LIBS="${LIBS} -lexpat -lffi -llzma -lpanelw -lncursesw -lz" \ ../configure \ --prefix="$(realpath .)" \ --disable-test-modules \ @@ -683,6 +728,7 @@ function build_gdb() { --with-gmp="$libgmp_prefix" \ --with-mpfr="$libmpfr_prefix" \ --enable-tui \ + --with-system-zlib \ --with-expat --with-libexpat-type=static \ --with-lzma=yes --with-liblzma-prefix="$liblzma_prefix" --with-liblzma-type="static" \ "${extra_flags[@]}" \ @@ -855,12 +901,18 @@ function build_gdb_with_dependencies() { return 1 fi + zlib_build_dir="$(build_zlib "${packages_dir}/zlib/" "${target_arch}")" + if [[ $? -ne 0 ]]; then + return 1 + fi + set_up_base_lib_search_paths "$iconv_build_dir" \ "$gmp_build_dir" \ "$mpfr_build_dir" \ "$ncursesw_build_dir" \ "$libexpat_build_dir" \ - "$lzma_build_dir" + "$lzma_build_dir" \ + "$zlib_build_dir" # Optional build components if [[ $full_build == "yes" && $full_build_python_support -eq 1 ]]; then diff --git a/src/compilation/static-python.site b/src/compilation/static-python.site index 3a10843..c3aeff3 100644 --- a/src/compilation/static-python.site +++ b/src/compilation/static-python.site @@ -1,25 +1,19 @@ ac_cv_buggy_getaddrinfo=no ac_cv_file__dev_ptmx=yes ac_cv_file__dev_ptc=no -ac_cv_header_zlib_h=no # Fix the module import path, by telling Python it should look for modules in # the regular scope, not the installed scope. host_prefix=/usr -# Custom flag that we added to configure, causes the check for zstd to automatically -# fail and mark the library as missing. This is so that it wouldn't try to dynamically -# link to it when linking python/gdb. -pkg_check_module_ZLIB=no - # Custom flag that we added that allows us to compile libhacl statically not for WASI. ac_static_libhacl=yes py_cv_module__decimal=n/a -py_cv_module_zlib=n/a py_cv_module_xxlimited=n/a py_cv_module__crypt=n/a +py_cv_module_zlib=yes py_cv_module__curses=yes py_cv_module__curses_panel=yes diff --git a/src/submodule_packages/zlib b/src/submodule_packages/zlib new file mode 160000 index 0000000..5a82f71 --- /dev/null +++ b/src/submodule_packages/zlib @@ -0,0 +1 @@ +Subproject commit 5a82f71ed1dfc0bec044d9702463dbdf84ea3b71 From 5ba46dead0c9d2dfcd38fa55852f08fccc6192b9 Mon Sep 17 00:00:00 2001 From: Roddy Rappaport Date: Fri, 26 Dec 2025 17:52:04 +0200 Subject: [PATCH 4/4] Fixed global module paths The static Python can now import modules from the regular module directories. Please note that modules that contain C code will still not work, and will never work, because these require `ld` to load their shared module, which isn't something that can be done in static binaries. --- src/compilation/frozen_python_modules.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/compilation/frozen_python_modules.txt b/src/compilation/frozen_python_modules.txt index 91d3195..118c4e6 100644 --- a/src/compilation/frozen_python_modules.txt +++ b/src/compilation/frozen_python_modules.txt @@ -101,6 +101,7 @@ _pydatetime _pydecimal _pyio _pylong +<_pyrepl.**.*> queue quopri random