From 293c55472ac602f63d03043a94e43175c34f87f2 Mon Sep 17 00:00:00 2001 From: marius david Date: Thu, 6 Jan 2022 16:16:34 +0100 Subject: [PATCH 1/6] binutils: fix windres not finding the apprioate cross compiler --- .../tools/misc/binutils/default.nix | 3 ++- .../misc/binutils/windres-locate-gcc.patch | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 pkgs/development/tools/misc/binutils/windres-locate-gcc.patch diff --git a/pkgs/development/tools/misc/binutils/default.nix b/pkgs/development/tools/misc/binutils/default.nix index 0d7ff5a54656..8d759457fa11 100644 --- a/pkgs/development/tools/misc/binutils/default.nix +++ b/pkgs/development/tools/misc/binutils/default.nix @@ -94,7 +94,8 @@ stdenv.mkDerivation { # indeed GHC will refuse to compile with a binutils suffering from it. See # this comment for more information: # https://gitlab.haskell.org/ghc/ghc/issues/4210#note_78333 - lib.optional (stdenv.targetPlatform.isAarch32 && stdenv.hostPlatform.system != stdenv.targetPlatform.system) ./R_ARM_COPY.patch; + lib.optional (stdenv.targetPlatform.isAarch32 && stdenv.hostPlatform.system != stdenv.targetPlatform.system) ./R_ARM_COPY.patch + ++ lib.optional stdenv.targetPlatform.isWindows ./windres-locate-gcc.patch; outputs = [ "out" "info" "man" ]; diff --git a/pkgs/development/tools/misc/binutils/windres-locate-gcc.patch b/pkgs/development/tools/misc/binutils/windres-locate-gcc.patch new file mode 100644 index 000000000000..721667c62cec --- /dev/null +++ b/pkgs/development/tools/misc/binutils/windres-locate-gcc.patch @@ -0,0 +1,19 @@ +diff --git a/binutils/resrc.c b/binutils/resrc.c +index a875c3a4..0411d047 100644 +--- a/binutils/resrc.c ++++ b/binutils/resrc.c +@@ -521,7 +521,13 @@ read_rc_file (const char *filename, const char *preprocessor, + + cpp_pipe = 0; + +- if (dash) ++ /* Nixpkgs specific : look first at the prefixed path ++ ( there should be no gcc in the binutils folder ) */ ++ if (slash && dash) { ++ cpp_pipe = look_for_default(cmd, slash + 1, dash - slash, preprocargs, filename); ++ } ++ ++ if (dash && ! cpp_pipe) + { + /* First, try looking for a prefixed gcc in the windres + directory, with the same prefix as windres */ From d398bdde950bde5cd29224ff32754ab0288e269f Mon Sep 17 00:00:00 2001 From: Marius DAVID Date: Thu, 6 Jan 2022 16:17:34 +0100 Subject: [PATCH 2/6] gettext: fix windows cross compilation --- pkgs/development/libraries/gettext/default.nix | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkgs/development/libraries/gettext/default.nix b/pkgs/development/libraries/gettext/default.nix index 3f8215d19fc2..22acc73c49c6 100644 --- a/pkgs/development/libraries/gettext/default.nix +++ b/pkgs/development/libraries/gettext/default.nix @@ -1,4 +1,4 @@ -{ stdenv, lib, fetchurl, libiconv, xz }: +{ stdenv, lib, fetchurl, fetchpatch, libiconv, xz }: # Note: this package is used for bootstrapping fetchurl, and thus # cannot use fetchpatch! All mutable patches (generated by GitHub or @@ -15,7 +15,11 @@ stdenv.mkDerivation rec { }; patches = [ ./absolute-paths.diff - ]; + ] ++ lib.optional stdenv.hostPlatform.isWindows (fetchpatch { + url = "https://aur.archlinux.org/cgit/aur.git/plain/gettext_formatstring-ruby.patch?h=mingw-w64-gettext&id=e8b577ee3d399518d005e33613f23363a7df07ee"; + name = "gettext_formatstring-ruby.patch"; + sha256 = "sha256-6SxZObOMkQDxuKJuJY+mQ/VuJJxSeGbf97J8ZZddCV0="; + }); outputs = [ "out" "man" "doc" "info" ]; From 3cd7ed9ca96c94079b5caa9a7b41c2cfab4d12e4 Mon Sep 17 00:00:00 2001 From: Marius DAVID Date: Thu, 6 Jan 2022 16:18:37 +0100 Subject: [PATCH 3/6] glib: fix windows compilation --- pkgs/development/libraries/glib/default.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/development/libraries/glib/default.nix b/pkgs/development/libraries/glib/default.nix index c8138431a0a7..30f43c00a05d 100644 --- a/pkgs/development/libraries/glib/default.nix +++ b/pkgs/development/libraries/glib/default.nix @@ -93,6 +93,7 @@ stdenv.mkDerivation rec { buildInputs = [ libelf setupHook pcre + ] ++ optionals (!stdenv.hostPlatform.isWindows) [ bash gnum4 # install glib-gettextize and m4 macros for other apps to use ] ++ optionals stdenv.isLinux [ libselinux @@ -143,6 +144,9 @@ stdenv.mkDerivation rec { patchShebangs glib/gen-unicode-tables.pl patchShebangs tests/gen-casefold-txt.py patchShebangs tests/gen-casemap-txt.py + '' + lib.optionalString stdenv.hostPlatform.isWindows '' + substituteInPlace gio/win32/meson.build \ + --replace "libintl, " "" ''; DETERMINISTIC_BUILD = 1; From cedddfb41f2b1d7b296430d381765ef1c83a6d4a Mon Sep 17 00:00:00 2001 From: Marius DAVID Date: Thu, 6 Jan 2022 16:20:17 +0100 Subject: [PATCH 4/6] openh264: fix compilation for windows --- pkgs/development/libraries/openh264/default.nix | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkgs/development/libraries/openh264/default.nix b/pkgs/development/libraries/openh264/default.nix index 3858cb4dc2d5..93fc495d3854 100644 --- a/pkgs/development/libraries/openh264/default.nix +++ b/pkgs/development/libraries/openh264/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, fetchFromGitHub, nasm }: +{ lib, stdenv, fetchFromGitHub, nasm, windows }: stdenv.mkDerivation rec { pname = "openh264"; @@ -13,10 +13,16 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ nasm ]; + buildInputs = lib.optional stdenv.hostPlatform.isWindows windows.pthreads; + makeFlags = [ "PREFIX=${placeholder "out"}" "ARCH=${stdenv.hostPlatform.linuxArch}" - ]; + ] ++ lib.optional stdenv.hostPlatform.isWindows "OS=mingw_nt"; + + enableParallelBuilding = true; + + hardeningDisable = lib.optional stdenv.hostPlatform.isWindows "stackprotector"; meta = with lib; { description = "A codec library which supports H.264 encoding and decoding"; From 4a50af42abfd900c845fbd2790c55ed54357171f Mon Sep 17 00:00:00 2001 From: Marius DAVID Date: Thu, 6 Jan 2022 16:21:51 +0100 Subject: [PATCH 5/6] ffmpeg-full: fix windows compilation --- pkgs/development/libraries/ffmpeg-full/default.nix | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkgs/development/libraries/ffmpeg-full/default.nix b/pkgs/development/libraries/ffmpeg-full/default.nix index e4a5d908d263..6f6db3e86cfe 100644 --- a/pkgs/development/libraries/ffmpeg-full/default.nix +++ b/pkgs/development/libraries/ffmpeg-full/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, ffmpeg, addOpenGLRunpath, pkg-config, perl, texinfo, yasm +{ lib, stdenv, buildPackages, ffmpeg, addOpenGLRunpath, pkg-config, perl, texinfo, yasm /* * Licensing options (yes some are listed twice, filters and such are not listed) */ @@ -260,7 +260,7 @@ stdenv.mkDerivation rec { configurePlatforms = []; configureFlags = [ - "--target_os=${stdenv.hostPlatform.parsed.kernel.name}" + "--target_os=${if stdenv.hostPlatform.isMinGW then "mingw64" else stdenv.hostPlatform.parsed.kernel.name}" #mingw32 and mingw64 doesn't have a difference here, it is internally rewritten as mingw32 "--arch=${stdenv.hostPlatform.parsed.cpu.name}" /* * Licensing flags @@ -282,7 +282,7 @@ stdenv.mkDerivation rec { (enableFeature hardcodedTablesBuild "hardcoded-tables") (enableFeature safeBitstreamReaderBuild "safe-bitstream-reader") (if multithreadBuild then ( - if isCygwin then + if stdenv.hostPlatform.isWindows then "--disable-pthreads --enable-w32threads" else # Use POSIX threads by default "--enable-pthreads --disable-w32threads") @@ -420,6 +420,7 @@ stdenv.mkDerivation rec { ] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ "--cross-prefix=${stdenv.cc.targetPrefix}" "--enable-cross-compile" + "--host-cc=${buildPackages.stdenv.cc}/bin/cc" ] ++ optionals stdenv.cc.isClang [ "--cc=clang" "--cxx=clang++" From d25d9f988e1e8135bfba38f26aa8e803ff452622 Mon Sep 17 00:00:00 2001 From: Marius DAVID Date: Fri, 7 Jan 2022 16:28:45 +0100 Subject: [PATCH 6/6] ffmpeg: add openh264 --- pkgs/development/libraries/ffmpeg-full/default.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/development/libraries/ffmpeg-full/default.nix b/pkgs/development/libraries/ffmpeg-full/default.nix index 6f6db3e86cfe..8d2144f10395 100644 --- a/pkgs/development/libraries/ffmpeg-full/default.nix +++ b/pkgs/development/libraries/ffmpeg-full/default.nix @@ -107,7 +107,7 @@ , opencore-amr ? null # AMR-NB de/encoder & AMR-WB decoder #, opencv ? null # Video filtering , openglExtlib ? false, libGL ? null, libGLU ? null # OpenGL rendering -#, openh264 ? null # H.264/AVC encoder +, openh264 ? null # H.264/AVC encoder , openjpeg ? null # JPEG 2000 de/encoder , opensslExtlib ? false, openssl ? null , libpulseaudio ? null # Pulseaudio input support @@ -164,7 +164,7 @@ * * Not packaged: * aacplus avisynth cdio-paranoia crystalhd libavc1394 libiec61883 - * libnut libquvi nvenc opencl openh264 oss shine twolame + * libnut libquvi nvenc opencl oss shine twolame * utvideo vo-aacenc vo-amrwbenc xvmc zvbi blackmagic-design-desktop-video * * Need fixes to support Darwin: @@ -382,7 +382,7 @@ stdenv.mkDerivation rec { (enableFeature (opencore-amr != null && version3Licensing) "libopencore-amrnb") #(enableFeature (opencv != null) "libopencv") (enableFeature openglExtlib "opengl") - #(enableFeature (openh264 != null) "openh264") + (enableFeature (openh264 != null) "libopenh264") (enableFeature (openjpeg != null) "libopenjpeg") (enableFeature (opensslExtlib && gplLicensing) "openssl") (enableFeature (libpulseaudio != null) "libpulse") @@ -434,7 +434,7 @@ stdenv.mkDerivation rec { libogg libopus librsvg libssh libtheora libvdpau libvorbis libvpx libwebp libX11 libxcb libXv libXext xz openal openjpeg libpulseaudio rav1e svt-av1 rtmpdump opencore-amr samba SDL2 soxr speex srt vid-stab vo-amrwbenc x264 x265 xavs xvidcore - zeromq4 zimg zlib + zeromq4 zimg zlib openh264 ] ++ optionals openglExtlib [ libGL libGLU ] ++ optionals nonfreeLicensing [ fdk_aac openssl ] ++ optional ((isLinux || isFreeBSD) && libva != null) libva