Skip to content

Commit 9b3230d

Browse files
committed
WIP tools
1 parent c1dfab0 commit 9b3230d

File tree

5 files changed

+88
-7
lines changed

5 files changed

+88
-7
lines changed

builder/comp-builder.nix

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -496,17 +496,17 @@ let
496496
# See also https://gitlab.haskell.org/ghc/ghc/-/issues/12935
497497
(if contentAddressed then ''
498498
runHook preBuild
499-
$SETUP_HS build ${haskellLib.componentTarget componentId} -j1 ${lib.concatStringsSep " " (component.setupBuildFlags ++ setupBuildFlags)}
499+
$SETUP_HS build ${haskellLib.componentTarget componentId} -j1 ${lib.concatStringsSep " " setupBuildFlags}
500500
runHook postBuild
501501
'' else if stdenv.hostPlatform.isGhcjs then ''
502502
runHook preBuild
503503
# https://gitlab.haskell.org/ghc/ghc/issues/9221
504-
$SETUP_HS build ${haskellLib.componentTarget componentId} ${lib.concatStringsSep " " (component.setupBuildFlags ++ setupBuildFlags)}
504+
$SETUP_HS build ${haskellLib.componentTarget componentId} ${lib.concatStringsSep " " setupBuildFlags}
505505
runHook postBuild
506506
'' else ''
507507
runHook preBuild
508508
# https://gitlab.haskell.org/ghc/ghc/issues/9221
509-
$SETUP_HS build ${haskellLib.componentTarget componentId} -j$(($NIX_BUILD_CORES > 4 ? 4 : $NIX_BUILD_CORES)) ${lib.concatStringsSep " " (component.setupBuildFlags ++ setupBuildFlags)}
509+
$SETUP_HS build ${haskellLib.componentTarget componentId} -j$(($NIX_BUILD_CORES > 4 ? 4 : $NIX_BUILD_CORES)) ${lib.concatStringsSep " " setupBuildFlags}
510510
runHook postBuild
511511
'');
512512

compiler/ghc/default.nix

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ let
243243
# for musl only; but I'd like to stay far away from the unnecessary
244244
# bindist logic as we can. It's slow, and buggy, and doesn't provide any
245245
# value for us.
246-
installStage1 = useHadrian && (haskell-nix.haskellLib.isCrossTarget || stdenv.targetPlatform.isMusl);
246+
installStage1 = useHadrian && (with haskell-nix.haskellLib; isCrossTarget || isNativeMusl);
247247

248248
hadrian =
249249
let
@@ -683,7 +683,7 @@ stdenv.mkDerivation (rec {
683683
--replace 'dynamic-library-dirs:' 'dynamic-library-dirs: ${libcxx}/lib ${libcxxabi}/lib'
684684
find . -name 'system*.conf*'
685685
cat mk/system-cxx-std-lib-1.0.conf
686-
'' + lib.optionalString (installStage1 && stdenv.targetPlatform.isMusl) ''
686+
'' + lib.optionalString (installStage1 && haskell-nix.haskellLib.isNativeMusl) ''
687687
substituteInPlace hadrian/cfg/system.config \
688688
--replace 'cross-compiling = YES' \
689689
'cross-compiling = NO'
@@ -768,7 +768,7 @@ stdenv.mkDerivation (rec {
768768
--replace 'dynamic-library-dirs:' 'dynamic-library-dirs: ${libcxx}/lib ${libcxxabi}/lib'
769769
find . -name 'system*.conf*'
770770
cat mk/system-cxx-std-lib-1.0.conf
771-
'' + lib.optionalString (installStage1 && !haskell-nix.haskellLib.isCrossTarget && stdenv.targetPlatform.isMusl) ''
771+
'' + lib.optionalString (installStage1 && haskell-nix.haskellLib.isNativeMusl) ''
772772
substituteInPlace hadrian/cfg/system.config \
773773
--replace 'cross-compiling = YES' \
774774
'cross-compiling = NO'

overlays/bootstrap.nix

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,6 @@ in {
251251
++ final.lib.optionals (final.stdenv.targetPlatform.isWindows) (fromUntil "9.4.1" "9.5" ./patches/ghc/ghc-9.4-hadrian-win-cross.patch)
252252
++ fromUntil "9.6.1" "9.8" ./patches/ghc/MR10116.patch
253253
++ fromUntil "9.4.1" "9.6" ./patches/ghc/hadrian-build-deriveConstants-genprimopcode-ghc94.patch
254-
++ fromUntil "9.6.1" "9.8" ./patches/ghc/hadrian-build-deriveConstants-genprimopcode.patch
255254
++ final.lib.optional (versionAtLeast "8.10" && versionLessThan "9.4" && final.stdenv.targetPlatform != final.stdenv.hostPlatform) ./patches/ghc/ghc-make-stage-1-lib-ghc.patch
256255

257256
# the following is a partial reversal of https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4391, to address haskell.nix#1227
@@ -293,6 +292,8 @@ in {
293292
++ final.lib.optional (versionAtLeast "8.10.6" && versionLessThan "9.2" && final.stdenv.targetPlatform.isAndroid && final.stdenv.targetPlatform.isAarch32) ./patches/ghc/ghc-8.10.7-bionic-libc.patch
294293
++ final.lib.optional (versionAtLeast "8.10.6" && versionLessThan "9.2" && final.stdenv.targetPlatform.isAndroid && final.stdenv.targetPlatform.isAarch32) ./patches/ghc/ghc-8.10.7-cross-dont-build-stage2-tools.patch
295294
++ final.lib.optional (versionAtLeast "9.0" && versionLessThan "9.8" && final.stdenv.targetPlatform.isAndroid) ./patches/ghc/ghc-9.6-hadrian-android.patch
295+
++ final.lib.optional (versionAtLeast "9.0" && versionLessThan "9.8" && final.stdenv.targetPlatform.isMusl && final.stdenv.targetPlatform.isAarch64) ./patches/ghc/ghc-9.6-hadrian-strip-cmd.patch
296+
++ final.lib.optional (versionAtLeast "9.0" && versionLessThan "10.0" && final.stdenv.targetPlatform.is32bit) ./patches/ghc/ghc-9.6-32bit-cmm.patch
296297
;
297298
in ({
298299
ghc865 = final.callPackage ../compiler/ghc (traceWarnOld "8.6" {
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
diff --git a/compiler/GHC/StgToCmm/CgUtils.hs b/compiler/GHC/StgToCmm/CgUtils.hs
2+
index 4718cbf..07001c6 100644
3+
--- a/compiler/GHC/StgToCmm/CgUtils.hs
4+
+++ b/compiler/GHC/StgToCmm/CgUtils.hs
5+
@@ -173,15 +173,15 @@ fixStgRegStmt platform stmt = fixAssign $ mapExpDeep fixExpr stmt
6+
BaseReg -> baseAddr
7+
_other -> CmmLoad baseAddr (globalRegType platform reg) NaturallyAligned
8+
9+
- CmmRegOff (CmmGlobal reg) offset ->
10+
+ CmmRegOff greg@(CmmGlobal reg) offset ->
11+
-- RegOf leaves are just a shorthand form. If the reg maps
12+
-- to a real reg, we keep the shorthand, otherwise, we just
13+
-- expand it and defer to the above code.
14+
case reg `elem` activeStgRegs platform of
15+
True -> expr
16+
- False -> CmmMachOp (MO_Add (wordWidth platform)) [
17+
- fixExpr (CmmReg (CmmGlobal reg)),
18+
+ False -> CmmMachOp (MO_Add (cmmRegWidth platform greg)) [
19+
+ fixExpr (CmmReg greg),
20+
CmmLit (CmmInt (fromIntegral offset)
21+
- (wordWidth platform))]
22+
+ (cmmRegWidth platform greg))]
23+
24+
other_expr -> other_expr
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
diff --git a/hadrian/cfg/system.config.in b/hadrian/cfg/system.config.in
2+
index 6a891b4..a2289f8 100644
3+
--- a/hadrian/cfg/system.config.in
4+
+++ b/hadrian/cfg/system.config.in
5+
@@ -18,6 +18,7 @@ merge-objects = @MergeObjsCmd@
6+
system-merge-objects = @LD_STAGE0@
7+
objdump = @ObjdumpCmd@
8+
ranlib = @REAL_RANLIB_CMD@
9+
+strip = @StripCmd@
10+
sphinx-build = @SPHINXBUILD@
11+
system-ar = @AR_STAGE0@
12+
system-cc = @CC_STAGE0@
13+
diff --git a/hadrian/src/Oracles/Setting.hs b/hadrian/src/Oracles/Setting.hs
14+
index 462d289..535cc5f 100644
15+
--- a/hadrian/src/Oracles/Setting.hs
16+
+++ b/hadrian/src/Oracles/Setting.hs
17+
@@ -69,6 +69,7 @@ data Setting = BuildArch
18+
| ProjectPatchLevel
19+
| ProjectPatchLevel1
20+
| ProjectPatchLevel2
21+
+ | Strip
22+
| SystemGhc
23+
| TargetArch
24+
| TargetOs
25+
@@ -171,6 +172,7 @@ setting key = lookupSystemConfig $ case key of
26+
ProjectPatchLevel -> "project-patch-level"
27+
ProjectPatchLevel1 -> "project-patch-level1"
28+
ProjectPatchLevel2 -> "project-patch-level2"
29+
+ Strip -> "strip"
30+
SystemGhc -> "system-ghc"
31+
TargetArch -> "target-arch"
32+
TargetArmVersion -> "target-arm-version"
33+
diff --git a/hadrian/src/Settings/Builders/Cabal.hs b/hadrian/src/Settings/Builders/Cabal.hs
34+
index 2e42185..032ca72 100644
35+
--- a/hadrian/src/Settings/Builders/Cabal.hs
36+
+++ b/hadrian/src/Settings/Builders/Cabal.hs
37+
@@ -85,15 +85,11 @@ commonCabalArgs :: Stage -> Args
38+
commonCabalArgs stage = do
39+
verbosity <- expr getVerbosity
40+
pkg <- getPackage
41+
+ strip <- getSetting Strip
42+
package_id <- expr $ pkgIdentifier pkg
43+
let prefix = "${pkgroot}" ++ (if windowsHost then "" else "/..")
44+
- mconcat [ -- Don't strip libraries when cross compiling.
45+
- -- TODO: We need to set @--with-strip=(stripCmdPath :: Action FilePath)@,
46+
- -- and if it's @:@ disable stripping as well. As it is now, I believe
47+
- -- we might have issues with stripping on Windows, as I can't see a
48+
- -- consumer of 'stripCmdPath'.
49+
- -- TODO: See https://github.com/snowleopard/hadrian/issues/549.
50+
- flag CrossCompiling ? pure [ "--disable-executable-stripping"
51+
+ mconcat [ notStage0 ? strip /= "" ? pure [ "--with-strip=" ++ strip ]
52+
+ , flag CrossCompiling ? pure [ "--disable-executable-stripping"
53+
, "--disable-library-stripping" ]
54+
-- We don't want to strip the debug RTS
55+
, S.package rts ? pure [ "--disable-executable-stripping"
56+

0 commit comments

Comments
 (0)