Hi Michael,

attached is a patch which fixes ecl, using the gmp and libffi supplied
by nix, preserving the dffi ecl feature.

Michael Raskin <[email protected]> writes:
>>>>2) to fix ecl, another common lisp implementation
>>>
>>> I think adding a wrapper that sets NIX_CFLAGS_COMPILE and 
>>> NIX_CFLAGS_LINK is a better last-ditch solution than just forbidding
>>> libffi (I don't remember if ECL has an option to just add generic 
>>> cflags).
>>
>>Could you please give me more clue, or better point me at an example,
>>how to write this?  My nix skills are not up for that just yet.
>
> Look at bittornado expression, for example, it sets PYTHONPATH for use
> at runtime.
>
> For ECL we need to set NIX_CFLAGS_COMPILE, I guess. Any flags in 
> NIX_CFLAGS_COMPILE are treated by NixPkgs gcc as if passed to gcc 
> directly. There are also NIX_LDFLAGS.
>
>>If we want to use libffi, then it needs to be in propagateBuildInputs.
>
> Good catch.
>
>>Ecl invokes gcc at runtime, to compile lisp files.  At this point,
>>libffi needs to be passed as gcc arg -I${libffi}/lib, which is not
>>happening at the moment, and I haven't found a way how to do this.
>>
>>So unless this runtime gcc invocation works (with or without) libffi,
>>ecl is not usable.

I tried a few things as you suggested but without success.  E.g.

   NIX_CFLAGS_COMPILE = [ "-I${libffi}/include" ];
   NIX_LDFLAGS = [ "-L${libffi}/lib" ];

   or

   wrapProgram $out/bin/ecl \
     --prefix NIX_CFLAGS_COMPILE ' ' "-I${libffi}/include" \
     --prefix NIX_LDFLAGS ' ' "-L${libffi}/lib"

but that did not work.  I think it makes sense, because it is ecl which
creates the gcc arguments, not nix.

The attached patch adds with-libffi-prefix to configure.ac (similar to
the existing with-gmp-prefix) and re-runs autoconf.

Thank you for your help!

Tomas

>From 042f6cd5d6ef80bb875676fb6728fb34049e61e0 Mon Sep 17 00:00:00 2001
From: Tomas Hlavaty <[email protected]>
Date: Sat, 28 Mar 2015 01:57:00 +0100
Subject: [PATCH] ensure that gmp and libffi are found when compiling with gcc
 dynamically

---
 pkgs/development/compilers/ecl/default.nix         | 15 +++++++--
 pkgs/development/compilers/ecl/libffi-prefix.patch | 39 ++++++++++++++++++++++
 2 files changed, 52 insertions(+), 2 deletions(-)
 create mode 100644 pkgs/development/compilers/ecl/libffi-prefix.patch

diff --git a/pkgs/development/compilers/ecl/default.nix b/pkgs/development/compilers/ecl/default.nix
index be65061..bb57ebb 100644
--- a/pkgs/development/compilers/ecl/default.nix
+++ b/pkgs/development/compilers/ecl/default.nix
@@ -1,4 +1,5 @@
 {stdenv, fetchurl
+, libtool, autoconf, automake
 , gmp, mpfr, libffi
 , noUnicode ? false, 
 }:
@@ -13,10 +14,10 @@ let
     sha256="13wlxkd5prm93gcm2dhm7v52fl803yx93aa97lrb39z0y6xzziid";
   };
   buildInputs = [
-    libffi
+    libtool autoconf automake
   ];
   propagatedBuildInputs = [
-    gmp mpfr
+    libffi gmp mpfr
   ];
 in
 stdenv.mkDerivation {
@@ -25,8 +26,18 @@ stdenv.mkDerivation {
   src = fetchurl {
     inherit (s) url sha256;
   };
+  patches = [ ./libffi-prefix.patch ];
+  preConfigure = ''
+    (cd src ; libtoolize -f)
+    (cd src ; autoheader -f)
+    (cd src ; aclocal)
+    (cd src ; automake --add-missing -c)
+    (cd src ; autoconf -f)
+  '';
   configureFlags = [
     "--enable-threads"
+    "--with-gmp-prefix=${gmp}"
+    "--with-libffi-prefix=${libffi}"
     ]
     ++
     (stdenv.lib.optional (! noUnicode)
diff --git a/pkgs/development/compilers/ecl/libffi-prefix.patch b/pkgs/development/compilers/ecl/libffi-prefix.patch
new file mode 100644
index 0000000..d02cc21
--- /dev/null
+++ b/pkgs/development/compilers/ecl/libffi-prefix.patch
@@ -0,0 +1,39 @@
+diff --git a/src/configure.in b/src/configure.in
+index 434da49..642c66c 100644
+--- ecl-15.3.7.orig/src/configure.ac
++++ ecl-15.3.7/src/configure.ac
+@@ -191,6 +191,11 @@ AC_ARG_WITH(dffi,
+                   [(system|included|auto|no, default=AUTO if libffi available)]),
+   [enable_libffi=${withval}], [enable_libffi=auto])
+ 
++AC_ARG_WITH(libffi-prefix,
++  AS_HELP_STRING( [--with-libffi-prefix=path],
++                  [prefix for system LIBFFI includes and libraries] ),
++  [LIBFFI_INCDIR="$withval/include"; LIBFFI_LIBDIR="$withval/lib"], [])
++
+ AC_ARG_WITH(fpe,
+   AS_HELP_STRING( [--with-fpe],
+                   [detect floating point exceptions]
+@@ -368,6 +373,22 @@ else
+   INFOEXT=info
+ fi
+ 
++dnl libffi
++
++if test "x$LIBFFI_INCDIR" != "x"; then
++  LIBFFI_CPPFLAGS="-I$LIBFFI_INCDIR"
++fi
++if test "x$LIBFFI_LIBDIR" != "x"; then
++  LIBFFI_LDFLAGS="-L$LIBFFI_LIBDIR"
++  if test "$enable_rpath" = "yes"; then
++    if (echo "$ECL_LDRPATH" | grep '~A') > /dev/null; then
++      LIBFFI_LDFLAGS=`echo $ECL_LDRPATH | sed "s,~A,$LIBFFI_LIBDIR,"`" $LIBFFI_LDFLAGS"
++    fi
++  fi
++fi
++CPPFLAGS="$CPPFLAGS $LIBFFI_CPPFLAGS"
++LDFLAGS="$LDFLAGS $LIBFFI_LDFLAGS"
++
+ dnl ======================================================================
+ dnl GNU multiprecision library
+ dnl
-- 
2.1.4

_______________________________________________
nix-dev mailing list
[email protected]
http://lists.science.uu.nl/mailman/listinfo/nix-dev

Reply via email to