diff mbox

gnu: Add optipng.

Message ID 20160925202832.17166-2-arunisaac@systemreboot.net
State New
Headers show

Commit Message

Arun Sept. 25, 2016, 8:28 p.m. UTC
* gnu/packages/image.scm (optipng): New variable.
---
 gnu/packages/image.scm | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

Comments

Kei Yamashita Sept. 25, 2016, 9:03 p.m. UTC | #1
Arun Isaac <arunisaac@systemreboot.net> writes:

> * gnu/packages/image.scm (optipng): New variable.
> ---
>  gnu/packages/image.scm | 33 +++++++++++++++++++++++++++++++++
>  1 file changed, 33 insertions(+)
>
> diff --git a/gnu/packages/image.scm b/gnu/packages/image.scm
> index 931cad1..4039c1a 100644
> --- a/gnu/packages/image.scm
> +++ b/gnu/packages/image.scm
> @@ -10,6 +10,7 @@
>  ;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
>  ;;; Copyright © 2016 Tobias Geerinckx-Rice <me@tobias.gr>
>  ;;; Copyright © 2016 Eric Bavier <bavier@member.fsf.org>
> +;;; Copyright © 2016 Arun Isaac <arunisaac@systemreboot.net>
>  ;;;
>  ;;; This file is part of GNU Guix.
>  ;;;
> @@ -932,3 +933,35 @@ statistical tests.")
>  all included libraries only the image loading and decoding library is
>  installed as @code{stb_image}.")
>        (license license:public-domain))))
> +
> +(define-public optipng
> +  (package
> +    (name "optipng")
> +    (version "0.7.6")
> +    (source
> +     (origin
> +       (method url-fetch)
> +       (uri (string-append "http://prdownloads.sourceforge.net/optipng/optipng-"
> +                           version ".tar.gz"))
> +       (sha256
> +        (base32
> +         "105yk5qykvhiahzag67gm36s2kplxf6qn5hay02md0nkrcgn6w28"))))
> +    (build-system gnu-build-system)
> +    (inputs
> +     `(("zlib" ,zlib)))
> +    (arguments
> +     '(#:phases
> +       (modify-phases %standard-phases
> +         ;; configure script does not accept arguments CONFIG_SHELL and SHELL
> +         (replace 'configure
> +           (lambda* (#:key outputs #:allow-other-keys)
> +             (zero? (system* "sh" "configure"
> +                             (string-append "--prefix=" (assoc-ref outputs "out")))))))))
> +    (synopsis "Optimizer that recompresses PNG image files to a
> +smaller size")
> +    (description "OptiPNG is a PNG optimizer that recompresses image
> +files to a smaller size, without losing any information.  This program
> +also converts external formats (BMP, GIF, PNM and TIFF) to optimized
> +PNG, and performs PNG integrity checks and corrections.")
> +    (home-page "http://optipng.sourceforge.net/")
> +    (license license:zlib)))

Linting and reproducibility are clean here!

Pushed as 93117227034666db18c8b0c7fd89cca72a3eeca8.
Leo Famulari Sept. 26, 2016, 5:59 p.m. UTC | #2
On Sun, Sep 25, 2016 at 05:03:43PM -0400, Kei Kebreau wrote:
> Arun Isaac <arunisaac@systemreboot.net> writes:
> 
> > * gnu/packages/image.scm (optipng): New variable.

It failed to build on armhf:
https://hydra.gnu.org/build/1479396

Log excerpt:

make[2]: Leaving directory '/tmp/nix-build-optipng-0.7.6.drv-0/optipng-0.7.6/src/pngxtern'
gcc -c  -O2 -Wall -Wextra -I../cexcept -I../zlib -I../libpng -I../opngreduc -I../pngxtern -o optipng.o optipng.c
gcc -c  -O2 -Wall -Wextra -I../cexcept -I../zlib -I../libpng -I../opngreduc -I../pngxtern -o optim.o optim.c
gcc -s -o optipng optipng.o optim.o bitset.o ratio.o osys.o wildargs.o ../opngreduc/libopngreduc.a ../pngxtern/libpngxtern.a ../libpng/libpng.a ../zlib/libz.a ../gifread/libgifread.a ../pnmio/libpnmio.a ../minitiff/libminitiff.a   -lm 
../libpng/libpng.a(pngrutil.o): In function `png_read_filter_row':
pngrutil.c:(.text+0x13bc): undefined reference to `png_init_filter_functions_neon'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:99: optipng] Error 1
make[1]: Leaving directory '/tmp/nix-build-optipng-0.7.6.drv-0/optipng-0.7.6/src/optipng'
make: *** [Makefile:2: all] Error 2
Arun Sept. 26, 2016, 7:21 p.m. UTC | #3
> make[2]: Leaving directory '/tmp/nix-build-optipng-0.7.6.drv-0/optipng-0.7.6/src/pngxtern'
> gcc -c  -O2 -Wall -Wextra -I../cexcept -I../zlib -I../libpng -I../opngreduc -I../pngxtern -o optipng.o optipng.c
> gcc -c  -O2 -Wall -Wextra -I../cexcept -I../zlib -I../libpng -I../opngreduc -I../pngxtern -o optim.o optim.c
> gcc -s -o optipng optipng.o optim.o bitset.o ratio.o osys.o wildargs.o ../opngreduc/libopngreduc.a ../pngxtern/libpngxtern.a ../libpng/libpng.a ../zlib/libz.a ../gifread/libgifread.a ../pnmio/libpnmio.a ../minitiff/libminitiff.a   -lm 
> ../libpng/libpng.a(pngrutil.o): In function `png_read_filter_row':
> pngrutil.c:(.text+0x13bc): undefined reference to `png_init_filter_functions_neon'
> collect2: error: ld returned 1 exit status
> make[1]: *** [Makefile:99: optipng] Error 1
> make[1]: Leaving directory '/tmp/nix-build-optipng-0.7.6.drv-0/optipng-0.7.6/src/optipng'
> make: *** [Makefile:2: all] Error 2

This seems related: https://sourceforge.net/p/libpng/bugs/230/
The bug was apparently fixed in libpng-1.6.15, and guix is still on
1.5.26. Could this be the issue?

How do I reproduce the armhf-linux build on my x86_64 system? I tried
`guix build --fallback --target=armhf-linux optipng`, but it failed with
the following error message while building binutils. Am I missing
something?

starting phase `configure'
source directory: "/tmp/guix-build-binutils-cross-armhf-linux-2.25.1.drv-0/binutils-2.25.1" (relative from build: ".")
build directory: "/tmp/guix-build-binutils-cross-armhf-linux-2.25.1.drv-0/binutils-2.25.1"
configure flags: ("CONFIG_SHELL=/gnu/store/ykzwykkvr2c80rw4l1qh3mvfdkl7jibi-bash-4.3.42/bin/bash" "SHELL=/gnu/store/ykzwykkvr2c80rw4l1qh3mvfdkl7jibi-bash-4.3.42/bin/bash" "--prefix=/gnu/store/cmk97w8d9hzab406g70b33kh3zbgllnh-binutils-cross-armhf-linux-2.25.1" "--enable-fast-install" "--build=x86_64-unknown-linux-gnu" "--target=armhf-linux" "--with-sysroot=/" "LDFLAGS=-static-libgcc" "--with-lib-path=/no-ld-lib-path" "--disable-werror" "--enable-install-libbfd" "--enable-deterministic-archives")
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... Invalid configuration `armhf-linux': machine `armhf' not recognized
configure: error: /gnu/store/ykzwykkvr2c80rw4l1qh3mvfdkl7jibi-bash-4.3.42/bin/bash ./config.sub armhf-linux failed
phase `configure' failed after 0.4 seconds
builder for `/gnu/store/zrr3b4gz2gh4m4fzpilj6zw7aw8r8c1h-binutils-cross-armhf-linux-2.25.1.drv' failed with exit code 1
@ build-failed /gnu/store/zrr3b4gz2gh4m4fzpilj6zw7aw8r8c1h-binutils-cross-armhf-linux-2.25.1.drv - 1 builder for `/gnu/store/zrr3b4gz2gh4m4fzpilj6zw7aw8r8c1h-binutils-cross-armhf-linux-2.25.1.drv' failed with exit code 1
cannot build derivation `/gnu/store/10r60df8navx9fprmlzvvv55zws8xj1x-optipng-0.7.6.drv': 1 dependencies couldn't be built
guix build: error: build failed: build of `/gnu/store/10r60df8navx9fprmlzvvv55zws8xj1x-optipng-0.7.6.drv' failed
Danny Milosavljevic Sept. 26, 2016, 7:34 p.m. UTC | #4
Hi Leo,

On Mon, 26 Sep 2016 13:59:58 -0400
Leo Famulari <leo@famulari.name> wrote:

> gcc -s -o optipng optipng.o optim.o bitset.o ratio.o osys.o wildargs.o ../opngreduc/libopngreduc.a ../pngxtern/libpngxtern.a ../libpng/libpng.a ../zlib/libz.a ../gifread/libgifread.a ../pnmio/libpnmio.a ../minitiff/libminitiff.a   -lm 
> ../libpng/libpng.a(pngrutil.o): In function `png_read_filter_row':
> pngrutil.c:(.text+0x13bc): undefined reference to `png_init_filter_functions_neon'
> collect2: error: ld returned 1 exit status
> make[1]: *** [Makefile:99: optipng] Error 1
> make[1]: Leaving directory '/tmp/nix-build-optipng-0.7.6.drv-0/optipng-0.7.6/src/optipng'
> make: *** [Makefile:2: all] Error 2

Looks like a problem internal to libpng.

There's a configure option '--enable-arm-neon=api' in libpng. If we supported only ARM with NEON SIMD extension then we could build libpng with it. Do we?

Debian says on their https://wiki.debian.org/ArmHardFloatPort#NEON that one shouldn't require NEON since Marvell Dove and NVidia Tegra2 (?!?!?!) don't implement it.

There's also a configure option '--enable-arm-neon=check' which would check whether NEON works at runtime - but according to configure, it's not well-supported. What does this mean?
Leo Famulari Sept. 26, 2016, 9:22 p.m. UTC | #5
On Tue, Sep 27, 2016 at 12:51:59AM +0530, Arun Isaac wrote:
> 
> > make[2]: Leaving directory '/tmp/nix-build-optipng-0.7.6.drv-0/optipng-0.7.6/src/pngxtern'
> > gcc -c  -O2 -Wall -Wextra -I../cexcept -I../zlib -I../libpng -I../opngreduc -I../pngxtern -o optipng.o optipng.c
> > gcc -c  -O2 -Wall -Wextra -I../cexcept -I../zlib -I../libpng -I../opngreduc -I../pngxtern -o optim.o optim.c
> > gcc -s -o optipng optipng.o optim.o bitset.o ratio.o osys.o wildargs.o ../opngreduc/libopngreduc.a ../pngxtern/libpngxtern.a ../libpng/libpng.a ../zlib/libz.a ../gifread/libgifread.a ../pnmio/libpnmio.a ../minitiff/libminitiff.a   -lm 
> > ../libpng/libpng.a(pngrutil.o): In function `png_read_filter_row':
> > pngrutil.c:(.text+0x13bc): undefined reference to `png_init_filter_functions_neon'
> > collect2: error: ld returned 1 exit status
> > make[1]: *** [Makefile:99: optipng] Error 1
> > make[1]: Leaving directory '/tmp/nix-build-optipng-0.7.6.drv-0/optipng-0.7.6/src/optipng'
> > make: *** [Makefile:2: all] Error 2
> 
> This seems related: https://sourceforge.net/p/libpng/bugs/230/
> The bug was apparently fixed in libpng-1.6.15, and guix is still on
> 1.5.26. Could this be the issue?

We have libpng 1.6.25 on core-updates. So this question will be answered
eventually.
diff mbox

Patch

diff --git a/gnu/packages/image.scm b/gnu/packages/image.scm
index 931cad1..4039c1a 100644
--- a/gnu/packages/image.scm
+++ b/gnu/packages/image.scm
@@ -10,6 +10,7 @@ 
 ;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
 ;;; Copyright © 2016 Tobias Geerinckx-Rice <me@tobias.gr>
 ;;; Copyright © 2016 Eric Bavier <bavier@member.fsf.org>
+;;; Copyright © 2016 Arun Isaac <arunisaac@systemreboot.net>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -932,3 +933,35 @@  statistical tests.")
 all included libraries only the image loading and decoding library is
 installed as @code{stb_image}.")
       (license license:public-domain))))
+
+(define-public optipng
+  (package
+    (name "optipng")
+    (version "0.7.6")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "http://prdownloads.sourceforge.net/optipng/optipng-"
+                           version ".tar.gz"))
+       (sha256
+        (base32
+         "105yk5qykvhiahzag67gm36s2kplxf6qn5hay02md0nkrcgn6w28"))))
+    (build-system gnu-build-system)
+    (inputs
+     `(("zlib" ,zlib)))
+    (arguments
+     '(#:phases
+       (modify-phases %standard-phases
+         ;; configure script does not accept arguments CONFIG_SHELL and SHELL
+         (replace 'configure
+           (lambda* (#:key outputs #:allow-other-keys)
+             (zero? (system* "sh" "configure"
+                             (string-append "--prefix=" (assoc-ref outputs "out")))))))))
+    (synopsis "Optimizer that recompresses PNG image files to a
+smaller size")
+    (description "OptiPNG is a PNG optimizer that recompresses image
+files to a smaller size, without losing any information.  This program
+also converts external formats (BMP, GIF, PNM and TIFF) to optimized
+PNG, and performs PNG integrity checks and corrections.")
+    (home-page "http://optipng.sourceforge.net/")
+    (license license:zlib)))