Skip to content

Commit

Permalink
ghc-8.6.3: use system libffi
Browse files Browse the repository at this point in the history
Use the system `libffi` (`ie` nixpkgs's) instead of built-in libffi
from ghc source tree.

This will prevent library conflict when ghc dynamically links haskell
packages (linked with ghc built-in libffi) and any external library
which uses nixpkgs `libffi`.

Closes #55208.
  • Loading branch information
guibou authored and peti committed Feb 12, 2019
1 parent 7f32b3d commit a7c7743
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkgs/development/compilers/ghc/8.6.3.nix
Expand Up @@ -6,6 +6,9 @@

, libiconv ? null, ncurses

, # GHC can be built with system libffi or a bundled one.
libffi ? null

, useLLVM ? !stdenv.targetPlatform.isx86 || (stdenv.targetPlatform.isMusl && stdenv.hostPlatform != stdenv.targetPlatform)
, # LLVM is conceptually a run-time-only depedendency, but for
# non-x86, we need LLVM to bootstrap later stages, so it becomes a
Expand Down Expand Up @@ -65,6 +68,7 @@ let

# Splicer will pull out correct variations
libDeps = platform: stdenv.lib.optional enableTerminfo [ ncurses ]
++ [libffi]
++ stdenv.lib.optional (!enableIntegerSimple) gmp
++ stdenv.lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;

Expand Down Expand Up @@ -149,6 +153,7 @@ stdenv.mkDerivation (rec {
configureFlags = [
"--datadir=$doc/share/doc/ghc"
"--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
] ++ stdenv.lib.optionals (libffi != null) ["--with-system-libffi" "--with-ffi-includes=${libffi}/include" "--with-ffi-libraries=${libffi}/lib"
] ++ stdenv.lib.optional (targetPlatform == hostPlatform && !enableIntegerSimple) [
"--with-gmp-includes=${targetPackages.gmp.dev}/include" "--with-gmp-libraries=${targetPackages.gmp.out}/lib"
] ++ stdenv.lib.optional (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
Expand Down

6 comments on commit a7c7743

@sgraf812
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sets the wrong --with-ffi-include path. This is quite a problem for developing GHC with a Nix provided boot compiler (https://ghc.haskell.org/trac/ghc/ticket/16368).

I'm not sure what the Nix-way of accessing the proper path is. Here is the derivation for libffi, so ${libffi.out} for lib and ${libffi.dev} maybe?

@sgraf812
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@peti
Copy link
Member

@peti peti commented on a7c7743 Mar 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... ${libffi.out} for lib and ${libffi.dev} maybe?

The most idiomatic way is stdenv.lib.getLib libffi for libraries and stdenv.lib.getDev libffi for development headers. The solution you've used in your PR now is fine, too, though. Accessing out explicitly is typically unnecessary because foo == foo.out by convention.

@sgraf812
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks!

@guibou
Copy link
Contributor Author

@guibou guibou commented on a7c7743 Mar 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for finding that!

@matthewbauer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two things on this:

Please sign in to comment.