Skip to content

Commit

Permalink
Add linux-ppc64 (little endian) as supported platform (#242)
Browse files Browse the repository at this point in the history
  • Loading branch information
sumitd2 authored Jul 17, 2024
1 parent a34823b commit 6651f42
Show file tree
Hide file tree
Showing 9 changed files with 148 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
- 'linux-armv7'
- 'linuxmusl-x64'
- 'linuxmusl-arm64v8'
- 'linux-ppc64le'
- 'linux-s390x'
- 'wasm32'
- 'win32-ia32'
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ the same shared libraries within multiple containers.
* [ARMv7-A glibc](platforms/linux-armv7/Dockerfile)
* [ARM64v8-A glibc](platforms/linux-arm64v8/Dockerfile)
* [ARM64v8-A musl](platforms/linuxmusl-arm64v8/Dockerfile)
* [ppc64le glibc](platforms/linux-ppc64le/Dockerfile)
* [s390x glibc](platforms/linux-s390x/Dockerfile)

### Windows
Expand Down
3 changes: 2 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ if [ $# -lt 1 ]; then
echo "- linux-armv7"
echo "- linux-arm64v8"
echo "- linuxmusl-arm64v8"
echo "- linux-ppc64le"
echo "- linux-s390x"
echo "- darwin-x64"
echo "- darwin-arm64v8"
Expand Down Expand Up @@ -101,7 +102,7 @@ for flavour in win32-ia32 win32-x64 win32-arm64v8; do
done

# Linux (x64, ARMv6, ARMv7, ARM64v8)
for flavour in linux-x64 linuxmusl-x64 linux-armv6 linux-armv7 linux-arm64v8 linuxmusl-arm64v8 linux-s390x; do
for flavour in linux-x64 linuxmusl-x64 linux-armv6 linux-armv7 linux-arm64v8 linuxmusl-arm64v8 linux-ppc64le linux-s390x; do
if [ $PLATFORM = "all" ] || [ $PLATFORM = $flavour ]; then
echo "Building $flavour..."
docker build -t vips-dev-$flavour platforms/$flavour
Expand Down
42 changes: 42 additions & 0 deletions npm/linux-ppc64/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "@img/sharp-libvips-linux-ppc64",
"version": "1.0.2",
"description": "Prebuilt libvips and dependencies for use with sharp on Linux (glibc) ppc64le",
"author": "Lovell Fuller <[email protected]>",
"homepage": "https://sharp.pixelplumbing.com",
"repository": {
"type": "git",
"url": "git+https://github.com/lovell/sharp-libvips.git",
"directory": "npm/linux-ppc64"
},
"license": "LGPL-3.0-or-later",
"funding": {
"url": "https://opencollective.com/libvips"
},
"preferUnplugged": true,
"publishConfig": {
"access": "public"
},
"files": [
"lib",
"versions.json"
],
"exports": {
"./lib": "./lib/index.js",
"./package": "./package.json",
"./versions": "./versions.json"
},
"type": "commonjs",
"config": {
"glibc": ">=2.31"
},
"os": [
"linux"
],
"libc": [
"glibc"
],
"cpu": [
"ppc64"
]
}
1 change: 1 addition & 0 deletions npm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"linux-arm64",
"linuxmusl-arm64",
"linuxmusl-x64",
"linux-ppc64",
"linux-s390x",
"linux-x64",
"win32-ia32",
Expand Down
9 changes: 8 additions & 1 deletion npm/populate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ CURL="curl --silent --location"

download_extract() {
PLATFORM="$1"
PACKAGE="${1%v[68]}" # remove ARM version
case $1 in
*ppc64le)
PACKAGE="${1%??}" # package directory is named as npm/linux-ppc64
;;
*)
PACKAGE="${1%v[68]}" # remove ARM version
;;
esac
echo "$PLATFORM -> $PACKAGE"
rm -rf "npm/$PACKAGE/include" "npm/$PACKAGE/lib"
$CURL \
Expand Down
55 changes: 55 additions & 0 deletions platforms/linux-ppc64le/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
FROM debian:bullseye
LABEL maintainer="Lovell Fuller <[email protected]>"

# Create Debian 11 (glibc 2.31) container suitable for cross-compiling Linux ppc64le binaries

# Path settings
ENV \
RUSTUP_HOME="/usr/local/rustup" \
CARGO_HOME="/usr/local/cargo" \
PATH="/usr/local/cargo/bin:$PATH"

# Build dependencies
RUN \
apt-get update && \
apt-get install -y curl && \
dpkg --add-architecture ppc64el && \
apt-get install -y \
autoconf \
autopoint \
cmake \
crossbuild-essential-ppc64el \
gettext \
git \
gperf \
jq \
libssl-dev \
libtool \
ninja-build \
pkg-config \
python3-packaging \
python3-pip \
&& \
curl https://sh.rustup.rs -sSf | sh -s -- -y \
--no-modify-path \
--profile minimal \
&& \
rustup target add powerpc64le-unknown-linux-gnu && \
cargo install cargo-c && \
pip3 install meson tomli

# Handy for debugging the compiled targets in Highway (hwy_list_targets)
#RUN apt-get install -y qemu-user-static
#ENV QEMU_LD_PREFIX="/usr/powerpc64le-linux-gnu"

# Compiler settings
ENV \
PKG_CONFIG="powerpc64le-linux-gnu-pkg-config --static" \
PLATFORM="linux-ppc64le" \
CHOST="powerpc64le-linux-gnu" \
RUST_TARGET="powerpc64le-unknown-linux-gnu" \
FLAGS="" \
MESON="--cross-file=/root/meson.ini"

COPY Toolchain.cmake /root/
COPY meson.ini /root/
15 changes: 15 additions & 0 deletions platforms/linux-ppc64le/Toolchain.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_SYSTEM_PROCESSOR ppc64le)

SET(CMAKE_C_COMPILER powerpc64le-linux-gnu-gcc)
SET(CMAKE_CXX_COMPILER powerpc64le-linux-gnu-g++)
SET(CMAKE_AR powerpc64le-linux-gnu-gcc-ar)
SET(CMAKE_STRIP powerpc64le-linux-gnu-gcc-strip)
SET(CMAKE_RANLIB powerpc64le-linux-gnu-gcc-ranlib)

#SET(CMAKE_CROSSCOMPILING_EMULATOR qemu-ppc64le-static)

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
23 changes: 23 additions & 0 deletions platforms/linux-ppc64le/meson.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[host_machine]
system = 'linux'
cpu_family = 'ppc64'
cpu = 'powerpc64le'
endian = 'little'

[binaries]
c = 'powerpc64le-linux-gnu-gcc'
cpp = 'powerpc64le-linux-gnu-g++'
ar = 'powerpc64le-linux-gnu-gcc-ar'
nm = 'powerpc64le-linux-gnu-gcc-nm'
ld = 'powerpc64le-linux-gnu-gcc-ld'
strip = 'powerpc64le-linux-gnu-strip'
ranlib = 'powerpc64le-linux-gnu-gcc-ranlib'
#exe_wrapper = 'qemu-ppc64le-static'

[built-in options]
libdir = 'lib'
datadir = '/usr/share'
localedir = '/usr/share/locale'
sysconfdir = '/etc'
localstatedir = '/var'
wrap_mode = 'nofallback'

0 comments on commit 6651f42

Please sign in to comment.