openexr, ilmbase: Fix compilation on non-glibc.

Tested with musl.

I PRd the patch upstream: https://github.com/AcademySoftwareFoundation/openexr/pull/798
This commit is contained in:
Niklas Hambüchen 2020-07-30 02:35:18 +02:00
parent 7fd5059f58
commit d9393731e6
2 changed files with 34 additions and 2 deletions

View File

@ -1,4 +1,5 @@
{ stdenv { stdenv
, lib
, buildPackages , buildPackages
, cmake , cmake
, libtool , libtool
@ -20,7 +21,11 @@ stdenv.mkDerivation rec {
nativeBuildInputs = [ cmake libtool ]; nativeBuildInputs = [ cmake libtool ];
depsBuildBuild = [ buildPackages.stdenv.cc ]; depsBuildBuild = [ buildPackages.stdenv.cc ];
patches = [ ./cross.patch ]; patches = [
./cross.patch
] ++ lib.optionals (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.libc != "glibc") [
openexr.non_glibc_fpstate_patch # see description of this patch in `openexr`
];
# fails 1 out of 1 tests with # fails 1 out of 1 tests with
# "lt-ImathTest: testBoxAlgo.cpp:892: void {anonymous}::boxMatrixTransform(): Assertion `b21 == b2' failed" # "lt-ImathTest: testBoxAlgo.cpp:892: void {anonymous}::boxMatrixTransform(): Assertion `b21 == b2' failed"

View File

@ -4,10 +4,24 @@
, fetchFromGitHub , fetchFromGitHub
, zlib , zlib
, ilmbase , ilmbase
, fetchpatch , fetchpatch
, cmake , cmake
, libtool , libtool
}: }:
let
non_glibc_fpstate_patch =
# Fix ilmbase/openexr using glibc-only fpstate.
# Found via https://git.alpinelinux.org/aports/tree/community/openexr/10-musl-_fpstate.patch?id=80d9611b7b8e406a554c6f511137e03ff26acbae,
# TODO Remove when https://github.com/AcademySoftwareFoundation/openexr/pull/798 is merged and available.
# Remove it from `ilmbase` as well then.
(fetchpatch {
name = "ilmbase-musl-_fpstate.patch.patch";
url = "https://raw.githubusercontent.com/void-linux/void-packages/80bbc168faa25448bd3399f4df331b836e74b85c/srcpkgs/ilmbase/patches/musl-_fpstate.patch";
sha256 = "0appzbs9pd6dia5pzxmrs9ww35shlxi329ks6lchwzw4f2a81arz";
});
in
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
pname = "openexr"; pname = "openexr";
version = "2.4.1"; version = "2.4.1";
@ -23,8 +37,21 @@ stdenv.mkDerivation rec {
nativeBuildInputs = [ cmake libtool ]; nativeBuildInputs = [ cmake libtool ];
propagatedBuildInputs = [ ilmbase zlib ]; propagatedBuildInputs = [ ilmbase zlib ];
postPatch =
if (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.libc != "glibc")
then
''
patch -p0 < ${non_glibc_fpstate_patch}
''
else null; # `null` avoids rebuild on glibc
enableParallelBuilding = true; enableParallelBuilding = true;
passthru = {
# So that ilmbase (sharing the same source code) can re-use this patch.
inherit non_glibc_fpstate_patch;
};
meta = with stdenv.lib; { meta = with stdenv.lib; {
description = "A high dynamic-range (HDR) image file format"; description = "A high dynamic-range (HDR) image file format";
homepage = "https://www.openexr.com/"; homepage = "https://www.openexr.com/";