Skip to content

Various arm, musl and other patches #628

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

Closed
wants to merge 9 commits into from
Closed
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
22 changes: 17 additions & 5 deletions builder/comp-builder.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{ stdenv, buildPackages, ghc, lib, gobject-introspection ? null, haskellLib, makeConfigFiles, ghcForComponent, hsPkgs, runCommand, libffi, gmp, zlib, ncurses, nodejs }:

lib.makeOverridable (
let self =
let self =
{ componentId
, component
, package
Expand Down Expand Up @@ -34,7 +34,10 @@ let self =
, dontStrip ? component.dontStrip

, enableStatic ? component.enableStatic
, enableShared ? component.enableShared && !haskellLib.isCrossHost
, enableShared ? ghc.enableShared && component.enableShared && !haskellLib.isCrossHost
# on x86 we'll use shared libraries, even with musl m(
# ghc's internal linker seems to be broken on x86.
&& !(stdenv.hostPlatform.isMusl && !stdenv.hostPlatform.isx86)
, enableDeadCodeElimination ? component.enableDeadCodeElimination

# Options for Haddock generation
Expand All @@ -52,8 +55,15 @@ let self =
# Data
, enableSeparateDataOutput ? component.enableSeparateDataOutput

# Prelinked ghci libraries; will make iserv faster; especially for static builds.
, enableLibraryForGhci ? true

# Debug
, enableDebugRTS ? false
, enableDWARF ? false

# LLVM
, useLLVM ? ghc.useLLVM
}@drvArgs:

let
Expand Down Expand Up @@ -112,6 +122,7 @@ let
(enableFeature enableExecutableProfiling "executable-profiling")
(enableFeature enableStatic "static")
(enableFeature enableShared "shared")
(enableFeature enableLibraryForGhci "library-for-ghci")
] ++ lib.optionals (stdenv.hostPlatform.isMusl && (haskellLib.isExecutableType componentId)) [
# These flags will make sure the resulting executable is statically linked.
# If it uses other libraries it may be necessary for to add more
Expand All @@ -120,9 +131,6 @@ let
"--disable-executable-dynamic"
"--ghc-option=-optl=-pthread"
"--ghc-option=-optl=-static"
"--ghc-option=-optl=-L${gmp.override { withStatic = true; }}/lib"
"--ghc-option=-optl=-L${zlib.static}/lib"
"--ghc-option=-optl=-L${ncurses.override { enableStatic = true; }}/lib"
] ++ lib.optional enableSeparateDataOutput "--datadir=$data/share/${ghc.name}"
++ lib.optional doHaddock' "--docdir=${docdir "$doc"}"
++ lib.optional (enableLibraryProfiling || enableExecutableProfiling) "--profiling-detail=${profilingDetail}"
Expand All @@ -133,6 +141,10 @@ let
++ configureFlags
++ (ghc.extraConfigureFlags or [])
++ lib.optional enableDebugRTS "--ghc-option=-debug"
++ lib.optional enableDWARF "--ghc-option=-g"
++ lib.optionals useLLVM [
"--ghc-option=-fPIC" "--gcc-option=-fPIC"
]
);

setupGhcOptions = lib.optional (package.ghcOptions != null) '' --ghc-options="${package.ghcOptions}"'';
Expand Down
6 changes: 6 additions & 0 deletions compiler/ghc/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ let
'' + stdenv.lib.optionalString (!enableTerminfo) ''
WITH_TERMINFO=NO
''
# musl doesn't have a system-linker. Only on x86, and on x86 we need it, as
# our elf linker for x86_64 is broken.
+ stdenv.lib.optionalString (targetPlatform.isMusl && !targetPlatform.isx86) ''
compiler_CONFIGURE_OPTS += --flags=-dynamic-system-linker
''
# While split sections are now enabled by default in ghc 8.8 for windows,
# the seem to lead to `too many sections` errors when building base for
# profiling.
Expand Down Expand Up @@ -332,6 +337,7 @@ in let configured-src = stdenv.mkDerivation (rec {

inherit llvmPackages;
inherit enableShared;
inherit useLLVM;

# Our Cabal compiler name
haskellCompilerName = "ghc-${version}";
Expand Down

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading