From 787e0cbc4118a9a6ab4a9d0542eab513346b6685 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Gu=C3=A9rin?= Date: Mon, 30 Jan 2023 08:26:57 +0100 Subject: [PATCH] manylinux2014-aarch64: Install zlib in sysroot --- common/common-manylinux.crosstool | 1 + common/common.crosstool | 1 + imagefiles/install-crosstool-ng-toolchain.sh | 7 ++ .../crosstool-ng-zlib-target.patch | 77 +++++++++++++++++++ manylinux2014-aarch64/crosstool-ng.config | 5 +- 5 files changed, 89 insertions(+), 2 deletions(-) create mode 100644 imagefiles/patch/crosstool-ng/crosstool-ng-zlib-target.patch diff --git a/common/common-manylinux.crosstool b/common/common-manylinux.crosstool index 776fc33..2230d8b 100644 --- a/common/common-manylinux.crosstool +++ b/common/common-manylinux.crosstool @@ -47,6 +47,7 @@ ENV XCC_PREFIX=/usr/xcc # for users. COPY \ imagefiles/install-crosstool-ng-toolchain.sh \ + imagefiles/patch/crosstool-ng/crosstool-ng-zlib-target.patch \ manylinux2014-aarch64/crosstool-ng.config \ /dockcross/ diff --git a/common/common.crosstool b/common/common.crosstool index 5c5b1be..b069b3e 100644 --- a/common/common.crosstool +++ b/common/common.crosstool @@ -38,6 +38,7 @@ ENV XCC_PREFIX=/usr/xcc # for users. COPY \ imagefiles/install-crosstool-ng-toolchain.sh \ + imagefiles/patch/crosstool-ng/crosstool-ng-zlib-target.patch \ crosstool-ng.config \ /dockcross/ diff --git a/imagefiles/install-crosstool-ng-toolchain.sh b/imagefiles/install-crosstool-ng-toolchain.sh index 3c670c3..15331f6 100755 --- a/imagefiles/install-crosstool-ng-toolchain.sh +++ b/imagefiles/install-crosstool-ng-toolchain.sh @@ -75,6 +75,13 @@ git fetch --tags # checkout git checkout ${REV} +if [ ${REV} = "crosstool-ng-1.25.0" ]; then + patch scripts/build/companion_libs/050-zlib.sh -i /dockcross/crosstool-ng-zlib-target.patch + # Clean patch + rm /dockcross/crosstool-ng-zlib-target.patch +fi + + # Bootstrap and install the tool. BOOTSTRAP_PREFIX="${CTNG}/prefix" ./bootstrap diff --git a/imagefiles/patch/crosstool-ng/crosstool-ng-zlib-target.patch b/imagefiles/patch/crosstool-ng/crosstool-ng-zlib-target.patch new file mode 100644 index 0000000..6b22a2f --- /dev/null +++ b/imagefiles/patch/crosstool-ng/crosstool-ng-zlib-target.patch @@ -0,0 +1,77 @@ +--- a/scripts/build/companion_libs/050-zlib.sh ++++ b/scripts/build/companion_libs/050-zlib.sh +@@ -9,7 +9,7 @@ do_zlib_for_host() { :; } + do_zlib_for_target() { :; } + + # Overide functions depending on configuration +-if [ "${CT_ZLIB}" = "y" ]; then ++if [ "${CT_ZLIB}" = "y" -o "${CT_ZLIB_TARGET}" = "y" ]; then + + # Download zlib + do_zlib_get() { +@@ -21,6 +21,8 @@ do_zlib_extract() { + CT_ExtractPatch ZLIB + } + ++if [ "${CT_ZLIB}" = "y" ]; then ++ + # Build zlib for running on build + # - always build statically + # - install in build-tools prefix +@@ -61,6 +63,38 @@ do_zlib_for_host() { + CT_EndStep + } + ++fi # CT_ZLIB ++ ++if [ "${CT_ZLIB_TARGET}" = "y" ]; then ++ ++do_zlib_for_target() { ++ local -a zlib_opts ++ local prefix ++ ++ CT_DoStep INFO "Installing zlib for the target" ++ CT_mkdir_pushd "${CT_BUILD_DIR}/build-zlib-target-${CT_TARGET}" ++ ++ case "${CT_TARGET}" in ++ *-*-mingw*) ++ prefix="/mingw" ++ ;; ++ *) ++ prefix="/usr" ++ ;; ++ esac ++ ++ zlib_opts+=( "host=${CT_TARGET}" ) ++ zlib_opts+=( "prefix=${prefix}" ) ++ zlib_opts+=( "destdir=${CT_SYSROOT_DIR}" ) ++ zlib_opts+=( "cflags=${CT_ALL_TARGET_CFLAGS}" ) ++ do_zlib_backend "${zlib_opts[@]}" ++ ++ CT_Popd ++ CT_EndStep ++} ++ ++fi # CT_ZLIB_TARGET ++ + # Build zlib + # Parameter : description : type : default + # host : machine to run on : tuple : (none) +@@ -72,6 +106,7 @@ do_zlib_backend() { + local prefix + local cflags + local ldflags ++ local destdir + local arg + local -a extra_config + local -a extra_make +@@ -126,7 +161,7 @@ do_zlib_backend() { + fi + + CT_DoLog EXTRA "Installing zlib" +- CT_DoExecLog ALL make "${extra_make[@]}" install ++ CT_DoExecLog ALL make "${extra_make[@]}" install DESTDIR="${destdir}" + } + +-fi # CT_ZLIB ++fi # CT_ZLIB || CT_ZLIB_TARGET diff --git a/manylinux2014-aarch64/crosstool-ng.config b/manylinux2014-aarch64/crosstool-ng.config index 107e051..af86038 100644 --- a/manylinux2014-aarch64/crosstool-ng.config +++ b/manylinux2014-aarch64/crosstool-ng.config @@ -541,7 +541,7 @@ CT_CC_GCC_ENABLE_CXX_FLAGS="-I/usr/include -fpermissive" CT_CC_GCC_CORE_EXTRA_CONFIG_ARRAY="" CT_CC_GCC_EXTRA_CONFIG_ARRAY="" CT_CC_GCC_STATIC_LIBSTDCXX=y -# CT_CC_GCC_SYSTEM_ZLIB is not set +CT_CC_GCC_SYSTEM_ZLIB=y CT_CC_GCC_CONFIG_TLS=m # @@ -789,6 +789,7 @@ CT_NCURSES_TARGET_CONFIG_ARGS="" CT_NCURSES_TARGET_FALLBACKS="" CT_COMP_LIBS_ZLIB=y CT_COMP_LIBS_ZLIB_PKG_KSYM="ZLIB" +CT_ZLIB_TARGET=y CT_ZLIB_DIR_NAME="zlib" CT_ZLIB_PKG_NAME="zlib" CT_ZLIB_SRC_RELEASE=y @@ -796,7 +797,7 @@ CT_ZLIB_SRC_RELEASE=y CT_ZLIB_PATCH_ORDER="global" CT_ZLIB_V_1_2_12=y CT_ZLIB_VERSION="1.2.13" -CT_ZLIB_MIRRORS="http://downloads.sourceforge.net/project/libpng/zlib/${CT_ZLIB_VERSION} https://www.zlib.net/" +CT_ZLIB_MIRRORS="https://github.com/madler/zlib/releases/download/v${CT_ZLIB_VERSION} https://www.zlib.net/ https://www.zlib.net/fossils" CT_ZLIB_ARCHIVE_FILENAME="@{pkg_name}-@{version}" CT_ZLIB_ARCHIVE_DIRNAME="@{pkg_name}-@{version}" CT_ZLIB_ARCHIVE_FORMATS=".tar.xz .tar.gz"