Skip to content

Commit 6eb329c

Browse files
committed
Merge remote-tracking branch 'upstream/master' into armando-1128-libm
2 parents ed11e78 + b1661f0 commit 6eb329c

File tree

409 files changed

+54282
-1125
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

409 files changed

+54282
-1125
lines changed

builder/comp-builder.nix

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,14 @@ let
223223
"--ghc-option=-fPIC" "--gcc-option=-fPIC"
224224
]
225225
++ map (o: ''--ghc${lib.optionalString (stdenv.hostPlatform.isGhcjs) "js"}-options="${o}"'') ghcOptions
226+
++ lib.optional (
227+
# GHC 9.2 cross compiler built with older versions of GHC seem to have problems
228+
# with unique conters. Perhaps because the name changed for the counters.
229+
# TODO This work around to use `-j1` should be removed once we are able to build 9.2 with 9.2.
230+
haskellLib.isCrossHost
231+
&& builtins.compareVersions defaults.ghc.version "9.2.1" >= 0
232+
&& builtins.compareVersions defaults.ghc.version "9.3" < 0)
233+
"--ghc-options=-j1"
226234
);
227235

228236
executableToolDepends =
@@ -236,6 +244,7 @@ let
236244
shellWrappers = ghcForComponent {
237245
componentName = fullName;
238246
inherit configFiles enableDWARF;
247+
inherit (component) plugins;
239248
};
240249

241250
# In order to let shell hooks make package-specific things like Hoogle databases
@@ -345,10 +354,14 @@ let
345354
frameworks # Frameworks will be needed at link time
346355
# Not sure why pkgconfig needs to be propagatedBuildInputs but
347356
# for gi-gtk-hs it seems to help.
348-
++ builtins.concatLists pkgconfig;
357+
++ builtins.concatLists pkgconfig
358+
++ lib.optionals (stdenv.hostPlatform.isWindows)
359+
(lib.flatten component.libs
360+
++ map haskellLib.dependToLib component.depends);
349361

350-
buildInputs = component.libs
351-
++ map haskellLib.dependToLib component.depends;
362+
buildInputs = lib.optionals (!stdenv.hostPlatform.isWindows)
363+
(lib.flatten component.libs
364+
++ map haskellLib.dependToLib component.depends);
352365

353366
nativeBuildInputs =
354367
[shellWrappers buildPackages.removeReferencesTo]
@@ -481,22 +494,20 @@ let
481494
fi
482495
'')
483496
# In case `setup copy` did not create this
484-
+ (lib.optionalString enableSeparateDataOutput "mkdir -p $data")
497+
+ (lib.optionalString enableSeparateDataOutput ''
498+
mkdir -p $data
499+
'')
485500
+ (lib.optionalString (stdenv.hostPlatform.isWindows && (haskellLib.mayHaveExecutable componentId)) (''
486501
echo "Symlink libffi and gmp .dlls ..."
487502
for p in ${lib.concatStringsSep " " [ libffi gmp ]}; do
488503
find "$p" -iname '*.dll' -exec ln -s {} $out/bin \;
489504
done
490505
''
491506
# symlink all .dlls into the local directory.
492-
# we ask ghc-pkg for *all* dynamic-library-dirs and then iterate over the unique set
493-
# to symlink over dlls as needed.
494507
+ ''
495-
echo "Symlink library dependencies..."
496-
for libdir in $(${stdenv.hostPlatform.config}-ghc-pkg field "*" dynamic-library-dirs --simple-output|xargs|sed 's/ /\n/g'|sort -u); do
497-
if [ -d "$libdir" ]; then
498-
find "$libdir" -iname '*.dll' -exec ln -s {} $out/bin \;
499-
fi
508+
for p in $pkgsHostTargetAsString; do
509+
find "$p" -iname '*.dll' -exec ln -s {} $out/bin \;
510+
find "$p" -iname '*.dll.a' -exec ln -s {} $out/bin \;
500511
done
501512
''))
502513
+ (lib.optionalString doCoverage ''

builder/ghc-for-component-wrapper.nix

Lines changed: 60 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
, configFiles # The component's "config" derivation
1414
, postInstall ? ""
1515
, enableDWARF
16+
, plugins
1617
}:
1718

1819
let
@@ -37,31 +38,70 @@ in runCommand "${componentName}-${ghc.name}-env" {
3738
''
3839
. ${makeWrapper}/nix-support/setup-hook
3940
40-
# Start with a ghc...
41+
''
42+
# Start with a ghc and remove all of the package directories
43+
+ ''
4144
mkdir -p $out/bin
4245
${lndir}/bin/lndir -silent ${ghc} $out
43-
# ... remove all of the package directories
4446
rm -rf ${libDir}/*/
45-
# ... but retain the lib/ghc/bin directory. This contains `unlit' and friends.
47+
''
48+
# ... but retain the lib/ghc/bin directory. This contains `unlit' and friends.
49+
+ ''
4650
ln -s ${ghc}/lib/${ghcCommand}-${ghc.version}/bin ${libDir}
47-
# ... and the ghcjs shim's if they are available ...
51+
''
52+
# ... and the ghcjs shim's if they are available ...
53+
+ ''
4854
if [ -d ${ghc}/lib/${ghcCommand}-${ghc.version}/shims ]; then
4955
ln -s ${ghc}/lib/${ghcCommand}-${ghc.version}/shims ${libDir}
5056
fi
51-
# ... and node modules ...
57+
''
58+
# ... and node modules ...
59+
+ ''
5260
if [ -d ${ghc}/lib/${ghcCommand}-${ghc.version}/ghcjs-node ]; then
5361
ln -s ${ghc}/lib/${ghcCommand}-${ghc.version}/ghcjs-node ${libDir}
5462
fi
55-
# Replace the package database with the one from target package config.
63+
''
64+
# Replace the package database with the one from target package config.
65+
+ ''
5666
ln -s ${configFiles}/${packageCfgDir} $out/${packageCfgDir}
5767
58-
# now the tricky bit. For GHCJS (to make plugins work), we need a special
59-
# file called ghc_libdir. That points to the build ghc's lib.
60-
echo "${ghc.buildGHC or ghc}/lib/${(ghc.buildGHC or ghc).name}" > "${libDir}/ghc_libdir"
68+
''
69+
# Set the GHC_PLUGINS environment variable according to the plugins for the component.
70+
# GHC will automatically load the relevant symbols from the given libraries and
71+
# initialize them with the given arguments.
72+
#
73+
# GHC_PLUGINS is a `read`able [(FilePath,String,String,[String])], where the
74+
# first component is a path to the shared library, the second is the package ID,
75+
# the third is the module name, and the fourth is the plugin arguments.
76+
+ ''
77+
GHC_PLUGINS="["
78+
LIST_PREFIX=""
79+
${builtins.concatStringsSep "\n" (map (plugin: ''
80+
id=$(${ghc}/bin/ghc-pkg --package-db ${plugin.library}/package.conf.d field ${plugin.library.package.identifier.name} id --simple-output)
81+
lib_dir=$(${ghc}/bin/ghc-pkg --package-db ${plugin.library}/package.conf.d field ${plugin.library.package.identifier.name} dynamic-library-dirs --simple-output)
82+
lib_base=$(${ghc}/bin/ghc-pkg --package-db ${plugin.library}/package.conf.d field ${plugin.library.package.identifier.name} hs-libraries --simple-output)
83+
lib="$(echo ''${lib_dir}/lib''${lib_base}*)"
84+
GHC_PLUGINS="''${GHC_PLUGINS}''${LIST_PREFIX}(\"''${lib}\",\"''${id}\",\"${plugin.moduleName}\",["
85+
LIST_PREFIX=""
86+
${builtins.concatStringsSep "\n" (map (arg: ''
87+
GHC_PLUGINS="''${GHC_PLUGINS}''${LIST_PREFIX}\"${arg}\""
88+
LIST_PREFIX=","
89+
'') plugin.args)}
90+
GHC_PLUGINS="''${GHC_PLUGINS}])"
91+
LIST_PREFIX=","
92+
'') plugins)}
93+
GHC_PLUGINS="''${GHC_PLUGINS}]"
6194
62-
# Wrap compiler executables with correct env variables.
63-
# The NIX_ variables are used by the patched Paths_ghc module.
95+
''
96+
# now the tricky bit. For GHCJS (to make plugins work), we need a special
97+
# file called ghc_libdir. That points to the build ghc's lib.
98+
+ ''
99+
echo "${ghc.buildGHC or ghc}/lib/${(ghc.buildGHC or ghc).name}" > "${libDir}/ghc_libdir"
64100
101+
''
102+
# Wrap compiler executables with correct env variables.
103+
# The NIX_ variables are used by the patched Paths_ghc module.
104+
+ ''
65105
for prg in ${ghcCommand} ${ghcCommand}i ${ghcCommand}-${ghc.version} ${ghcCommand}i-${ghc.version}; do
66106
if [[ -x "${ghc}/bin/$prg" ]]; then
67107
rm -f $out/bin/$prg
@@ -70,6 +110,7 @@ in runCommand "${componentName}-${ghc.name}-env" {
70110
--set "NIX_${ghcCommandCaps}" "$out/bin/${ghcCommand}" \
71111
--set "NIX_${ghcCommandCaps}PKG" "$out/bin/${ghcCommand}-pkg" \
72112
--set "NIX_${ghcCommandCaps}_DOCDIR" "${docDir}" \
113+
--set "GHC_PLUGINS" "$GHC_PLUGINS" \
73114
--set "NIX_${ghcCommandCaps}_LIBDIR" "${libDir}"
74115
fi
75116
done
@@ -82,21 +123,25 @@ in runCommand "${componentName}-${ghc.name}-env" {
82123
--set "NIX_${ghcCommandCaps}" "$out/bin/${ghcCommand}" \
83124
--set "NIX_${ghcCommandCaps}PKG" "$out/bin/${ghcCommand}-pkg" \
84125
--set "NIX_${ghcCommandCaps}_DOCDIR" "${docDir}" \
126+
--set "GHC_PLUGINS" "$GHC_PLUGINS" \
85127
--set "NIX_${ghcCommandCaps}_LIBDIR" "${libDir}"
86128
fi
87129
done
88130
89-
# Wrap haddock, if the base GHC provides it.
131+
''
132+
# Wrap haddock, if the base GHC provides it.
133+
+ ''
90134
if [[ -x "${haddock}/bin/haddock" ]]; then
91135
rm -f $out/bin/haddock
92136
makeWrapper ${haddock}/bin/haddock $out/bin/haddock \
93137
--add-flags '"-B$NIX_${ghcCommandCaps}_LIBDIR"' \
94138
--set "NIX_${ghcCommandCaps}_LIBDIR" "${libDir}"
95139
fi
96140
97-
# Point ghc-pkg to the package database of the component using the
98-
# --global-package-db flag.
99-
141+
''
142+
# Point ghc-pkg to the package database of the component using the
143+
# --global-package-db flag.
144+
+ ''
100145
for prg in ${ghcCommand}-pkg ${ghcCommand}-pkg-${ghc.version}; do
101146
if [[ -x "${ghc}/bin/$prg" ]]; then
102147
rm -f $out/bin/$prg

builder/haddock-builder.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ let
5656
componentName = fullName;
5757
configFiles = docsConfigFiles;
5858
inherit (componentDrv) enableDWARF;
59+
inherit (component) plugins;
5960
};
6061

6162
drv = stdenv.mkDerivation (commonAttrs // {

builder/make-config-files.nix

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,12 @@ let
8585
${target-pkg} init $out/${packageCfgDir}
8686
8787
${lib.concatStringsSep "\n" (lib.mapAttrsToList flagsAndConfig {
88-
"extra-lib-dirs" = map (p: "${lib.getLib p}/lib") component.libs
88+
"extra-lib-dirs" = map (p: "${lib.getLib p}/lib") (lib.flatten component.libs)
8989
# On windows also include `bin` directories that may contain DLLs
9090
++ lib.optionals (stdenv.hostPlatform.isWindows)
9191
(map (p: "${lib.getBin p}/bin")
92-
(component.libs ++ lib.concatLists component.pkgconfig));
93-
"extra-include-dirs" = map (p: "${lib.getDev p}/include") component.libs;
92+
(lib.flatten component.libs ++ lib.concatLists component.pkgconfig));
93+
"extra-include-dirs" = map (p: "${lib.getDev p}/include") (lib.flatten component.libs);
9494
"extra-framework-dirs" = map (p: "${p}/Library/Frameworks") component.frameworks;
9595
})}
9696

builder/shell-for.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ let
113113
ln -s ${hoogleIndex}/bin/hoogle $out/bin
114114
'';
115115
inherit enableDWARF;
116+
plugins = [];
116117
};
117118

118119
hoogleIndex = let

ci.nix

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
ghc902 = true;
4242
ghc921 = false;
4343
ghc922 = true;
44-
ghc810420210212 = false;
44+
ghc810420210212 = true;
4545
});
4646
systems = nixpkgsName: nixpkgs: compiler-nix-name: nixpkgs.lib.genAttrs (
4747
nixpkgs.lib.filter (v:
@@ -53,7 +53,12 @@
5353
# aarch64-darwin requires ghc 8.10.7 and does not work on older nixpkgs
5454
(v != "aarch64-darwin" || (
5555
!__elem compiler-nix-name ["ghc865" "ghc884" "ghc8104" "ghc810420210212" "ghc8105" "ghc8106" "ghc901" "ghc921"]
56-
&& !__elem nixpkgsName ["R2105"]))) supportedSystems) (v: v);
56+
&& !__elem nixpkgsName ["R2105"]))
57+
&&
58+
# aarch64-linux requires ghc 8.8.4
59+
(v != "aarch64-linux" || (
60+
!__elem compiler-nix-name ["ghc865" "ghc8104" "ghc810420210212" "ghc8105" "ghc8106" "ghc901" "ghc921"]
61+
))) supportedSystems) (v: v);
5762
crossSystems = nixpkgsName: nixpkgs: compiler-nix-name: system:
5863
# We need to use the actual nixpkgs version we're working with here, since the values
5964
# of 'lib.systems.examples' are not understood between all versions
@@ -63,10 +68,10 @@
6368
|| (system == "x86_64-darwin" && __elem compiler-nix-name ["ghc8107"]))) {
6469
inherit (lib.systems.examples) ghcjs;
6570
} // lib.optionalAttrs (system == "x86_64-linux" &&
66-
nixpkgsName == "unstable" && (__elem compiler-nix-name ["ghc8107"])) {
71+
nixpkgsName == "unstable" && (__elem compiler-nix-name ["ghc810420210212" "ghc8107" "ghc902" "ghc922"])) {
6772
# Windows cross compilation is currently broken on macOS
6873
inherit (lib.systems.examples) mingwW64;
69-
} // lib.optionalAttrs (system == "x86_64-linux" && nixpkgsName == "unstable" && compiler-nix-name == "ghc8107") {
74+
} // lib.optionalAttrs (system == "x86_64-linux" && nixpkgsName == "unstable" && __elem compiler-nix-name ["ghc8107" "ghc902" "ghc922"]) {
7075
# Musl cross only works on linux
7176
# aarch64 cross only works on linux
7277
inherit (lib.systems.examples) musl64 aarch64-multiplatform;

compiler/ghc/configured-src.nix

Lines changed: 0 additions & 132 deletions
This file was deleted.

0 commit comments

Comments
 (0)