Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

haskell: pkgsStatic fixes #162374

Merged
merged 4 commits into from
Mar 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pkgs/development/compilers/ghc/8.10.7.nix
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,10 @@ stdenv.mkDerivation (rec {
inherit llvmPackages;
inherit enableShared;

# This is used by the haskell builder to query
# the presence of the haddock program.
hasHaddock = enableHaddockProgram;

# Our Cabal compiler name
haskellCompilerName = "ghc-${version}";
};
Expand Down
4 changes: 4 additions & 0 deletions pkgs/development/compilers/ghc/8.8.4.nix
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,10 @@ stdenv.mkDerivation (rec {
inherit llvmPackages;
inherit enableShared;

# This is used by the haskell builder to query
# the presence of the haddock program.
hasHaddock = enableHaddockProgram;

# Our Cabal compiler name
haskellCompilerName = "ghc-${version}";
};
Expand Down
16 changes: 12 additions & 4 deletions pkgs/development/compilers/ghc/9.0.2.nix
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

, # Whether to build dynamic libs for the standard library (on the target
# platform). Static libs are always built.
enableShared ? !stdenv.targetPlatform.isWindows && !stdenv.targetPlatform.useiOSPrebuilt
enableShared ? with stdenv.targetPlatform; !isWindows && !useiOSPrebuilt && !isStatic

, # Whether to build terminfo.
enableTerminfo ? !stdenv.targetPlatform.isWindows
Expand Down Expand Up @@ -105,9 +105,13 @@ let
CrossCompilePrefix = ${targetPrefix}
'' + lib.optionalString (!enableProfiledLibs) ''
GhcLibWays = "v dyn"
'' + lib.optionalString enableRelocatedStaticLibs ''
GhcLibHcOpts += -fPIC
GhcRtsHcOpts += -fPIC
'' +
# -fexternal-dynamic-refs apparently (because it's not clear from the documentation)
# makes the GHC RTS able to load static libraries, which may be needed for TemplateHaskell.
# This solution was described in https://www.tweag.io/blog/2020-09-30-bazel-static-haskell
lib.optionalString enableRelocatedStaticLibs ''
GhcLibHcOpts += -fPIC -fexternal-dynamic-refs
GhcRtsHcOpts += -fPIC -fexternal-dynamic-refs
'' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
EXTRA_CC_OPTS += -std=gnu99
'';
Expand Down Expand Up @@ -327,6 +331,10 @@ stdenv.mkDerivation (rec {
inherit llvmPackages;
inherit enableShared;

# This is used by the haskell builder to query
# the presence of the haddock program.
hasHaddock = enableHaddockProgram;

# Our Cabal compiler name
haskellCompilerName = "ghc-${version}";
};
Expand Down
16 changes: 12 additions & 4 deletions pkgs/development/compilers/ghc/9.2.2.nix
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

, # Whether to build dynamic libs for the standard library (on the target
# platform). Static libs are always built.
enableShared ? !stdenv.targetPlatform.isWindows && !stdenv.targetPlatform.useiOSPrebuilt
enableShared ? with stdenv.targetPlatform; !isWindows && !useiOSPrebuilt && !isStatic

, # Whether to build terminfo.
enableTerminfo ? !stdenv.targetPlatform.isWindows
Expand Down Expand Up @@ -106,9 +106,13 @@ let
CrossCompilePrefix = ${targetPrefix}
'' + lib.optionalString (!enableProfiledLibs) ''
GhcLibWays = "v dyn"
'' + lib.optionalString enableRelocatedStaticLibs ''
GhcLibHcOpts += -fPIC
GhcRtsHcOpts += -fPIC
'' +
# -fexternal-dynamic-refs apparently (because it's not clear from the documentation)
# makes the GHC RTS able to load static libraries, which may be needed for TemplateHaskell.
# This solution was described in https://www.tweag.io/blog/2020-09-30-bazel-static-haskell
lib.optionalString enableRelocatedStaticLibs ''
GhcLibHcOpts += -fPIC -fexternal-dynamic-refs
GhcRtsHcOpts += -fPIC -fexternal-dynamic-refs
'' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
EXTRA_CC_OPTS += -std=gnu99
'';
Expand Down Expand Up @@ -327,6 +331,10 @@ stdenv.mkDerivation (rec {
inherit llvmPackages;
inherit enableShared;

# This is used by the haskell builder to query
# the presence of the haddock program.
hasHaddock = enableHaddockProgram;

# Our Cabal compiler name
haskellCompilerName = "ghc-${version}";
};
Expand Down
4 changes: 4 additions & 0 deletions pkgs/development/compilers/ghc/head.nix
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,10 @@ stdenv.mkDerivation (rec {
inherit llvmPackages;
inherit enableShared;

# This is used by the haskell builder to query
# the presence of the haddock program.
hasHaddock = enableHaddockProgram;

# Our Cabal compiler name
haskellCompilerName = "ghc-${version}";
};
Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/haskell-modules/generic-builder.nix
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ in
, changelog ? null
, mainProgram ? null
, doCoverage ? false
, doHaddock ? !(ghc.isHaLVM or false)
, doHaddock ? !(ghc.isHaLVM or false) && (ghc.hasHaddock or true)
, doHaddockInterfaces ? doHaddock && lib.versionAtLeast ghc.version "9.0.1"
, passthru ? {}
, pkg-configDepends ? [], libraryPkgconfigDepends ? [], executablePkgconfigDepends ? [], testPkgconfigDepends ? [], benchmarkPkgconfigDepends ? []
Expand Down
12 changes: 10 additions & 2 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12489,7 +12489,11 @@ with pkgs;

# Please update doc/languages-frameworks/haskell.section.md, “Our
# current default compiler is”, if you bump this:
haskellPackages = dontRecurseIntoAttrs haskell.packages.ghc902;
haskellPackages = dontRecurseIntoAttrs
# Prefer native-bignum to avoid linking issues with gmp
(if stdenv.hostPlatform.isStatic
then haskell.packages.native-bignum.ghc902
else haskell.packages.ghc902);

rnhmjoj marked this conversation as resolved.
Show resolved Hide resolved
# haskellPackages.ghc is build->host (it exposes the compiler used to build the
# set, similarly to stdenv.cc), but pkgs.ghc should be host->target to be more
Expand All @@ -12499,7 +12503,11 @@ with pkgs;
# the withPackages wrapper available. In the final cross-compiled package set
# however, targetPackages won't be populated, so we need to fall back to the
# plain, cross-compiled compiler (which is only theoretical at the moment).
ghc = targetPackages.haskellPackages.ghc or haskell.compiler.ghc902;
ghc = targetPackages.haskellPackages.ghc or
# Prefer native-bignum to avoid linking issues with gmp
(if stdenv.targetPlatform.isStatic
then haskell.compiler.native-bignum.ghc902
else haskell.compiler.ghc902);

cabal-install = haskell.lib.compose.justStaticExecutables haskellPackages.cabal-install;

Expand Down
2 changes: 2 additions & 0 deletions pkgs/top-level/release-haskell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ let
hello
lens
random
QuickCheck
;
};

Expand All @@ -304,6 +305,7 @@ let
hello
lens
random
QuickCheck
;
};
};
Expand Down