From 2e5051e2235f93829f0d6531ace21e87f2a486a4 Mon Sep 17 00:00:00 2001 From: Daniel Fullmer Date: Fri, 3 Jan 2020 20:06:13 -0500 Subject: [PATCH] x264: fix cross compilation --- pkgs/development/libraries/x264/default.nix | 13 +++++++++---- .../libraries/x264/disable-arm-neon-default.patch | 13 +++++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 pkgs/development/libraries/x264/disable-arm-neon-default.patch diff --git a/pkgs/development/libraries/x264/default.nix b/pkgs/development/libraries/x264/default.nix index 9998add0d93..2757ca7704c 100644 --- a/pkgs/development/libraries/x264/default.nix +++ b/pkgs/development/libraries/x264/default.nix @@ -1,4 +1,4 @@ -{ stdenv, fetchurl, nasm }: +{ stdenv, lib, fetchurl, nasm }: stdenv.mkDerivation rec { pname = "x264"; @@ -9,6 +9,10 @@ stdenv.mkDerivation rec { sha256 = "1xv41z04km3rf374xk3ny7v8ibr211ph0j5am0909ln63mphc48f"; }; + # Upstream ./configure greps for (-mcpu|-march|-mfpu) in CFLAGS, which in nix + # is put in the cc wrapper anyway. + patches = [ ./disable-arm-neon-default.patch ]; + postPatch = '' patchShebangs . ''; @@ -17,15 +21,16 @@ stdenv.mkDerivation rec { outputs = [ "out" "lib" "dev" ]; - preConfigure = '' + preConfigure = lib.optionalString (stdenv.buildPlatform.isx86_64 || stdenv.hostPlatform.isi686) '' # `AS' is set to the binutils assembler, but we need nasm unset AS ''; configureFlags = [ "--enable-shared" ] - ++ stdenv.lib.optional (!stdenv.isi686) "--enable-pic"; + ++ stdenv.lib.optional (!stdenv.isi686) "--enable-pic" + ++ stdenv.lib.optional (stdenv.buildPlatform != stdenv.hostPlatform) "--cross-prefix=${stdenv.cc.targetPrefix}"; - nativeBuildInputs = [ nasm ]; + nativeBuildInputs = lib.optional (stdenv.hostPlatform.isx86_64 || stdenv.hostPlatform.isi686) nasm; meta = with stdenv.lib; { description = "Library for encoding H264/AVC video streams"; diff --git a/pkgs/development/libraries/x264/disable-arm-neon-default.patch b/pkgs/development/libraries/x264/disable-arm-neon-default.patch new file mode 100644 index 00000000000..6971944abb4 --- /dev/null +++ b/pkgs/development/libraries/x264/disable-arm-neon-default.patch @@ -0,0 +1,13 @@ +diff -Naur x264-snapshot-20190517-2245-stable-orig/configure x264-snapshot-20190517-2245-stable/configure +--- x264-snapshot-20190517-2245-stable-orig/configure 2020-01-03 19:51:03.041037657 -0500 ++++ x264-snapshot-20190517-2245-stable/configure 2020-01-03 19:52:15.075034609 -0500 +@@ -930,9 +930,6 @@ + fi + + if [ $asm = auto -a $ARCH = ARM ] ; then +- # set flags so neon is built by default +- [ $compiler == CL ] || echo $CFLAGS | grep -Eq '(-mcpu|-march|-mfpu)' || CFLAGS="$CFLAGS -mcpu=cortex-a8 -mfpu=neon" +- + cc_check '' '' '__asm__("add r0, r1, r2");' && define HAVE_ARM_INLINE_ASM + if [ $compiler = CL ] && cpp_check '' '' 'defined(_M_ARM) && _M_ARM >= 7' ; then + define HAVE_ARMV6