Skip to content

Commit

Permalink
Make Ghostscript build on ppc64el and arm64
Browse files Browse the repository at this point in the history
The libpng shipping with Ghostscript does not build on ppc64el and
arm64 without disabling certain optimizations. For ppc64el this is
already solved in the Ghostscript GIT and part of the upcoming 9.53:

http://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff;h=1c9bd8e0aa4
https://bugs.ghostscript.com/show_bug.cgi?id=702236

For arm64 there is a similar problem but Ghostscript developers seem
not yet aware of it. A hint for a solution can be found in another
project though:

imagemin/optipng-bin#97
  • Loading branch information
tillkamppeter committed Jun 14, 2020
1 parent bd6c58a commit 2f8765c
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 3 deletions.
45 changes: 45 additions & 0 deletions patches/ghostscript-disable-ppc-optimisations-in-libpng.patch
@@ -0,0 +1,45 @@
From: Chris Liddell <chris.liddell@artifex.com>
Date: Tue, 24 Mar 2020 15:19:23 +0000 (+0000)
Subject: Disable PPC optimisations in libpng
X-Git-Tag: ghostpdl-9.52-test-base-1~2
X-Git-Url: http://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff_plain;h=1c9bd8e0aa4

Disable PPC optimisations in libpng

Since we don't include the libpng source file with the PowerPC optimizations
in our build, and it only applies to reading, which we don't rely on, just
disable calling the optimizations.

Cures a linker error on PowerPCle platforms
---

diff --git a/configure.ac b/configure.ac
index 638c56641..5be1eac6a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1252,7 +1252,24 @@ else
SHARE_LIBPNG=0
LIBPNGDIR=$srcdir/libpng
PNGDEVS="$PNGDEVS_ALL"
- else
+ case $host in
+ *powerpc*)
+ # Building on PPC with gcc, disable libpng's PPC specific
+ # optimizations: we don't include the source file for it
+ # and it only applies to reading, which we don't use.
+ if test $GCC = yes; then
+ CFLAGS="$CFLAGS -DPNG_POWERPC_VSX_OPT=0"
+ fi
+ ;;
+ *arm64*|*aarch64*)
+ # Building on arm64 with gcc, disable libpng's neon
+ # optimizations.
+ if test $GCC = yes; then
+ CFLAGS="$CFLAGS -DPNG_ARM_NEON_OPT=0"
+ fi
+ ;;
+ esac
+ else
AC_MSG_RESULT([no])
AC_CHECK_LIB(png, png_create_write_struct, [
AC_CHECK_HEADERS(png.h, [
11 changes: 8 additions & 3 deletions snapcraft.yaml
Expand Up @@ -115,7 +115,7 @@ apps:
plugs: [home, system-config]

parts:
cups-patches:
patches:
plugin: dump
source: patches
organize:
Expand Down Expand Up @@ -202,7 +202,7 @@ parts:
- -usr/share/doc
- -usr/share/doc-base
- -usr/share/lintian
after: [cups-patches]
after: [patches]
qpdf:
source: https://github.com/qpdf/qpdf/releases/download/release-qpdf-10.0.1/qpdf-10.0.1.tar.gz
plugin: autotools
Expand All @@ -228,6 +228,11 @@ parts:
ghostscript:
source: https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs952/ghostscript-9.52.tar.gz
plugin: autotools
override-build: |
set -eux
patch -p1 < $SNAPCRAFT_STAGE/patches/ghostscript-disable-ppc-optimisations-in-libpng.patch
./autogen.sh
snapcraftctl build
configflags:
- --without-x
- --disable-gtk
Expand Down Expand Up @@ -259,7 +264,7 @@ parts:
- -snap/cups
organize:
snap/cups/current/share: share
after: [cups]
after: [patches, cups]
cups-filters:
source: http://www.openprinting.org/download/cups-filters/cups-filters-1.27.5.tar.xz
plugin: autotools
Expand Down

0 comments on commit 2f8765c

Please sign in to comment.