Skip to content

Commit

Permalink
Add loongarch64 (#103)
Browse files Browse the repository at this point in the history
* initial changes to add loongarch64

* drop python2

* break system packages

* update zig

* drop patches

* loongarch64 openssl

* add gdbm-1.24

* gdbm-1.24

* use libgpg-error-1.50

* use libgcrypt-1.11.0

* use local config.guess, config.sub

* add xtrans-dev package

* chmod +x

* put interpreter under /lib64

* break system packages

* add loongarch64 to installer

* break system packages

* add package required for autogen
  • Loading branch information
bjia56 authored Oct 17, 2024
1 parent 47d8b3c commit 16eec93
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 19 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/build_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
platforms:
required: true
type: string
default: "linux-x86_64,linux-aarch64,linux-i386,linux-arm,linux-riscv64,linux-s390x,macos,windows,cosmo,freebsd13-x86_64,freebsd14-x86_64"
default: "linux-x86_64,linux-aarch64,linux-i386,linux-arm,linux-riscv64,linux-loongarch64,linux-s390x,macos,windows,cosmo,freebsd13-x86_64,freebsd14-x86_64"
buildsystem_branch:
required: false
type: string
Expand Down Expand Up @@ -52,25 +52,26 @@ env:
DEBUG_CI: ${{ inputs.debug }}
VERBOSE_CI: ${{ inputs.verbose }}
PORTABLE_PYTHON_BUILDSYSTEM_BRANCH: ${{ inputs.buildsystem_branch || 'portable-python' }}
image_map: '{"x86_64": "amd64/ubuntu:18.04", "i386": "i386/ubuntu:18.04", "aarch64": "arm64v8/ubuntu:18.04", "arm": "arm32v7/debian:bullseye", "riscv64": "riscv64/debian:sid", "s390x": "s390x/debian:bullseye"}'
image_map: '{"x86_64": "amd64/ubuntu:18.04", "i386": "i386/ubuntu:18.04", "aarch64": "arm64v8/ubuntu:18.04", "arm": "arm32v7/debian:bullseye", "riscv64": "riscv64/debian:sid", "loongarch64": "loongarch64/debian:sid", "s390x": "s390x/debian:bullseye"}'
freebsd_release_map: '{"14": "14.0", "13": "13.2"}'

jobs:
build_linux:
name: Linux ${{ inputs.python_version }} ${{ matrix.arch }} ${{ matrix.distribution }}
if: ${{ contains(inputs.platforms, 'linux') }}
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
arch: [x86_64, i386, aarch64, arm, riscv64, s390x]
arch: [x86_64, i386, aarch64, arm, riscv64, s390x, loongarch64]
distribution: [full, headless]
exclude:
- arch: ${{ !contains(inputs.platforms, 'linux-x86_64') && 'x86_64' || '' }}
- arch: ${{ !contains(inputs.platforms, 'linux-i386') && 'i386' || '' }}
- arch: ${{ !contains(inputs.platforms, 'linux-aarch64') && 'aarch64' || '' }}
- arch: ${{ !contains(inputs.platforms, 'linux-arm') && 'arm' || '' }}
- arch: ${{ !contains(inputs.platforms, 'linux-riscv64') && 'riscv64' || '' }}
- arch: ${{ !contains(inputs.platforms, 'linux-loongarch64') && 'loongarch64' || '' }}
- arch: ${{ !contains(inputs.platforms, 'linux-s390x') && 's390x' || '' }}

steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_python_on_branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
run_tests: ${{ inputs.run_tests || false }}
debug: ${{ inputs.debug || false }}
verbose: ${{ inputs.verbose || false }}
platforms: "linux-x86_64,linux-aarch64,linux-i386,linux-arm,linux-riscv64,linux-s390x,macos,windows,cosmo,freebsd13-x86_64,freebsd14-x86_64"
platforms: "linux-x86_64,linux-aarch64,linux-i386,linux-arm,linux-riscv64,linux-loongarch64,linux-s390x,macos,windows,cosmo,freebsd13-x86_64,freebsd14-x86_64"
buildsystem_branch: ${{ inputs.buildsystem_branch || 'portable-python' }}

graalpy:
Expand Down
1 change: 1 addition & 0 deletions checksums/gdbm-1.24.tar.gz.sha256
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
695e9827fdf763513f133910bc7e6cfdb9187943a4fec943e57449723d2b8dbf gdbm-1.24.tar.gz
1 change: 1 addition & 0 deletions checksums/libgcrypt-1.11.0.tar.bz2.sha256
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
09120c9867ce7f2081d6aaa1775386b98c2f2f246135761aae47d81f58685b9c libgcrypt-1.11.0.tar.bz2
1 change: 1 addition & 0 deletions checksums/libgpg-error-1.50.tar.bz2.sha256
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
69405349e0a633e444a28c5b35ce8f14484684518a508dc48a089992fe93e20a libgpg-error-1.50.tar.bz2
2 changes: 2 additions & 0 deletions installers/nodejs/src/cpython.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ const DL_ARCH = (() => {
return "x86_64";
case "arm64":
return "aarch64";
case "loong64":
return "loongarch64";
}

return arch();
Expand Down
35 changes: 21 additions & 14 deletions scripts/build_linux_zig.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export DEBIAN_FRONTEND=noninteractive
sudo apt update
sudo apt -y install \
wget build-essential pkg-config autoconf git patch \
python2 python3 python3-pip clang qemu-user-static \
gettext bison libtool autopoint gperf ncurses-bin xutils-dev
python3 python3-pip clang qemu-user-static \
gettext bison libtool autopoint gperf ncurses-bin xutils-dev xtrans-dev libltdl-dev
case "$ARCH" in
x86_64)
sudo apt -y install libc6-amd64-cross
Expand All @@ -35,6 +35,10 @@ case "$ARCH" in
sudo apt -y install libc6-armhf-cross
sudo ln -s /usr/arm-linux-gnueabihf/lib/ld-linux-armhf.so.3 /lib/ld-linux-armhf.so.3
;;
loongarch64)
sudo apt -y install libc6-loong64-cross
sudo ln -s /usr/loongarch64-linux-gnu/lib/ld-linux-loongarch-lp64d.so.1 /lib64/ld-linux-loongarch-lp64d.so.1
;;
riscv64)
sudo apt -y install libc6-riscv64-cross
sudo ln -s /usr/riscv64-linux-gnu/lib/ld-linux-riscv64-lp64d.so.1 /lib/ld-linux-riscv64-lp64d.so.1
Expand All @@ -46,9 +50,9 @@ case "$ARCH" in
sudo ln -s /usr/s390x-linux-gnu/lib/ld64.so.1 /lib/ld64.so.1
;;
esac
sudo pip install https://github.com/mesonbuild/meson/archive/2baae24.zip ninja cmake==3.28.4
sudo pip install https://github.com/mesonbuild/meson/archive/2baae24.zip ninja cmake==3.28.4 --break-system-packages
if [[ "${ARCH}" == "riscv64" ]]; then
sudo pip install patchelf==0.15.0.0
sudo pip install patchelf==0.15.0.0 --break-system-packages
fi

export ZIG_FLAGS=""
Expand Down Expand Up @@ -96,6 +100,8 @@ else
if [[ "${ARCH}" == "riscv64" ]]; then
export ZIG_FLAGS="-target riscv64-linux-gnu.2.27"
export CFLAGS="-Wl,--undefined-version ${CFLAGS}"
elif [[ "${ARCH}" == "loongarch64" ]]; then
export ZIG_FLAGS="-target loongarch64-linux-gnu.2.36"
elif [[ "${ARCH}" == "s390x" ]]; then
export ZIG_FLAGS="-target s390x-linux-gnu.2.19"
else
Expand All @@ -104,12 +110,7 @@ else
export CHOST=${ARCH}-linux-gnu
fi

# apply some zig patches
#cd $(dirname $(which zig))
#for patchfile in ${WORKDIR}/zigshim/patches/*.patch; do
# patch -p1 < $patchfile
#done
#cd ${WORKDIR}
cd ${WORKDIR}

echo "::endgroup::"
########
Expand Down Expand Up @@ -144,6 +145,8 @@ elif [[ "${ARCH}" == "i386" ]]; then
CFLAGS="${CFLAGS} -fgnuc-version=0 -D__STDC_NO_ATOMICS__" ./Configure linux-x86 no-shared --prefix=${DEPSDIR} --openssldir=${DEPSDIR}
elif [[ "${ARCH}" == "riscv64" ]]; then
CFLAGS="${CFLAGS} -fgnuc-version=0 -D__STDC_NO_ATOMICS__" ./Configure linux-generic64 no-shared --prefix=${DEPSDIR} --openssldir=${DEPSDIR}
elif [[ "${ARCH}" == "loongarch64" ]]; then
./Configure linux64-loongarch64 no-shared --prefix=${DEPSDIR} --openssldir=${DEPSDIR}
elif [[ "${ARCH}" == "s390x" ]]; then
./Configure linux64-s390x no-shared --prefix=${DEPSDIR} --openssldir=${DEPSDIR}
else
Expand Down Expand Up @@ -304,7 +307,7 @@ echo "::endgroup::"
echo "::group::gdbm"
cd ${BUILDDIR}

download_verify_extract gdbm-1.23.tar.gz
download_verify_extract gdbm-1.24.tar.gz
cd gdbm*
./configure --host=${CHOST} --enable-libgdbm-compat --prefix=${DEPSDIR}
make -j4
Expand Down Expand Up @@ -345,7 +348,7 @@ echo "::endgroup::"
echo "::group::libgcrypt"
cd ${BUILDDIR}

download_verify_extract libgpg-error-1.47.tar.bz2
download_verify_extract libgpg-error-1.50.tar.bz2
cd libgpg-error*
./configure --host=${CHOST} --prefix=${DEPSDIR}
make -j4
Expand All @@ -354,7 +357,7 @@ install_license ./COPYING.LIB

cd ${BUILDDIR}

download_verify_extract libgcrypt-1.10.3.tar.bz2
download_verify_extract libgcrypt-1.11.0.tar.bz2
cd libgcrypt*
LDFLAGS="${LDFLAGS} -Wl,--undefined-version" ./configure --disable-asm --host=${CHOST} --prefix=${DEPSDIR}
make -j4
Expand Down Expand Up @@ -398,6 +401,10 @@ cd ${BUILDDIR}

download_verify_extract fontconfig-2.15.0.tar.gz
cd fontconfig*
if [[ "${ARCH}" == "loongarch64" ]]; then
# remove this once upstream fontconfig updates config.*
cp /usr/share/misc/config.* .
fi
LDFLAGS="${LDFLAGS} -lxml2" ./configure --host=${CHOST} --enable-static --disable-shared --enable-libxml2 --disable-cache-build --prefix=${DEPSDIR}
make -j4
make install
Expand Down Expand Up @@ -645,7 +652,7 @@ echo "::endgroup::"
echo "::group::Compress output"
cd ${BUILDDIR}

python3 -m pip install pyclean
python3 -m pip install pyclean --break-system-packages
python3 -m pyclean -v python-install
mv python-install python-${DISTRIBUTION}-${PYTHON_FULL_VER}-${PLATFORM}-${ARCH}
tar -czf ${WORKDIR}/python-${DISTRIBUTION}-${PYTHON_FULL_VER}-${PLATFORM}-${ARCH}.tar.gz python-${DISTRIBUTION}-${PYTHON_FULL_VER}-${PLATFORM}-${ARCH}
Expand Down
4 changes: 4 additions & 0 deletions scripts/qemu_loongarch64_interpreter
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
# this interpreter shim is used by cmake to run platform
# detection programs
LD_LIBRARY_PATH=/usr/loongarch64-linux-gnu/lib qemu-loongarch64-static "$@"

0 comments on commit 16eec93

Please sign in to comment.