@@ -4,10 +4,24 @@
44, fetchFromGitHub
55, zlib
66, ilmbase
7−, fetchpatch
7+, fetchpatch
88, cmake
99, libtool
1010}:
11+
12+let
13+ non_glibc_fpstate_patch =
14+ # Fix ilmbase/openexr using glibc-only fpstate.
15+ # Found via https://git.alpinelinux.org/aports/tree/community/openexr/10-musl-_fpstate.patch?id=80d9611b7b8e406a554c6f511137e03ff26acbae,
16+ # TODO Remove when https://github.com/AcademySoftwareFoundation/openexr/pull/798 is merged and available.
17+ # Remove it from `ilmbase` as well then.
18+ (fetchpatch {
19+ name = "ilmbase-musl-_fpstate.patch.patch";
20+ url = "https://raw.githubusercontent.com/void-linux/void-packages/80bbc168faa25448bd3399f4df331b836e74b85c/srcpkgs/ilmbase/patches/musl-_fpstate.patch";
21+ sha256 = "0appzbs9pd6dia5pzxmrs9ww35shlxi329ks6lchwzw4f2a81arz";
22+ });
23+in
24+
1125stdenv.mkDerivation rec {
1226 pname = "openexr";
1327 version = "2.4.1";
@@ -23,8 +37,21 @@ stdenv.mkDerivation rec {
2337 nativeBuildInputs = [ cmake libtool ];
2438 propagatedBuildInputs = [ ilmbase zlib ];
2539
40+ postPatch =
41+ if (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.libc != "glibc")
42+ then
43+ ''
44+ patch -p0 < ${non_glibc_fpstate_patch}
45+ ''
46+ else null; # `null` avoids rebuild on glibc
47+
2648 enableParallelBuilding = true;
2749
50+ passthru = {
51+ # So that ilmbase (sharing the same source code) can re-use this patch.
52+ inherit non_glibc_fpstate_patch;
53+ };
54+
2855 meta = with stdenv.lib; {
2956 description = "A high dynamic-range (HDR) image file format";
3057 homepage = "https://www.openexr.com/";