Skip to content

Commit 82bc945

Browse files
authored
Fix ghc 9 windows cross compilation (#1450)
Fixes Windows cross compilation for GHC 9.0 and 9.2. Updates wine to use the version that is included with the chosen Nixpkgs (it used to be pinned to an older version). Moves the configuration of the GHC source into the GHC derivation. This should make adding Hadrian support easier. Propagates library dependences (not just pkgconfig ones) on windows so that any DLLs in those libraries can be copied for TH evaluation and to the `/bin` directory of executable components. Adds gcc and mfcgthreads as library dependencies on Windows so that the DLLs they include will be found. Use `$pkgsHostTarget` (instead of `ghc-pkg`) to find all the DLLs can copy them to the `/bin` directory of executable components. Adds support for __int128_t and __uint128_t to language-c to fix aarch64-darwin builds. Fixed reinstalling packages that come with patched versions in ghcjs.
1 parent e00ff65 commit 82bc945

File tree

382 files changed

+53539
-1066
lines changed

Some content is hidden

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

382 files changed

+53539
-1066
lines changed

builder/comp-builder.nix

Lines changed: 21 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 =
@@ -346,10 +354,14 @@ let
346354
frameworks # Frameworks will be needed at link time
347355
# Not sure why pkgconfig needs to be propagatedBuildInputs but
348356
# for gi-gtk-hs it seems to help.
349-
++ builtins.concatLists pkgconfig;
357+
++ builtins.concatLists pkgconfig
358+
++ lib.optionals (stdenv.hostPlatform.isWindows)
359+
(lib.flatten component.libs
360+
++ map haskellLib.dependToLib component.depends);
350361

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

354366
nativeBuildInputs =
355367
[shellWrappers buildPackages.removeReferencesTo]
@@ -482,22 +494,20 @@ let
482494
fi
483495
'')
484496
# In case `setup copy` did not create this
485-
+ (lib.optionalString enableSeparateDataOutput "mkdir -p $data")
497+
+ (lib.optionalString enableSeparateDataOutput ''
498+
mkdir -p $data
499+
'')
486500
+ (lib.optionalString (stdenv.hostPlatform.isWindows && (haskellLib.mayHaveExecutable componentId)) (''
487501
echo "Symlink libffi and gmp .dlls ..."
488502
for p in ${lib.concatStringsSep " " [ libffi gmp ]}; do
489503
find "$p" -iname '*.dll' -exec ln -s {} $out/bin \;
490504
done
491505
''
492506
# symlink all .dlls into the local directory.
493-
# we ask ghc-pkg for *all* dynamic-library-dirs and then iterate over the unique set
494-
# to symlink over dlls as needed.
495507
+ ''
496-
echo "Symlink library dependencies..."
497-
for libdir in $(${stdenv.hostPlatform.config}-ghc-pkg field "*" dynamic-library-dirs --simple-output|xargs|sed 's/ /\n/g'|sort -u); do
498-
if [ -d "$libdir" ]; then
499-
find "$libdir" -iname '*.dll' -exec ln -s {} $out/bin \;
500-
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 \;
501511
done
502512
''))
503513
+ (lib.optionalString doCoverage ''

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

ci.nix

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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 ["ghc810420210212" "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)