on iko/ghcjs-patch-master help sign in
backport ghc!3227 (#718)

This essentially backports the following two commits (make build system parts only) - https://github.com/ghc/ghc/commit/bec76733b818b0489ffea0834ab6b1560207577c - https://github.com/ghc/ghc/commit/67738db10010fd28a8e997b5c8f83ea591b88a0e fixes #584

commit74edd91659dcf7eb2f889beacced610fd612d459 authorMoritz Angermann <moritz.angermann@gmail.com> dateMon 22 Jun 2020, 08:03 (6 years ago) parent21a6d60
3 files changed+156
overlays/bootstrap.nix+6 overlays/patches/ghc/67738db10010fd28a8e997b5c8f83ea591b88a0e.patch+107 overlays/patches/ghc/bec76733b818b0489ffea0834ab6b1560207577c.patch+43
overlays/bootstrap.nix+6
@@ -135,6 +135,12 @@ in {
135135 ++ final.lib.optional (versionAtLeast "8.6.4" && final.stdenv.isDarwin) ./patches/ghc/ghc-macOS-loadArchive-fix.patch
136136 ++ final.lib.optional (versionAtLeast "8.4.4" && versionLessThan "8.10" && final.stdenv.isDarwin) ./patches/ghc/ghc-darwin-gcc-version-fix.patch
137137 ++ final.lib.optional (versionAtLeast "8.10.1" && final.stdenv.isDarwin) ./patches/ghc/ghc-8.10-darwin-gcc-version-fix.patch
138+ # backport of https://gitlab.haskell.org/ghc/ghc/-/merge_requests/3227
139+ # the first one is a prerequisite.
140+ # both are trimmed to only include the make build system part and not the
141+ # hadrian one.
142+ ++ fromUntil "8.8" "8.12" ./patches/ghc/bec76733b818b0489ffea0834ab6b1560207577c.patch
143+ ++ fromUntil "8.8" "8.12" ./patches/ghc/67738db10010fd28a8e997b5c8f83ea591b88a0e.patch
138144 ;
139145 in ({
140146 ghc844 = final.callPackage ../compiler/ghc {
overlays/patches/ghc/67738db10010fd28a8e997b5c8f83ea591b88a0e.patchnew file+107
@@ -0,0 +1,107 @@
1+From 67738db10010fd28a8e997b5c8f83ea591b88a0e Mon Sep 17 00:00:00 2001
2+From: Travis Whitaker <pi.boy.travis@gmail.com>
3+Date: Wed, 6 May 2020 04:14:47 +0000
4+Subject: [PATCH] Build a threaded stage 1 if the bootstrapping GHC supports
5+ it.
6+
7+---
8+ compiler/ghc.mk | 6 ++++++
9+ configure.ac | 15 +++++++++++++++
10+ ghc/ghc.mk | 9 ++++++++-
11+ mk/config.mk.in | 3 +++
12+ 8 files changed, 98 insertions(+), 21 deletions(-)
13+
14+diff --git a/compiler/ghc.mk b/compiler/ghc.mk
15+index 6a2dadc820..6e86b73e8d 100644
16+--- a/compiler/ghc.mk
17++++ b/compiler/ghc.mk
18+@@ -194,6 +194,12 @@ ifeq "$(GhcThreaded)" "YES"
19+ compiler_stage2_CONFIGURE_OPTS += --ghc-option=-optc-DTHREADED_RTS
20+ endif
21+
22++# If the bootstrapping GHC supplies the threaded RTS, then we can have a
23++# threaded stage 1 too.
24++ifeq "$(GhcThreadedRts)" "YES"
25++compiler_stage1_CONFIGURE_OPTS += --ghc-option=-optc-DTHREADED_RTS
26++endif
27++
28+ ifeq "$(GhcWithNativeCodeGen)" "YES"
29+ compiler_stage1_CONFIGURE_OPTS += --flags=ncg
30+ compiler_stage2_CONFIGURE_OPTS += --flags=ncg
31+diff --git a/configure.ac b/configure.ac
32+index a621814700..bac2cfde5e 100644
33+--- a/configure.ac
34++++ b/configure.ac
35+@@ -124,6 +124,9 @@ AC_ARG_VAR(CC_STAGE0, [C compiler command (bootstrap)])
36+ AC_ARG_VAR(LD_STAGE0, [Linker command (bootstrap)])
37+ AC_ARG_VAR(AR_STAGE0, [Archive command (bootstrap)])
38+
39++dnl RTS ways supplied by the bootstrapping compiler.
40++AC_ARG_VAR(RTS_WAYS_STAGE0, [RTS ways])
41++
42+ if test "$WithGhc" != ""; then
43+ FPTOOLS_GHC_VERSION([GhcVersion], [GhcMajVersion], [GhcMinVersion], [GhcPatchLevel])dnl
44+
45+@@ -151,6 +154,17 @@ if test "$WithGhc" != ""; then
46+ fi
47+ BOOTSTRAPPING_GHC_INFO_FIELD([AR_OPTS_STAGE0],[ar flags])
48+ BOOTSTRAPPING_GHC_INFO_FIELD([ArSupportsAtFile_STAGE0],[ar supports at file])
49++ BOOTSTRAPPING_GHC_INFO_FIELD([RTS_WAYS_STAGE0],[RTS ways])
50++
51++ dnl Check whether or not the bootstrapping GHC has a threaded RTS. This
52++ dnl determines whether or not we can have a threaded stage 1.
53++ dnl See Note [Linking ghc-bin against threaded stage0 RTS] in
54++ dnl hadrian/src/Settings/Packages.hs for details.
55++ if echo ${RTS_WAYS_STAGE0} | grep '.*thr.*' 2>&1 >/dev/null; then
56++ AC_SUBST(GhcThreadedRts, YES)
57++ else
58++ AC_SUBST(GhcThreadedRts, NO)
59++ fi
60+ fi
61+
62+ dnl ** Must have GHC to build GHC
63+@@ -1454,6 +1468,7 @@ Configure completed successfully.
64+ echo "\
65+ Bootstrapping using : $WithGhc
66+ which is version : $GhcVersion
67++ with threaded RTS? : $GhcThreadedRts
68+ "
69+
70+ if test "x$CcLlvmBackend" = "xYES"; then
71+diff --git a/ghc/ghc.mk b/ghc/ghc.mk
72+index 8c112a054f..5512d50710 100644
73+--- a/ghc/ghc.mk
74++++ b/ghc/ghc.mk
75+@@ -66,8 +66,15 @@ else
76+ ghc_stage2_CONFIGURE_OPTS += -f-threaded
77+ ghc_stage3_CONFIGURE_OPTS += -f-threaded
78+ endif
79+-# Stage-0 compiler isn't guaranteed to have a threaded RTS.
80++
81++# If stage 0 supplies a threaded RTS, we can use it for stage 1.
82++# See Note [Linking ghc-bin against threaded stage0 RTS] in
83++# hadrian/src/Settings/Packages.hs for details.
84++ifeq "$(GhcThreadedRts)" "YES"
85++ghc_stage1_MORE_HC_OPTS += -threaded
86++else
87+ ghc_stage1_CONFIGURE_OPTS += -f-threaded
88++endif
89+
90+ ifeq "$(GhcProfiled)" "YES"
91+ ghc_stage2_PROGRAM_WAY = p
92+diff --git a/mk/config.mk.in b/mk/config.mk.in
93+index 791dc5acc0..250d41ebe6 100644
94+--- a/mk/config.mk.in
95++++ b/mk/config.mk.in
96+@@ -199,6 +199,9 @@ endif
97+ # `GhcUnregisterised` mode doesn't allow that.
98+ GhcWithSMP := $(strip $(if $(filter YESNO, $(ArchSupportsSMP)$(GhcUnregisterised)),YES,NO))
99+
100++# Whether or not the bootstrapping GHC supplies a threaded RTS.
101++GhcThreadedRts = @GhcThreadedRts@
102++
103+ # Whether to include GHCi in the compiler. Depends on whether the RTS linker
104+ # has support for this OS/ARCH combination.
105+
106+--
107+2.25.0
overlays/patches/ghc/bec76733b818b0489ffea0834ab6b1560207577c.patchnew file+43
@@ -0,0 +1,43 @@
1+From bec76733b818b0489ffea0834ab6b1560207577c Mon Sep 17 00:00:00 2001
2+From: Ben Gamari <ben@smart-cactus.org>
3+Date: Wed, 15 Jan 2020 14:57:08 -0500
4+Subject: [PATCH] Fix GhcThreaded setting
5+
6+This adopts a patch from NetBSD's packaging fixing the `GhcThreaded`
7+option of the make build system. In addition we introduce a `ghcThreaded`
8+option in hadrian's `Flavour` type.
9+
10+Also fix Hadrian's treatment of the `Use Threaded` entry in `settings`.
11+Previously it would incorrectly claim `Use Threaded = True` if we were
12+building the `threaded` runtime way. However, this is inconsistent with
13+the `make` build system, which defines it to be whether the `ghc`
14+executable is linked against the threaded runtime.
15+
16+Fixes #17692.
17+---
18+ ghc/ghc.mk | 6 ++++++
19+ hadrian/doc/user-settings.md | 2 ++
20+ hadrian/src/Flavour.hs | 2 ++
21+ hadrian/src/Rules/Generate.hs | 2 +-
22+ hadrian/src/Settings/Default.hs | 1 +
23+ hadrian/src/Settings/Packages.hs | 4 +++-
24+ 6 files changed, 15 insertions(+), 2 deletions(-)
25+
26+diff --git a/ghc/ghc.mk b/ghc/ghc.mk
27+index 3bff2f58c93..8c112a054f9 100644
28+--- a/ghc/ghc.mk
29++++ b/ghc/ghc.mk
30+@@ -61,7 +61,13 @@ ifeq "$(GhcThreaded)" "YES"
31+ # Use threaded RTS with GHCi, so threads don't get blocked at the prompt.
32+ ghc_stage2_MORE_HC_OPTS += -threaded
33+ ghc_stage3_MORE_HC_OPTS += -threaded
34++else
35++# Opt out from threaded GHC. See ghc-bin.cabal.in
36++ghc_stage2_CONFIGURE_OPTS += -f-threaded
37++ghc_stage3_CONFIGURE_OPTS += -f-threaded
38+ endif
39++# Stage-0 compiler isn't guaranteed to have a threaded RTS.
40++ghc_stage1_CONFIGURE_OPTS += -f-threaded
41+
42+ ifeq "$(GhcProfiled)" "YES"
43+ ghc_stage2_PROGRAM_WAY = p