Skip to content

Add cross-builds for ARM #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
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: 2 additions & 7 deletions cpython-unix/base.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# Debian Jessie.
FROM debian@sha256:734728c8e411698485ae644fc988dad06f757565e292b5b85edc084befa37bbb
MAINTAINER Gregory Szorc <[email protected]>
FROM ubuntu:xenial

RUN groupadd -g 1000 build && \
useradd -u 1000 -g 1000 -d /build -s /bin/bash -m build && \
Expand All @@ -17,10 +15,7 @@ ENV HOME=/build \
CMD ["/bin/bash", "--login"]
WORKDIR '/build'

RUN for s in debian_jessie debian_jessie-updates debian-security_jessie/updates; do \
echo "deb http://snapshot.debian.org/archive/${s%_*}/20200510T203930Z/ ${s#*_} main"; \
done > /etc/apt/sources.list && \
( echo 'quiet "true";'; \
RUN ( echo 'quiet "true";'; \
echo 'APT::Get::Assume-Yes "true";'; \
echo 'APT::Install-Recommends "false";'; \
echo 'Acquire::Check-Valid-Until "false";'; \
Expand Down
2 changes: 1 addition & 1 deletion cpython-unix/build-bdb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pushd db-${BDB_VERSION}/build_unix

CFLAGS="${EXTRA_TARGET_CFLAGS} -fPIC" CPPFLAGS="${EXTRA_TARGET_CFLAGS} -fPIC" ../dist/configure \
--build=${BUILD_TRIPLE} \
--target=${TARGET_TRIPLE} \
--host=${TARGET_TRIPLE} \
--prefix=/tools/deps \
--enable-dbm \
--disable-shared
Expand Down
23 changes: 18 additions & 5 deletions cpython-unix/build-cpython.sh
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,16 @@ if [ "${PYBUILD_PLATFORM}" = "macos" ]; then
CONFIGURE_FLAGS="${CONFIGURE_FLAGS} ac_cv_lib_intl_textdomain=yes"
fi

if [ "${BUILD_TRIPLE}" != "${TARGET_TRIPLE}" ]; then
CONFIGURE_FLAGS="--build=${BUILD_TRIPLE} \
--host=${TARGET_TRIPLE} \
--disable-ipv6 \
${CONFIGURE_FLAGS} \
ac_cv_file__dev_ptmx=no \
ac_cv_file__dev_ptc=no"
export PYTHON_DECIMAL_WITH_MACHINE=uint128
fi

CFLAGS=$CFLAGS CPPFLAGS=$CFLAGS LDFLAGS=$LDFLAGS \
./configure ${CONFIGURE_FLAGS}

Expand Down Expand Up @@ -276,6 +286,11 @@ else
PYTHON_BINARY_SUFFIX=
fi

# Python interpreter to use during the build.
if [ -z "${BUILD_PYTHON}" ]; then
BUILD_PYTHON=${ROOT}/out/python/install/bin/python3
fi

# If we're building a shared library hack some binaries so rpath is set.
# This ensures we can run the binary in any location without
# LD_LIBRARY_PATH pointing to the directory containing libpython.
Expand Down Expand Up @@ -346,7 +361,7 @@ index ec9942f0..1b306ca7 100644
except AttributeError:
EOF

${ROOT}/out/python/install/bin/python3 setup.py install
${BUILD_PYTHON} setup.py install
popd

pushd ${ROOT}/pip-${PIP_VERSION}
Expand Down Expand Up @@ -385,7 +400,7 @@ index 60a69d8..08c0597 100644
except AttributeError:
EOF

${ROOT}/out/python/install/bin/python3 setup.py install
${BUILD_PYTHON} setup.py install
popd

# Emit metadata to be used in PYTHON.json.
Expand Down Expand Up @@ -428,9 +443,7 @@ with open(sys.argv[1], "w") as fh:
json.dump(metadata, fh, sort_keys=True, indent=4)
EOF

PYTHON_EXE=${ROOT}/out/python/install/bin/$(readlink ${ROOT}/out/python/install/bin/python3)

${ROOT}/out/python/install/bin/python3 ${ROOT}/generate_metadata.py ${ROOT}/metadata.json
${BUILD_PYTHON} ${ROOT}/generate_metadata.py ${ROOT}/metadata.json
cat ${ROOT}/metadata.json

if [ "${CC}" != "musl-clang" ]; then
Expand Down
4 changes: 2 additions & 2 deletions cpython-unix/build-gdbm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ pushd gdbm-${GDBM_VERSION}

# CPython setup.py looks for libgdbm_compat and gdbm-ndbm.h,
# which require --enable-libgdbm-compat.
CLFAGS="${EXTRA_TARGET_CFLAGS} -fPIC" CPPFLAGS="${EXTRA_TARGET_CFLAGS} -fPIC" ./configure \
CLFAGS="${EXTRA_TARGET_CFLAGS} -fPIC" CPPFLAGS="${EXTRA_TARGET_CFLAGS} -fPIC" LDFLAGS="${EXTRA_TARGET_CFLAGS}" ./configure \
--build=${BUILD_TRIPLE} \
--target=${TARGET_TRIPLE} \
--host=${TARGET_TRIPLE} \
--prefix=/tools/deps \
--disable-shared \
--enable-libgdbm-compat
Expand Down
2 changes: 1 addition & 1 deletion cpython-unix/build-gettext.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pushd gettext-${GETTEXT_VERSION}
# an added dependency. So we force use of the bundled version.
CLFAGS="${EXTRA_TARGET_CFLAGS} -fPIC" CPPFLAGS="${EXTRA_TARGET_CFLAGS} -fPIC" ./configure \
--build=${BUILD_TRIPLE} \
--target=${TARGET_TRIPLE} \
--host=${TARGET_TRIPLE} \
--prefix=/tools/deps \
--disable-shared \
--disable-java \
Expand Down
8 changes: 5 additions & 3 deletions cpython-unix/build-inputproto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

set -ex

cd /build
ROOT=`pwd`

pkg-config --version

Expand All @@ -15,8 +15,10 @@ export PKG_CONFIG_PATH=/tools/deps/share/pkgconfig
tar -xf inputproto-${INPUTPROTO_VERSION}.tar.gz
pushd inputproto-${INPUTPROTO_VERSION}

CFLAGS="-fPIC" ./configure \
CFLAGS="${EXTRA_TARGET_CFLAGS} -fPIC" ./configure \
--build=${BUILD_TRIPLE} \
--host=${TARGET_TRIPLE} \
--prefix=/tools/deps

make -j `nproc`
make -j `nproc` install DESTDIR=/build/out
make -j `nproc` install DESTDIR=${ROOT}/out
10 changes: 5 additions & 5 deletions cpython-unix/build-kbproto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.

set -ex

cd /build
ROOT=`pwd`

pkg-config --version

Expand All @@ -15,8 +13,10 @@ export PKG_CONFIG_PATH=/tools/deps/share/pkgconfig
tar -xf kbproto-${KBPROTO_VERSION}.tar.gz
pushd kbproto-${KBPROTO_VERSION}

CFLAGS="-fPIC" ./configure \
CFLAGS="${EXTRA_TARGET_CFLAGS} -fPIC" ./configure \
--build=${BUILD_TRIPLE} \
--host=${TARGET_TRIPLE} \
--prefix=/tools/deps

make -j `nproc`
make -j `nproc` install DESTDIR=/build/out
make -j `nproc` install DESTDIR=${ROOT}/out
14 changes: 11 additions & 3 deletions cpython-unix/build-libX11.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

set -ex

cd /build
ROOT=`pwd`

export PATH=/tools/${TOOLCHAIN}/bin:/tools/host/bin:$PATH
export PKG_CONFIG_PATH=/tools/deps/share/pkgconfig:/tools/deps/lib/pkgconfig
Expand Down Expand Up @@ -41,9 +41,17 @@ if [ "${CC}" = "musl-clang" ]; then
EXTRA_FLAGS="--disable-shared"
fi

CFLAGS="-fPIC -I/tools/deps/include" ./configure \
if [ "${BUILD_TRIPLE}" != "${TARGET_TRIPLE}" ]; then
EXTRA_FLAGS="${EXTRA_FLAGS} \
--disable-ipv6 \
xorg_cv_malloc0_returns_null=yes"
fi

CFLAGS="${EXTRA_TARGET_CFLAGS} -fPIC -I/tools/deps/include" CFLAGS_FOR_BUILD="-I/tools/deps/include" ./configure \
--build=${BUILD_TRIPLE} \
--host=${TARGET_TRIPLE} \
--prefix=/tools/deps \
${EXTRA_FLAGS}

make -j `nproc`
make -j `nproc` install DESTDIR=/build/out
make -j `nproc` install DESTDIR=${ROOT}/out
8 changes: 5 additions & 3 deletions cpython-unix/build-libXau.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

set -ex

cd /build
ROOT=`pwd`

export PATH=/tools/${TOOLCHAIN}/bin:/tools/host/bin:$PATH
export PKG_CONFIG_PATH=/tools/deps/share/pkgconfig:/tools/deps/lib/pkgconfig
Expand All @@ -17,9 +17,11 @@ if [ "${CC}" = "musl-clang" ]; then
EXTRA_FLAGS="--disable-shared"
fi

CFLAGS="-fPIC" ./configure \
CFLAGS="${EXTRA_TARGET_CFLAGS} -fPIC" ./configure \
--build=${BUILD_TRIPLE} \
--host=${TARGET_TRIPLE} \
--prefix=/tools/deps \
${EXTRA_FLAGS}

make -j `nproc`
make -j `nproc` install DESTDIR=/build/out
make -j `nproc` install DESTDIR=${ROOT}/out
8 changes: 5 additions & 3 deletions cpython-unix/build-libpthread-stubs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

set -ex

cd /build
ROOT=`pwd`

pkg-config --version

Expand All @@ -15,8 +15,10 @@ export PKG_CONFIG_PATH=/tools/deps/share/pkgconfig
tar -xf libpthread-stubs-${LIBPTHREAD_STUBS_VERSION}.tar.gz
pushd libpthread-stubs-${LIBPTHREAD_STUBS_VERSION}

CFLAGS="-fPIC" ./configure \
CFLAGS="${EXTRA_TARGET_CFLAGS} -fPIC" ./configure \
--build=${BUILD_TRIPLE} \
--host=${TARGET_TRIPLE} \
--prefix=/tools/deps

make -j `nproc`
make -j `nproc` install DESTDIR=/build/out
make -j `nproc` install DESTDIR=${ROOT}/out
4 changes: 2 additions & 2 deletions cpython-unix/build-libressl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

set -ex

cd /build
ROOT=`pwd`

export PATH=/tools/${TOOLCHAIN}/bin:/tools/host/bin:$PATH

Expand All @@ -21,4 +21,4 @@ CFLAGS="${EXTRA_TARGET_CFLAGS} -fPIC" CPPFLAGS="${EXTRA_TARGET_CFLAGS} -fPIC" ./
--disable-shared

make -j `nproc`
make -j `nproc` install DESTDIR=/build/out
make -j `nproc` install DESTDIR=${ROOT}/out
11 changes: 8 additions & 3 deletions cpython-unix/build-libxcb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

set -ex

cd /build
ROOT=`pwd`

export PATH=/tools/${TOOLCHAIN}/bin:/tools/host/bin:$PATH
export PKG_CONFIG_PATH=/tools/deps/share/pkgconfig:/tools/deps/lib/pkgconfig
Expand All @@ -17,9 +17,14 @@ if [ "${CC}" = "musl-clang" ]; then
EXTRA_FLAGS="--disable-shared"
fi

CFLAGS="-fPIC" ./configure \
echo "############################################"
echo "##### ${CC}"

CFLAGS="${EXTRA_TARGET_CFLAGS} -fPIC" ./configure \
--build=${BUILD_TRIPLE} \
--host=${TARGET_TRIPLE} \
--prefix=/tools/deps \
${EXTRA_FLAGS}

make -j `nproc`
make -j `nproc` install DESTDIR=/build/out
make -j `nproc` install DESTDIR=${ROOT}/out
2 changes: 2 additions & 0 deletions cpython-unix/build-main.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ def main():
targets = {
default_target_triple,
"x86_64-unknown-linux-musl",
"aarch64-unknown-linux-gnu",
"arm-unknown-linux-gnueabihf",
}
elif sys.platform == "darwin":
host_platform = "macos"
Expand Down
18 changes: 17 additions & 1 deletion cpython-unix/build-ncurses.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,27 @@ tar -xf ncurses-${NCURSES_VERSION}.tar.gz

pushd ncurses-${NCURSES_VERSION}

patch -p1 << 'EOF'
diff --git a/configure b/configure
--- a/configure
+++ b/configure
@@ -15350,7 +15350,7 @@ echo "${ECHO_T}$with_stripping" >&6

if test "$with_stripping" = yes
then
- INSTALL_OPT_S="-s"
+ INSTALL_OPT_S="-s --strip-program=${STRIP}"
else
INSTALL_OPT_S=
fi
EOF

CFLAGS="${EXTRA_TARGET_CFLAGS} -fPIC" ./configure \
--build=${BUILD_TRIPLE} \
--host=${TARGET_TRIPLE} \
--prefix=/tools/deps \
--without-cxx \
--enable-widec
--enable-widec \
--disable-db-install
make -j ${NUM_CPUS}
make -j ${NUM_CPUS} install DESTDIR=${ROOT}/out
15 changes: 13 additions & 2 deletions cpython-unix/build-openssl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,22 @@ fi

if [ "${PYBUILD_PLATFORM}" = "macos" ]; then
OPENSSL_TARGET=darwin64-x86_64-cc
else
elif [ "${TARGET_TRIPLE}" = "x86_64-unknown-linux-gnu" ]; then
OPENSSL_TARGET=linux-x86_64
elif [ "${TARGET_TRIPLE}" = "aarch64-unknown-linux-gnu" ]; then
OPENSSL_TARGET=linux-aarch64
elif [ "${TARGET_TRIPLE}" = "arm-unknown-linux-gnueabihf" ]; then
OPENSSL_TARGET=linux-armv4
else
echo "Error: unsupported target"
exit 1
fi

/usr/bin/perl ./Configure --prefix=/tools/deps ${OPENSSL_TARGET} no-shared ${EXTRA_FLAGS}
CFLAGS="${EXTRA_TARGET_CFLAGS}" /usr/bin/perl ./Configure \
--prefix=/tools/deps \
${OPENSSL_TARGET} \
no-shared \
${EXTRA_FLAGS}

make -j ${NUM_CPUS}
make -j ${NUM_CPUS} install DESTDIR=${ROOT}/out
4 changes: 2 additions & 2 deletions cpython-unix/build-readline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

set -ex

cd /build
ROOT=`pwd`

export PATH=/tools/${TOOLCHAIN}/bin:/tools/host/bin:$PATH

Expand All @@ -22,4 +22,4 @@ CLFAGS="${EXTRA_TARGET_CFLAGS} -fPIC" CPPFLAGS="${EXTRA_TARGET_CFLAGS} -fPIC" LD
--with-curses

make -j `nproc`
make -j `nproc` install DESTDIR=/build/out
make -j `nproc` install DESTDIR=${ROOT}/out
4 changes: 3 additions & 1 deletion cpython-unix/build-sqlite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ export PATH=${TOOLS_PATH}/${TOOLCHAIN}/bin:${TOOLS_PATH}/host/bin:$PATH
tar -xf sqlite-autoconf-${SQLITE_VERSION}.tar.gz
pushd sqlite-autoconf-${SQLITE_VERSION}

CFLAGS="-fPIC" CPPFLAGS="-fPIC" ./configure \
CFLAGS="${EXTRA_TARGET_CFLAGS} -fPIC" CPPFLAGS="-fPIC" ./configure \
--build=${BUILD_TRIPLE} \
--host=${TARGET_TRIPLE} \
--prefix /tools/deps \
--disable-shared

Expand Down
2 changes: 2 additions & 0 deletions cpython-unix/build-tcl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ if [ "${PYBUILD_PLATFORM}" = "macos" ]; then
fi

CFLAGS="${CFLAGS}" CPPFLAGS="${CFLAGS}" ./configure \
--build=${BUILD_TRIPLE} \
--host=${TARGET_TRIPLE} \
--prefix=/tools/deps \
--enable-shared=no \
--enable-threads
Expand Down
4 changes: 3 additions & 1 deletion cpython-unix/build-tix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ fi

# -DUSE_INTERP_RESULT is to allow tix to use deprecated fields or something
# like that.
CFLAGS="${CFLAGS}" CPPFLAGS="${CFLAGS}" ./configure \
CFLAGS="${EXTRA_TARGET_CFLAGS} ${CFLAGS}" CPPFLAGS="${EXTRA_TARGET_CFLAGS} ${CFLAGS}" ./configure \
--build=${BUILD_TRIPLE} \
--host=${TARGET_TRIPLE} \
--prefix=/tools/deps \
--with-tcl=${TOOLS_PATH}/deps/lib \
--with-tk=${TOOLS_PATH}/deps/lib \
Expand Down
4 changes: 3 additions & 1 deletion cpython-unix/build-tk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ else
EXTRA_CONFIGURE_FLAGS="--x-includes=${TOOLS_PATH}/deps/include --x-libraries=${TOOLS_PATH}/deps/lib"
fi

CFLAGS="${CFLAGS}" CPPFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" ./configure \
CFLAGS="${EXTRA_TARGET_CFLAGS} ${CFLAGS}" CPPFLAGS="${EXTRA_TARGET_CFLAGS} ${CFLAGS}" LDFLAGS="${LDFLAGS}" ./configure \
--build=${BUILD_TRIPLE} \
--host=${TARGET_TRIPLE} \
--prefix=/tools/deps \
--with-tcl=${TOOLS_PATH}/deps/lib \
--enable-shared=no \
Expand Down
Loading