Sven Tennie pushed to branch wip/supersven/hadrian-cross-stage3 at Glasgow Haskell Compiler / GHC
Commits:
-
05be70fe
by Sven Tennie at 2026-06-27T14:40:02+00:00
-
c5dd7a9b
by Sven Tennie at 2026-06-27T14:40:02+00:00
-
ac3d3df0
by Sven Tennie at 2026-06-27T14:40:02+00:00
-
8b7fa370
by Sven Tennie at 2026-06-27T14:40:02+00:00
7 changed files:
- .gitlab/ci.sh
- .gitlab/generate-ci/gen_ci.hs
- .gitlab/jobs.yaml
- hadrian/src/BindistConfig.hs
- hadrian/src/Rules/BinaryDist.hs
- hadrian/src/Rules/CabalReinstall.hs
- hadrian/src/Rules/Generate.hs
Changes:
| ... | ... | @@ -1034,7 +1034,12 @@ esac |
| 1034 | 1034 | if [ -n "${CROSS_TARGET:-}" ]; then
|
| 1035 | 1035 | info "Cross-compiling for $CROSS_TARGET..."
|
| 1036 | 1036 | target_triple="$CROSS_TARGET"
|
| 1037 | - cross_prefix="$target_triple-"
|
|
| 1037 | + # Stage3 native GHC runs on the target itself, so no cross prefix.
|
|
| 1038 | + if [ "${CROSS_STAGE:-2}" = "3" ]; then
|
|
| 1039 | + cross_prefix=""
|
|
| 1040 | + else
|
|
| 1041 | + cross_prefix="$target_triple-"
|
|
| 1042 | + fi
|
|
| 1038 | 1043 | else
|
| 1039 | 1044 | cross_prefix=""
|
| 1040 | 1045 | fi
|
| ... | ... | @@ -160,6 +160,7 @@ data BuildConfig |
| 160 | 160 | , withZstd :: Bool
|
| 161 | 161 | , crossTarget :: Maybe String
|
| 162 | 162 | , crossStage :: Maybe Int
|
| 163 | + , platformKeyOverride :: Maybe String
|
|
| 163 | 164 | , crossEmulator :: CrossEmulator
|
| 164 | 165 | , configureWrapper :: Maybe String
|
| 165 | 166 | , fullyStatic :: Bool
|
| ... | ... | @@ -229,6 +230,7 @@ vanilla = BuildConfig |
| 229 | 230 | , withZstd = False
|
| 230 | 231 | , crossTarget = Nothing
|
| 231 | 232 | , crossStage = Nothing
|
| 233 | + , platformKeyOverride = Nothing
|
|
| 232 | 234 | , crossEmulator = NoEmulator
|
| 233 | 235 | , configureWrapper = Nothing
|
| 234 | 236 | , fullyStatic = False
|
| ... | ... | @@ -273,17 +275,31 @@ static = vanilla { fullyStatic = True } |
| 273 | 275 | staticNativeInt :: BuildConfig
|
| 274 | 276 | staticNativeInt = static { bignumBackend = Native }
|
| 275 | 277 | |
| 276 | -crossConfig :: String -- ^ target triple
|
|
| 278 | +stage2CrossConfig :: String -- ^ target triple
|
|
| 277 | 279 | -> CrossEmulator -- ^ emulator for testing
|
| 278 | 280 | -> Maybe String -- ^ Configure wrapper
|
| 279 | 281 | -> BuildConfig
|
| 280 | -crossConfig triple emulator configure_wrapper =
|
|
| 282 | +stage2CrossConfig triple emulator configure_wrapper =
|
|
| 281 | 283 | vanilla { crossTarget = Just triple
|
| 282 | 284 | , crossStage = Just 2
|
| 283 | 285 | , crossEmulator = emulator
|
| 284 | 286 | , configureWrapper = configure_wrapper
|
| 285 | 287 | }
|
| 286 | 288 | |
| 289 | +-- | cross-compiled compilers (build /= host/target)
|
|
| 290 | +stage3CrossConfig :: String -- ^ target triple
|
|
| 291 | + -> String -- ^ GHCup platform key for the host (e.g. "riscv64-linux")
|
|
| 292 | + -> CrossEmulator -- ^ emulator for testing
|
|
| 293 | + -> Maybe String -- ^ Configure wrapper
|
|
| 294 | + -> BuildConfig
|
|
| 295 | +stage3CrossConfig triple hostKey emulator configure_wrapper =
|
|
| 296 | + vanilla { crossTarget = Just triple
|
|
| 297 | + , crossStage = Just 3
|
|
| 298 | + , platformKeyOverride = Just hostKey
|
|
| 299 | + , crossEmulator = emulator
|
|
| 300 | + , configureWrapper = configure_wrapper
|
|
| 301 | + }
|
|
| 302 | + |
|
| 287 | 303 | llvm :: BuildConfig
|
| 288 | 304 | llvm = vanilla { llvmBootstrap = True }
|
| 289 | 305 | |
| ... | ... | @@ -368,6 +384,7 @@ testEnv arch opsys bc = |
| 368 | 384 | , ["zstd" | withZstd bc ]
|
| 369 | 385 | , ["no_tntc" | not (tablesNextToCode bc) ]
|
| 370 | 386 | , ["cross_"++triple | Just triple <- pure $ crossTarget bc ]
|
| 387 | + , ["stage" ++ show stage | Just stage <- pure (crossStage bc), Just triple <- pure (crossTarget bc), "riscv" `isInfixOf` triple ]
|
|
| 371 | 388 | , [flavourString (mkJobFlavour bc)]
|
| 372 | 389 | ]
|
| 373 | 390 | |
| ... | ... | @@ -806,6 +823,7 @@ data Job |
| 806 | 823 | , jobCache :: Cache
|
| 807 | 824 | , jobRules :: OnOffRules
|
| 808 | 825 | , jobPlatform :: (Arch, Opsys)
|
| 826 | + , jobHostPlatformKey :: String
|
|
| 809 | 827 | }
|
| 810 | 828 | |
| 811 | 829 | instance Show Job where
|
| ... | ... | @@ -837,6 +855,8 @@ job arch opsys buildConfig = NamedJob { name = jobName, jobInfo = Job {..} } |
| 837 | 855 | where
|
| 838 | 856 | jobPlatform = (arch, opsys)
|
| 839 | 857 | |
| 858 | + jobHostPlatformKey = fromMaybe (mkPlatform arch opsys) (platformKeyOverride buildConfig)
|
|
| 859 | + |
|
| 840 | 860 | jobRules = emptyRules jobName
|
| 841 | 861 | |
| 842 | 862 | jobName = testEnv arch opsys buildConfig
|
| ... | ... | @@ -1285,13 +1305,16 @@ alpine_aarch64 = [ |
| 1285 | 1305 | cross_jobs :: [JobGroup Job]
|
| 1286 | 1306 | cross_jobs = [
|
| 1287 | 1307 | -- x86 -> aarch64
|
| 1288 | - validateBuilds Amd64 (Linux Debian13) (crossConfig "aarch64-linux-gnu" (Emulator "qemu-aarch64 -L /usr/aarch64-linux-gnu") Nothing)
|
|
| 1308 | + validateBuilds Amd64 (Linux Debian13) (stage2CrossConfig "aarch64-linux-gnu" (Emulator "qemu-aarch64 -L /usr/aarch64-linux-gnu") Nothing)
|
|
| 1309 | + |
|
| 1310 | + -- x86_64 (build/host) -> riscv (target)
|
|
| 1311 | + , addValidateRule RiscV (validateBuilds Amd64 (Linux Debian13Riscv) (stage2CrossConfig "riscv64-linux-gnu" (Emulator "qemu-riscv64 -L /usr/riscv64-linux-gnu") Nothing))
|
|
| 1289 | 1312 | |
| 1290 | - -- x86_64 -> riscv
|
|
| 1291 | - , addValidateRule RiscV (validateBuilds Amd64 (Linux Debian13Riscv) (crossConfig "riscv64-linux-gnu" (Emulator "qemu-riscv64 -L /usr/riscv64-linux-gnu") Nothing))
|
|
| 1313 | + -- x86_64 (build) -> riscv (host/target)
|
|
| 1314 | + , addValidateRule RiscV (validateBuilds Amd64 (Linux Debian13Riscv) (stage3CrossConfig "riscv64-linux-gnu" "riscv64-linux" (Emulator "qemu-riscv64 -L /usr/riscv64-linux-gnu") Nothing))
|
|
| 1292 | 1315 | |
| 1293 | 1316 | -- x86_64 -> loongarch64
|
| 1294 | - , addValidateRule LoongArch64 (validateBuilds Amd64 (Linux Ubuntu2404LoongArch64) (crossConfig "loongarch64-linux-gnu" (Emulator "qemu-loongarch64 -L /usr/loongarch64-linux-gnu") Nothing))
|
|
| 1317 | + , addValidateRule LoongArch64 (validateBuilds Amd64 (Linux Ubuntu2404LoongArch64) (stage2CrossConfig "loongarch64-linux-gnu" (Emulator "qemu-loongarch64 -L /usr/loongarch64-linux-gnu") Nothing))
|
|
| 1295 | 1318 | |
| 1296 | 1319 | -- Javascript
|
| 1297 | 1320 | , addValidateRule JSBackend (validateBuilds Amd64 (Linux Debian11Js) javascriptConfig)
|
| ... | ... | @@ -1312,7 +1335,7 @@ cross_jobs = [ |
| 1312 | 1335 | (validateBuilds AArch64 (Linux Debian12Wine) (winAarch64Config {llvmBootstrap = True}))
|
| 1313 | 1336 | ]
|
| 1314 | 1337 | where
|
| 1315 | - javascriptConfig = (crossConfig "javascript-unknown-ghcjs" (NoEmulatorNeeded TimeoutIncrease) (Just "emconfigure"))
|
|
| 1338 | + javascriptConfig = (stage2CrossConfig "javascript-unknown-ghcjs" (NoEmulatorNeeded TimeoutIncrease) (Just "emconfigure"))
|
|
| 1316 | 1339 | { bignumBackend = Native }
|
| 1317 | 1340 | |
| 1318 | 1341 | makeWinArmJobs = modifyJobs
|
| ... | ... | @@ -1351,7 +1374,7 @@ cross_jobs = [ |
| 1351 | 1374 | llvm_prefix = "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-"
|
| 1352 | 1375 | cflags = "-fuse-ld=" ++ llvm_prefix ++ "ld --rtlib=compiler-rt"
|
| 1353 | 1376 | |
| 1354 | - winAarch64Config = (crossConfig "aarch64-unknown-mingw32" (Emulator "/opt/wine-arm64ec-msys2-deb12/bin/wine") Nothing)
|
|
| 1377 | + winAarch64Config = (stage2CrossConfig "aarch64-unknown-mingw32" (Emulator "/opt/wine-arm64ec-msys2-deb12/bin/wine") Nothing)
|
|
| 1355 | 1378 | { bignumBackend = Native }
|
| 1356 | 1379 | |
| 1357 | 1380 | make_wasm_jobs cfg =
|
| ... | ... | @@ -1364,7 +1387,7 @@ cross_jobs = [ |
| 1364 | 1387 | $ addValidateRule WasmBackend $ validateBuilds Amd64 (Linux AlpineWasm) cfg
|
| 1365 | 1388 | |
| 1366 | 1389 | wasm_build_config =
|
| 1367 | - (crossConfig "wasm32-wasi" (NoEmulatorNeeded NoTimeoutIncrease) Nothing)
|
|
| 1390 | + (stage2CrossConfig "wasm32-wasi" (NoEmulatorNeeded NoTimeoutIncrease) Nothing)
|
|
| 1368 | 1391 | { hostFullyStatic = True
|
| 1369 | 1392 | , buildFlavour = Release -- TODO: This needs to be validate but wasm backend doesn't pass yet
|
| 1370 | 1393 | , textWithSIMDUTF = True
|
| ... | ... | @@ -1435,7 +1458,7 @@ platform_mapping = Map.map go combined_result |
| 1435 | 1458 | |
| 1436 | 1459 | process sel =
|
| 1437 | 1460 | Map.fromListWith combine
|
| 1438 | - [ (uncurry mkPlatform (jobPlatform (jobInfo j)), j)
|
|
| 1461 | + [ (jobHostPlatformKey (jobInfo j), j)
|
|
| 1439 | 1462 | | (sel -> Just j) <- job_groups
|
| 1440 | 1463 | ]
|
| 1441 | 1464 |
| ... | ... | @@ -2696,7 +2696,7 @@ |
| 2696 | 2696 | "XZ_OPT": "-9"
|
| 2697 | 2697 | }
|
| 2698 | 2698 | },
|
| 2699 | - "nightly-x86_64-linux-deb13-riscv-cross_riscv64-linux-gnu-validate": {
|
|
| 2699 | + "nightly-x86_64-linux-deb13-riscv-cross_riscv64-linux-gnu-stage2-validate": {
|
|
| 2700 | 2700 | "after_script": [
|
| 2701 | 2701 | ".gitlab/ci.sh save_cache",
|
| 2702 | 2702 | ".gitlab/ci.sh save_test_output",
|
| ... | ... | @@ -2707,7 +2707,7 @@ |
| 2707 | 2707 | "artifacts": {
|
| 2708 | 2708 | "expire_in": "8 weeks",
|
| 2709 | 2709 | "paths": [
|
| 2710 | - "ghc-x86_64-linux-deb13-riscv-cross_riscv64-linux-gnu-validate.tar.xz",
|
|
| 2710 | + "ghc-x86_64-linux-deb13-riscv-cross_riscv64-linux-gnu-stage2-validate.tar.xz",
|
|
| 2711 | 2711 | "junit.xml",
|
| 2712 | 2712 | "unexpected-test-output.tar.gz"
|
| 2713 | 2713 | ],
|
| ... | ... | @@ -2750,7 +2750,7 @@ |
| 2750 | 2750 | ],
|
| 2751 | 2751 | "variables": {
|
| 2752 | 2752 | "BIGNUM_BACKEND": "gmp",
|
| 2753 | - "BIN_DIST_NAME": "ghc-x86_64-linux-deb13-riscv-cross_riscv64-linux-gnu-validate",
|
|
| 2753 | + "BIN_DIST_NAME": "ghc-x86_64-linux-deb13-riscv-cross_riscv64-linux-gnu-stage2-validate",
|
|
| 2754 | 2754 | "BUILD_FLAVOUR": "validate",
|
| 2755 | 2755 | "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check",
|
| 2756 | 2756 | "CROSS_EMULATOR": "qemu-riscv64 -L /usr/riscv64-linux-gnu",
|
| ... | ... | @@ -2758,7 +2758,73 @@ |
| 2758 | 2758 | "CROSS_TARGET": "riscv64-linux-gnu",
|
| 2759 | 2759 | "INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
|
| 2760 | 2760 | "RUNTEST_ARGS": "-e config.timeout=900",
|
| 2761 | - "TEST_ENV": "x86_64-linux-deb13-riscv-cross_riscv64-linux-gnu-validate",
|
|
| 2761 | + "TEST_ENV": "x86_64-linux-deb13-riscv-cross_riscv64-linux-gnu-stage2-validate",
|
|
| 2762 | + "XZ_OPT": "-9"
|
|
| 2763 | + }
|
|
| 2764 | + },
|
|
| 2765 | + "nightly-x86_64-linux-deb13-riscv-cross_riscv64-linux-gnu-stage3-validate": {
|
|
| 2766 | + "after_script": [
|
|
| 2767 | + ".gitlab/ci.sh save_cache",
|
|
| 2768 | + ".gitlab/ci.sh save_test_output",
|
|
| 2769 | + ".gitlab/ci.sh clean",
|
|
| 2770 | + "cat ci_timings.txt"
|
|
| 2771 | + ],
|
|
| 2772 | + "allow_failure": false,
|
|
| 2773 | + "artifacts": {
|
|
| 2774 | + "expire_in": "8 weeks",
|
|
| 2775 | + "paths": [
|
|
| 2776 | + "ghc-x86_64-linux-deb13-riscv-cross_riscv64-linux-gnu-stage3-validate.tar.xz",
|
|
| 2777 | + "junit.xml",
|
|
| 2778 | + "unexpected-test-output.tar.gz"
|
|
| 2779 | + ],
|
|
| 2780 | + "reports": {
|
|
| 2781 | + "junit": "junit.xml"
|
|
| 2782 | + },
|
|
| 2783 | + "when": "always"
|
|
| 2784 | + },
|
|
| 2785 | + "cache": {
|
|
| 2786 | + "key": "x86_64-linux-deb13-riscv-$CACHE_REV",
|
|
| 2787 | + "paths": [
|
|
| 2788 | + "cabal-cache",
|
|
| 2789 | + "toolchain"
|
|
| 2790 | + ]
|
|
| 2791 | + },
|
|
| 2792 | + "dependencies": [],
|
|
| 2793 | + "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb13-riscv:$DOCKER_REV",
|
|
| 2794 | + "needs": [
|
|
| 2795 | + {
|
|
| 2796 | + "artifacts": false,
|
|
| 2797 | + "job": "hadrian-ghc-in-ghci"
|
|
| 2798 | + }
|
|
| 2799 | + ],
|
|
| 2800 | + "rules": [
|
|
| 2801 | + {
|
|
| 2802 | + "if": "(\"true\" == \"true\") && ($RELEASE_JOB != \"yes\") && ($NIGHTLY)",
|
|
| 2803 | + "when": "on_success"
|
|
| 2804 | + }
|
|
| 2805 | + ],
|
|
| 2806 | + "script": [
|
|
| 2807 | + "sudo chown ghc:ghc -R .",
|
|
| 2808 | + ".gitlab/ci.sh setup",
|
|
| 2809 | + ".gitlab/ci.sh configure",
|
|
| 2810 | + ".gitlab/ci.sh build_hadrian",
|
|
| 2811 | + ".gitlab/ci.sh test_hadrian"
|
|
| 2812 | + ],
|
|
| 2813 | + "stage": "full-build",
|
|
| 2814 | + "tags": [
|
|
| 2815 | + "x86_64-linux"
|
|
| 2816 | + ],
|
|
| 2817 | + "variables": {
|
|
| 2818 | + "BIGNUM_BACKEND": "gmp",
|
|
| 2819 | + "BIN_DIST_NAME": "ghc-x86_64-linux-deb13-riscv-cross_riscv64-linux-gnu-stage3-validate",
|
|
| 2820 | + "BUILD_FLAVOUR": "validate",
|
|
| 2821 | + "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check",
|
|
| 2822 | + "CROSS_EMULATOR": "qemu-riscv64 -L /usr/riscv64-linux-gnu",
|
|
| 2823 | + "CROSS_STAGE": "3",
|
|
| 2824 | + "CROSS_TARGET": "riscv64-linux-gnu",
|
|
| 2825 | + "INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
|
|
| 2826 | + "RUNTEST_ARGS": "-e config.timeout=900",
|
|
| 2827 | + "TEST_ENV": "x86_64-linux-deb13-riscv-cross_riscv64-linux-gnu-stage3-validate",
|
|
| 2762 | 2828 | "XZ_OPT": "-9"
|
| 2763 | 2829 | }
|
| 2764 | 2830 | },
|
| ... | ... | @@ -6611,7 +6677,7 @@ |
| 6611 | 6677 | "TEST_ENV": "x86_64-linux-deb13-release"
|
| 6612 | 6678 | }
|
| 6613 | 6679 | },
|
| 6614 | - "x86_64-linux-deb13-riscv-cross_riscv64-linux-gnu-validate": {
|
|
| 6680 | + "x86_64-linux-deb13-riscv-cross_riscv64-linux-gnu-stage2-validate": {
|
|
| 6615 | 6681 | "after_script": [
|
| 6616 | 6682 | ".gitlab/ci.sh save_cache",
|
| 6617 | 6683 | ".gitlab/ci.sh save_test_output",
|
| ... | ... | @@ -6622,7 +6688,7 @@ |
| 6622 | 6688 | "artifacts": {
|
| 6623 | 6689 | "expire_in": "2 weeks",
|
| 6624 | 6690 | "paths": [
|
| 6625 | - "ghc-x86_64-linux-deb13-riscv-cross_riscv64-linux-gnu-validate.tar.xz",
|
|
| 6691 | + "ghc-x86_64-linux-deb13-riscv-cross_riscv64-linux-gnu-stage2-validate.tar.xz",
|
|
| 6626 | 6692 | "junit.xml",
|
| 6627 | 6693 | "unexpected-test-output.tar.gz"
|
| 6628 | 6694 | ],
|
| ... | ... | @@ -6648,7 +6714,7 @@ |
| 6648 | 6714 | ],
|
| 6649 | 6715 | "rules": [
|
| 6650 | 6716 | {
|
| 6651 | - "if": "((($ONLY_JOBS) && ($ONLY_JOBS =~ /.*\\bx86_64-linux-deb13-riscv-cross_riscv64-linux-gnu-validate(\\s|$).*/)) || (($ONLY_JOBS == null) && ((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/)) || ($CI_MERGE_REQUEST_LABELS =~ /.*RISC-V.*/)))) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)",
|
|
| 6717 | + "if": "((($ONLY_JOBS) && ($ONLY_JOBS =~ /.*\\bx86_64-linux-deb13-riscv-cross_riscv64-linux-gnu-stage2-validate(\\s|$).*/)) || (($ONLY_JOBS == null) && ((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/)) || ($CI_MERGE_REQUEST_LABELS =~ /.*RISC-V.*/)))) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)",
|
|
| 6652 | 6718 | "when": "on_success"
|
| 6653 | 6719 | }
|
| 6654 | 6720 | ],
|
| ... | ... | @@ -6665,7 +6731,7 @@ |
| 6665 | 6731 | ],
|
| 6666 | 6732 | "variables": {
|
| 6667 | 6733 | "BIGNUM_BACKEND": "gmp",
|
| 6668 | - "BIN_DIST_NAME": "ghc-x86_64-linux-deb13-riscv-cross_riscv64-linux-gnu-validate",
|
|
| 6734 | + "BIN_DIST_NAME": "ghc-x86_64-linux-deb13-riscv-cross_riscv64-linux-gnu-stage2-validate",
|
|
| 6669 | 6735 | "BUILD_FLAVOUR": "validate",
|
| 6670 | 6736 | "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check",
|
| 6671 | 6737 | "CROSS_EMULATOR": "qemu-riscv64 -L /usr/riscv64-linux-gnu",
|
| ... | ... | @@ -6673,7 +6739,72 @@ |
| 6673 | 6739 | "CROSS_TARGET": "riscv64-linux-gnu",
|
| 6674 | 6740 | "INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
|
| 6675 | 6741 | "RUNTEST_ARGS": "-e config.timeout=900",
|
| 6676 | - "TEST_ENV": "x86_64-linux-deb13-riscv-cross_riscv64-linux-gnu-validate"
|
|
| 6742 | + "TEST_ENV": "x86_64-linux-deb13-riscv-cross_riscv64-linux-gnu-stage2-validate"
|
|
| 6743 | + }
|
|
| 6744 | + },
|
|
| 6745 | + "x86_64-linux-deb13-riscv-cross_riscv64-linux-gnu-stage3-validate": {
|
|
| 6746 | + "after_script": [
|
|
| 6747 | + ".gitlab/ci.sh save_cache",
|
|
| 6748 | + ".gitlab/ci.sh save_test_output",
|
|
| 6749 | + ".gitlab/ci.sh clean",
|
|
| 6750 | + "cat ci_timings.txt"
|
|
| 6751 | + ],
|
|
| 6752 | + "allow_failure": false,
|
|
| 6753 | + "artifacts": {
|
|
| 6754 | + "expire_in": "2 weeks",
|
|
| 6755 | + "paths": [
|
|
| 6756 | + "ghc-x86_64-linux-deb13-riscv-cross_riscv64-linux-gnu-stage3-validate.tar.xz",
|
|
| 6757 | + "junit.xml",
|
|
| 6758 | + "unexpected-test-output.tar.gz"
|
|
| 6759 | + ],
|
|
| 6760 | + "reports": {
|
|
| 6761 | + "junit": "junit.xml"
|
|
| 6762 | + },
|
|
| 6763 | + "when": "always"
|
|
| 6764 | + },
|
|
| 6765 | + "cache": {
|
|
| 6766 | + "key": "x86_64-linux-deb13-riscv-$CACHE_REV",
|
|
| 6767 | + "paths": [
|
|
| 6768 | + "cabal-cache",
|
|
| 6769 | + "toolchain"
|
|
| 6770 | + ]
|
|
| 6771 | + },
|
|
| 6772 | + "dependencies": [],
|
|
| 6773 | + "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb13-riscv:$DOCKER_REV",
|
|
| 6774 | + "needs": [
|
|
| 6775 | + {
|
|
| 6776 | + "artifacts": false,
|
|
| 6777 | + "job": "hadrian-ghc-in-ghci"
|
|
| 6778 | + }
|
|
| 6779 | + ],
|
|
| 6780 | + "rules": [
|
|
| 6781 | + {
|
|
| 6782 | + "if": "((($ONLY_JOBS) && ($ONLY_JOBS =~ /.*\\bx86_64-linux-deb13-riscv-cross_riscv64-linux-gnu-stage3-validate(\\s|$).*/)) || (($ONLY_JOBS == null) && ((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/)) || ($CI_MERGE_REQUEST_LABELS =~ /.*RISC-V.*/)))) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)",
|
|
| 6783 | + "when": "on_success"
|
|
| 6784 | + }
|
|
| 6785 | + ],
|
|
| 6786 | + "script": [
|
|
| 6787 | + "sudo chown ghc:ghc -R .",
|
|
| 6788 | + ".gitlab/ci.sh setup",
|
|
| 6789 | + ".gitlab/ci.sh configure",
|
|
| 6790 | + ".gitlab/ci.sh build_hadrian",
|
|
| 6791 | + ".gitlab/ci.sh test_hadrian"
|
|
| 6792 | + ],
|
|
| 6793 | + "stage": "full-build",
|
|
| 6794 | + "tags": [
|
|
| 6795 | + "x86_64-linux"
|
|
| 6796 | + ],
|
|
| 6797 | + "variables": {
|
|
| 6798 | + "BIGNUM_BACKEND": "gmp",
|
|
| 6799 | + "BIN_DIST_NAME": "ghc-x86_64-linux-deb13-riscv-cross_riscv64-linux-gnu-stage3-validate",
|
|
| 6800 | + "BUILD_FLAVOUR": "validate",
|
|
| 6801 | + "CONFIGURE_ARGS": "--with-intree-gmp --enable-strict-ghc-toolchain-check",
|
|
| 6802 | + "CROSS_EMULATOR": "qemu-riscv64 -L /usr/riscv64-linux-gnu",
|
|
| 6803 | + "CROSS_STAGE": "3",
|
|
| 6804 | + "CROSS_TARGET": "riscv64-linux-gnu",
|
|
| 6805 | + "INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
|
|
| 6806 | + "RUNTEST_ARGS": "-e config.timeout=900",
|
|
| 6807 | + "TEST_ENV": "x86_64-linux-deb13-riscv-cross_riscv64-linux-gnu-stage3-validate"
|
|
| 6677 | 6808 | }
|
| 6678 | 6809 | },
|
| 6679 | 6810 | "x86_64-linux-deb13-unreg-validate": {
|
| ... | ... | @@ -3,26 +3,28 @@ module BindistConfig where |
| 3 | 3 | import Stage
|
| 4 | 4 | import Oracles.Flag
|
| 5 | 5 | import Expression
|
| 6 | +import UserSettings (finalStage)
|
|
| 6 | 7 | |
| 7 | 8 | data BindistConfig = BindistConfig { library_stage :: Stage -- ^ The stage compiler which builds the libraries
|
| 8 | 9 | , executable_stage :: Stage -- ^ The stage compiler which builds the executables
|
| 10 | + , use_inplace_ghcPkg :: Bool -- ^ Which ghc-pkg to use (targetBindist's ghc-pkg cannot run on the build platform)
|
|
| 9 | 11 | }
|
| 10 | 12 | |
| 11 | 13 | -- | A bindist for when the host = target, non cross-compilation setting.
|
| 12 | 14 | -- Both the libraries and final executables are built with stage1 compiler.
|
| 13 | 15 | normalBindist :: BindistConfig
|
| 14 | -normalBindist = BindistConfig { library_stage = Stage1, executable_stage = Stage1 }
|
|
| 16 | +normalBindist = BindistConfig { library_stage = Stage1, executable_stage = Stage1, use_inplace_ghcPkg = True }
|
|
| 15 | 17 | |
| 16 | 18 | -- | A bindist which contains a cross compiler (when host /= target)
|
| 17 | 19 | -- The cross compiler is produced by the stage1 compiler, but then we must compile
|
| 18 | 20 | -- all the boot libraries with the cross compiler (hence stage2 for libraries)
|
| 19 | 21 | crossBindist :: BindistConfig
|
| 20 | -crossBindist = BindistConfig { library_stage = Stage2, executable_stage = Stage1 }
|
|
| 22 | +crossBindist = BindistConfig { library_stage = Stage2, executable_stage = Stage1, use_inplace_ghcPkg = True }
|
|
| 21 | 23 | |
| 22 | 24 | -- | A bindist which contains executables for the target, which produce code for the
|
| 23 | 25 | -- target. These are produced as "Stage3" build products, produced by a stage2 cross compiler.
|
| 24 | 26 | targetBindist :: BindistConfig
|
| 25 | -targetBindist = BindistConfig { library_stage = Stage2, executable_stage = Stage2 }
|
|
| 27 | +targetBindist = BindistConfig { library_stage = Stage2, executable_stage = Stage2, use_inplace_ghcPkg = False }
|
|
| 26 | 28 | |
| 27 | 29 | |
| 28 | 30 | -- | The implicit bindist config, if we don't know any better.
|
| ... | ... | @@ -32,7 +34,9 @@ implicitBindistConfig = do |
| 32 | 34 | -- libraries built for the host, but the distributed compiler would produce files for
|
| 33 | 35 | -- the target.
|
| 34 | 36 | cross <- flag CrossCompiling
|
| 35 | - return $ if cross then crossBindist else normalBindist
|
|
| 37 | + if not cross
|
|
| 38 | + then return normalBindist
|
|
| 39 | + else return $ if finalStage == Stage3 then targetBindist else crossBindist
|
|
| 36 | 40 | |
| 37 | 41 | -- | Are we building things in this stage for the final target?
|
| 38 | 42 | buildingForTarget :: Stage -> Action Bool
|
| ... | ... | @@ -110,12 +110,12 @@ other, the install script: |
| 110 | 110 | |
| 111 | 111 | data Relocatable = Relocatable | NotRelocatable
|
| 112 | 112 | |
| 113 | -installTo :: Relocatable -> String -> Action ()
|
|
| 114 | -installTo relocatable prefix = do
|
|
| 113 | +installTo :: Relocatable -> FilePath -> String -> Action ()
|
|
| 114 | +installTo relocatable dirSuffix prefix = do
|
|
| 115 | 115 | root <- buildRoot
|
| 116 | 116 | version <- setting ProjectVersion
|
| 117 | 117 | targetPlatform <- setting TargetPlatformFull
|
| 118 | - let ghcVersionPretty = "ghc-" ++ version ++ "-" ++ targetPlatform
|
|
| 118 | + let ghcVersionPretty = "ghc-" ++ version ++ "-" ++ targetPlatform <> dirSuffix
|
|
| 119 | 119 | bindistFilesDir = root -/- "bindist" -/- ghcVersionPretty
|
| 120 | 120 | runBuilder (Configure bindistFilesDir) ["--prefix="++prefix] [] []
|
| 121 | 121 | let env = case relocatable of
|
| ... | ... | @@ -124,8 +124,8 @@ installTo relocatable prefix = do |
| 124 | 124 | runBuilderWithCmdOptions env (Make bindistFilesDir) ["install"] [] []
|
| 125 | 125 | |
| 126 | 126 | |
| 127 | -buildBinDistDir :: FilePath -> BindistConfig -> Action ()
|
|
| 128 | -buildBinDistDir root conf@BindistConfig{..} = do
|
|
| 127 | +buildBinDistDir :: FilePath -> FilePath -> BindistConfig -> Action ()
|
|
| 128 | +buildBinDistDir dirSuffix root conf@BindistConfig{..} = do
|
|
| 129 | 129 | |
| 130 | 130 | verbosity <- getVerbosity
|
| 131 | 131 | -- We 'need' all binaries and libraries
|
| ... | ... | @@ -155,7 +155,7 @@ buildBinDistDir root conf@BindistConfig{..} = do |
| 155 | 155 | distDir <- Context.distDir (vanillaContext library_stage rts)
|
| 156 | 156 | |
| 157 | 157 | let ghcBuildDir = root -/- stageString library_stage
|
| 158 | - bindistFilesDir = root -/- "bindist" -/- ghcVersionPretty
|
|
| 158 | + bindistFilesDir = root -/- "bindist" -/- ghcVersionPretty <> dirSuffix
|
|
| 159 | 159 | ghcVersionPretty = "ghc-" ++ version ++ "-" ++ targetPlatform
|
| 160 | 160 | rtsIncludeDir = distDir -/- "include"
|
| 161 | 161 | |
| ... | ... | @@ -228,7 +228,7 @@ buildBinDistDir root conf@BindistConfig{..} = do |
| 228 | 228 | let bindistSettings = bindistFilesDir -/- "lib" -/- "settings"
|
| 229 | 229 | bindistContext = vanillaContext library_stage compiler
|
| 230 | 230 | bindistSettingsContent <- interpretInContext bindistContext $
|
| 231 | - generateSettings bindistSettings False "package.conf.d"
|
|
| 231 | + generateSettings bindistSettings False "package.conf.d" executable_stage
|
|
| 232 | 232 | writeFile' bindistSettings bindistSettingsContent
|
| 233 | 233 | |
| 234 | 234 | copyDirectory rtsIncludeDir bindistFilesDir
|
| ... | ... | @@ -240,10 +240,16 @@ buildBinDistDir root conf@BindistConfig{..} = do |
| 240 | 240 | --
|
| 241 | 241 | -- N.B. the ghc-pkg executable may be prefixed with a target triple
|
| 242 | 242 | -- (c.f. #20267).
|
| 243 | - |
|
| 244 | - -- Not going to work for cross
|
|
| 245 | - ghcPkgName <- programName (vanillaContext Stage1 ghcPkg)
|
|
| 246 | - cmd_ (bindistFilesDir -/- "bin" -/- ghcPkgName) ["recache", "--package-db", bindistFilesDir -/- "lib" -/- "package.conf.d" ]
|
|
| 243 | + --
|
|
| 244 | + -- For Stage3 cross-compilers (those that are supposed to run on the target
|
|
| 245 | + -- platform), we have to resort to a prior stage's ghc-pkg as the final
|
|
| 246 | + -- stage can naturally not be executed on our current build host.
|
|
| 247 | + if use_inplace_ghcPkg then do
|
|
| 248 | + ghcPkgName <- programName (vanillaContext executable_stage ghcPkg)
|
|
| 249 | + cmd_ (bindistFilesDir -/- "bin" -/- ghcPkgName) ["recache", "--package-db", bindistFilesDir -/- "lib" -/- "package.conf.d" ]
|
|
| 250 | + else do
|
|
| 251 | + ghcPkgPath <- builderPath $ GhcPkg Recache library_stage
|
|
| 252 | + cmd_ ghcPkgPath ["recache", "--package-db", bindistFilesDir -/- "lib" -/- "package.conf.d" ]
|
|
| 247 | 253 | |
| 248 | 254 | |
| 249 | 255 | need ["docs"]
|
| ... | ... | @@ -318,45 +324,45 @@ buildBinDistDir root conf@BindistConfig{..} = do |
| 318 | 324 | bindistRules :: Rules ()
|
| 319 | 325 | bindistRules = do
|
| 320 | 326 | root <- buildRootRules
|
| 321 | - phony "reloc-binary-dist-dir" $ do
|
|
| 322 | - need ["binary-dist-dir"]
|
|
| 327 | + forM_ ["", "-stage3"] $ \suffix -> do
|
|
| 328 | + phony ("reloc-binary-dist-dir" ++ suffix) $ do
|
|
| 329 | + need ["binary-dist-dir" ++ suffix]
|
|
| 323 | 330 | cwd <- liftIO IO.getCurrentDirectory
|
| 324 | 331 | version <- setting ProjectVersion
|
| 325 | 332 | targetPlatform <- setting TargetPlatformFull
|
| 326 | - let ghcVersionPretty = "ghc-" ++ version ++ "-" ++ targetPlatform
|
|
| 327 | - let prefix = cwd -/- root -/- "reloc-bindist" -/- ghcVersionPretty
|
|
| 328 | - installTo Relocatable prefix
|
|
| 333 | + let prefix = cwd -/- root -/- "reloc-bindist" -/- ("ghc-" ++ version ++ "-" ++ targetPlatform ++ suffix)
|
|
| 334 | + installTo Relocatable suffix prefix
|
|
| 329 | 335 | |
| 330 | - phony "install" $ do
|
|
| 331 | - need ["binary-dist-dir"]
|
|
| 336 | + phony ("install" ++ suffix) $ do
|
|
| 337 | + need ["binary-dist-dir" ++ suffix]
|
|
| 332 | 338 | let prefixErr = "You must specify a path with --prefix when using the"
|
| 333 | - ++ " 'install' rule"
|
|
| 339 | + ++ " 'install" ++ suffix ++ "' rule"
|
|
| 334 | 340 | installPrefix <- fromMaybe (error prefixErr) <$> cmdPrefix
|
| 335 | - installTo NotRelocatable installPrefix
|
|
| 341 | + installTo NotRelocatable suffix installPrefix
|
|
| 336 | 342 | |
| 337 | 343 | phony "binary-dist-dir" $ do
|
| 338 | 344 | cfg <- implicitBindistConfig
|
| 339 | - buildBinDistDir root cfg
|
|
| 345 | + buildBinDistDir "" root cfg
|
|
| 340 | 346 | |
| 341 | - phony "binary-dist-dir-cross" $ buildBinDistDir root crossBindist
|
|
| 342 | - -- MP: Not working yet
|
|
| 343 | - -- phony "binary-dist-dir-stage3" $ buildBinDistDir root targetBindist
|
|
| 347 | + phony "binary-dist-dir-cross" $ buildBinDistDir "" root crossBindist
|
|
| 348 | + |
|
| 349 | + phony "binary-dist-dir-stage3" $ buildBinDistDir "-stage3" root targetBindist
|
|
| 344 | 350 | |
| 345 | 351 | let buildBinDist compressor = do
|
| 346 | 352 | win_host <- isWinHost
|
| 347 | 353 | win_target <- isWinTarget Stage2
|
| 348 | 354 | when (win_target && win_host) (error "normal binary-dist does not work for windows targets, use `reloc-binary-dist-*` target instead.")
|
| 349 | - buildBinDistX "binary-dist-dir" "bindist" compressor
|
|
| 350 | - buildBinDistReloc = buildBinDistX "reloc-binary-dist-dir" "reloc-bindist"
|
|
| 355 | + buildBinDistX "binary-dist-dir" "bindist" "" compressor
|
|
| 356 | + buildBinDistReloc = buildBinDistX "reloc-binary-dist-dir" "reloc-bindist" ""
|
|
| 351 | 357 | |
| 352 | - buildBinDistX :: String -> FilePath -> Compressor -> Action ()
|
|
| 353 | - buildBinDistX target bindist_folder compressor = do
|
|
| 358 | + buildBinDistX :: String -> FilePath -> FilePath -> Compressor -> Action ()
|
|
| 359 | + buildBinDistX target bindist_folder dirSuffix compressor = do
|
|
| 354 | 360 | need [target]
|
| 355 | 361 | |
| 356 | 362 | version <- setting ProjectVersion
|
| 357 | 363 | targetPlatform <- setting TargetPlatformFull
|
| 358 | 364 | |
| 359 | - let ghcVersionPretty = "ghc-" ++ version ++ "-" ++ targetPlatform
|
|
| 365 | + let ghcVersionPretty = "ghc-" ++ version ++ "-" ++ targetPlatform <> dirSuffix
|
|
| 360 | 366 | |
| 361 | 367 | -- Finally, we create the archive <root>/bindist/ghc-X.Y.Z-platform.tar.xz
|
| 362 | 368 | tarPath <- builderPath (Tar Create)
|
| ... | ... | @@ -371,14 +377,35 @@ bindistRules = do |
| 371 | 377 | phony (name <> "-dist-bzip2") $ mk_bindist Bzip2
|
| 372 | 378 | phony (name <> "-dist-xz") $ mk_bindist Xz
|
| 373 | 379 | |
| 374 | - phony "binary-dist-cross" $ buildBinDistX "binary-dist-dir-cross" "bindist" Xz
|
|
| 375 | - phony "binary-dist-stage3" $ buildBinDistX "binary-dist-dir-stage3" "bindist" Xz
|
|
| 380 | + phony "binary-dist-cross" $ buildBinDistX "binary-dist-dir-cross" "bindist" "" Xz
|
|
| 381 | + phony "binary-dist-stage3" $ buildBinDistX "binary-dist-dir-stage3" "bindist" "-stage3" Xz
|
|
| 376 | 382 | |
| 377 | 383 | -- Prepare binary distribution configure script
|
| 378 | 384 | -- (generated under <ghc root>/distrib/configure by 'autoreconf')
|
| 379 | - root -/- "bindist" -/- "ghc-*" -/- "configure" %> \configurePath -> do
|
|
| 380 | - need ["distrib" -/- "configure.ac"]
|
|
| 385 | + priority 2 $ root -/- "bindist" -/- "*ghc-*-stage3" -/- "configure" %> generateConfigure Stage2
|
|
| 386 | + root -/- "bindist" -/- "*ghc-*" -/- "configure" %> generateConfigure Stage1
|
|
| 387 | + |
|
| 388 | + -- Generate the Makefile that enables the "make install" part
|
|
| 389 | + root -/- "bindist" -/- "*ghc-*" -/- "Makefile" %> \makefilePath -> do
|
|
| 390 | + top <- topDirectory
|
|
| 391 | + copyFile (top -/- "hadrian" -/- "bindist" -/- "Makefile") makefilePath
|
|
| 392 | + |
|
| 393 | + -- Copy various configure-related files needed for a working
|
|
| 394 | + -- './configure [...] && make install' workflow
|
|
| 395 | + -- (see the list of files needed in the 'binary-dist' rule above, before
|
|
| 396 | + -- creating the archive).
|
|
| 397 | + forM_ bindistInstallFiles $ \file ->
|
|
| 398 | + root -/- "bindist" -/- "*ghc-*" -/- file %> \dest -> do
|
|
| 399 | + copyFile (fixup file) dest
|
|
| 400 | + |
|
| 401 | + where
|
|
| 402 | + fixup f | f `elem` ["INSTALL", "README"] = "distrib" -/- f
|
|
| 403 | + | otherwise = f
|
|
| 404 | + generateConfigure stage configurePath = do
|
|
| 405 | + let acFile = stageString stage -/- "distrib" -/- "configure.ac"
|
|
| 406 | + need [acFile]
|
|
| 381 | 407 | ghcRoot <- topDirectory
|
| 408 | + copyFile (ghcRoot -/- acFile) (ghcRoot -/- "distrib" -/- "configure.ac")
|
|
| 382 | 409 | copyFile (ghcRoot -/- "aclocal.m4") (ghcRoot -/- "distrib" -/- "aclocal.m4")
|
| 383 | 410 | copyDirectory (ghcRoot -/- "m4") (ghcRoot -/- "distrib")
|
| 384 | 411 | |
| ... | ... | @@ -401,30 +428,12 @@ bindistRules = do |
| 401 | 428 | |
| 402 | 429 | buildWithCmdOptions env $
|
| 403 | 430 | target (vanillaContext Stage1 ghc) (Autoreconf $ ghcRoot -/- "distrib") [] []
|
| 404 | - -- We clean after ourselves, moving the configure script we generated in
|
|
| 405 | - -- our bindist dir
|
|
| 431 | + removeFile (ghcRoot -/- acFile)
|
|
| 432 | + removeFile (ghcRoot -/- "distrib" -/- "configure.ac")
|
|
| 406 | 433 | removeFile (ghcRoot -/- "distrib" -/- "aclocal.m4")
|
| 407 | 434 | removeDirectory (ghcRoot -/- "distrib" -/- "m4")
|
| 408 | - |
|
| 409 | 435 | moveFile (ghcRoot -/- "distrib" -/- "configure") configurePath
|
| 410 | 436 | |
| 411 | - -- Generate the Makefile that enables the "make install" part
|
|
| 412 | - root -/- "bindist" -/- "ghc-*" -/- "Makefile" %> \makefilePath -> do
|
|
| 413 | - top <- topDirectory
|
|
| 414 | - copyFile (top -/- "hadrian" -/- "bindist" -/- "Makefile") makefilePath
|
|
| 415 | - |
|
| 416 | - -- Copy various configure-related files needed for a working
|
|
| 417 | - -- './configure [...] && make install' workflow
|
|
| 418 | - -- (see the list of files needed in the 'binary-dist' rule above, before
|
|
| 419 | - -- creating the archive).
|
|
| 420 | - forM_ bindistInstallFiles $ \file ->
|
|
| 421 | - root -/- "bindist" -/- "ghc-*" -/- file %> \dest -> do
|
|
| 422 | - copyFile (fixup file) dest
|
|
| 423 | - |
|
| 424 | - where
|
|
| 425 | - fixup f | f `elem` ["INSTALL", "README"] = "distrib" -/- f
|
|
| 426 | - | otherwise = f
|
|
| 427 | - |
|
| 428 | 437 | data Compressor = Gzip | Bzip2 | Xz
|
| 429 | 438 | deriving (Eq, Ord, Show)
|
| 430 | 439 | |
| ... | ... | @@ -499,7 +508,7 @@ pkgToWrappers stage pkg = do |
| 499 | 508 | -- These are the packages which we want to expose to the user and hence
|
| 500 | 509 | -- there are wrappers installed in the bindist.
|
| 501 | 510 | | pkg `elem` [hpcBin, haddock, hp2ps, hsc2hs, ghc, ghcPkg]
|
| 502 | - -> (:[]) <$> (programName =<< programContext Stage1 pkg)
|
|
| 511 | + -> (:[]) <$> (programName =<< programContext stage pkg)
|
|
| 503 | 512 | | otherwise -> pure []
|
| 504 | 513 | |
| 505 | 514 | wrapper :: Stage -> FilePath -> Action String
|
| ... | ... | @@ -67,13 +67,15 @@ cabalBuildRules = do |
| 67 | 67 | |
| 68 | 68 | let cabal_package_db = cwd -/- root -/- "stage-cabal" -/- "dist-newstyle" -/- "packagedb" -/- "ghc-" ++ version
|
| 69 | 69 | |
| 70 | + cfg <- implicitBindistConfig
|
|
| 71 | + let compilerStage = executable_stage cfg
|
|
| 70 | 72 | forM_ bin_targets $ \(bin_pkg,_bin_path) -> do
|
| 71 | 73 | let pgmName pkg
|
| 72 | 74 | | pkg == ghc = "ghc"
|
| 73 | 75 | | pkg == hpcBin = "hpc"
|
| 74 | 76 | | otherwise = pkgName pkg
|
| 75 | 77 | let cabal_bin_out = work_dir -/- "cabal-bin" -/- (pgmName bin_pkg)
|
| 76 | - needed_wrappers <- pkgToWrappers Stage2 bin_pkg
|
|
| 78 | + needed_wrappers <- pkgToWrappers compilerStage bin_pkg
|
|
| 77 | 79 | forM_ needed_wrappers $ \wrapper_name -> do
|
| 78 | 80 | let wrapper_prefix = unlines
|
| 79 | 81 | ["#!/usr/bin/env sh"
|
| ... | ... | @@ -85,7 +87,7 @@ cabalBuildRules = do |
| 85 | 87 | ,"export GHC_PACKAGE_PATH="++show cabal_package_db++":"
|
| 86 | 88 | ]
|
| 87 | 89 | output_file = outputDir -/- wrapper_name
|
| 88 | - wrapper_content <- wrapper Stage2 wrapper_name
|
|
| 90 | + wrapper_content <- wrapper compilerStage wrapper_name
|
|
| 89 | 91 | writeFile' output_file (wrapper_prefix ++ wrapper_content)
|
| 90 | 92 | makeExecutable output_file
|
| 91 | 93 | pure ()
|
| ... | ... | @@ -275,7 +275,7 @@ generateRules = do |
| 275 | 275 | then root -/- stageString stage' -/- "lib"
|
| 276 | 276 | else prefix
|
| 277 | 277 | relPkgDb = makeRelativeNoSysLink libTopDir pkgDb
|
| 278 | - go (generateSettings out True relPkgDb) out
|
|
| 278 | + go (generateSettings out True relPkgDb (predStage stage')) out
|
|
| 279 | 279 | (prefix -/- "targets" -/- "default.target") %> \out -> go (show <$> expr (targetStage (succStage stage))) out
|
| 280 | 280 | |
| 281 | 281 | where
|
| ... | ... | @@ -360,6 +360,11 @@ templateRule :: FilePath -> Interpolations -> Rules () |
| 360 | 360 | templateRule outPath =
|
| 361 | 361 | templateRuleFrom (outPath <.> "in") outPath
|
| 362 | 362 | |
| 363 | +templateRuleForStages :: FilePath -> (Stage -> Interpolations) -> Rules ()
|
|
| 364 | +templateRuleForStages outPath mkInterps =
|
|
| 365 | + forM_ [Stage1, Stage2] $ \stage ->
|
|
| 366 | + templateRuleFrom (outPath <.> "in") (stageString stage -/- outPath) (mkInterps stage)
|
|
| 367 | + |
|
| 363 | 368 | templateRules :: Rules ()
|
| 364 | 369 | templateRules = do
|
| 365 | 370 | templateRule "compiler/ghc.cabal" $ projectVersion
|
| ... | ... | @@ -427,12 +432,13 @@ bindistRules = do |
| 427 | 432 | , interpolateVar "TargetOS_CPP" $ cppify <$> getTarget queryOS
|
| 428 | 433 | , interpolateVar "LLVMTarget" $ getTarget tgtLlvmTarget
|
| 429 | 434 | ]
|
| 430 | - templateRule ("distrib" -/- "configure.ac") $ mconcat
|
|
| 435 | + templateRuleForStages ("distrib" -/- "configure.ac") $ \stage -> mconcat
|
|
| 431 | 436 | [ interpolateSetting "ConfiguredEmsdkVersion" EmsdkVersion
|
| 432 | 437 | , interpolateVar "CrossCompilePrefix" $ do
|
| 433 | - crossCompiling <- interp $ getFlag CrossCompiling
|
|
| 434 | - tpf <- setting TargetPlatformFull
|
|
| 435 | - pure $ if crossCompiling then tpf <> "-" else ""
|
|
| 438 | + cross <- interp $ getFlag CrossCompiling
|
|
| 439 | + isCross <- crossStage stage
|
|
| 440 | + target <- setting TargetPlatformFull
|
|
| 441 | + pure $ if cross && isCross then target <> "-" else ""
|
|
| 436 | 442 | , interpolateVar "LeadingUnderscore" $ yesNo <$> getTarget tgtSymbolsHaveLeadingUnderscore
|
| 437 | 443 | , interpolateSetting "LlvmMaxVersion" LlvmMaxVersion
|
| 438 | 444 | , interpolateSetting "LlvmMinVersion" LlvmMinVersion
|
| ... | ... | @@ -442,8 +448,8 @@ bindistRules = do |
| 442 | 448 | , interpolateVar "TablesNextToCode" $ yesNo <$> getTarget tgtTablesNextToCode
|
| 443 | 449 | , interpolateVar "TargetHasLibm" $ yesNo <$> interp (staged (buildFlag TargetHasLibm))
|
| 444 | 450 | , interpolateVar "TargetPlatform" $ getTarget targetPlatformTriple
|
| 445 | - , interpolateVar "BuildPlatform" $ interp $ queryBuild targetPlatformTriple
|
|
| 446 | - , interpolateVar "HostPlatform" $ interp $ queryHost targetPlatformTriple
|
|
| 451 | + , interpolateVar "BuildPlatform" $ ifM (not <$> crossStage stage) (getTarget targetPlatformTriple) (interp $ queryBuild targetPlatformTriple)
|
|
| 452 | + , interpolateVar "HostPlatform" $ ifM (not <$> crossStage stage) (getTarget targetPlatformTriple) (interp $ queryHost targetPlatformTriple)
|
|
| 447 | 453 | , interpolateVar "TargetWordBigEndian" $ getTarget isBigEndian
|
| 448 | 454 | , interpolateVar "TargetWordSize" $ getTarget wordSize
|
| 449 | 455 | , interpolateVar "Unregisterised" $ yesNo <$> getTarget tgtUnregisterised
|
| ... | ... | @@ -452,8 +458,8 @@ bindistRules = do |
| 452 | 458 | , interpolateVar "BaseUnitId" $ pkgUnitId Stage1 base
|
| 453 | 459 | , interpolateVar "GhcWithSMP" $ yesNo <$> targetSupportsSMP Stage2
|
| 454 | 460 | , interpolateVar "TargetPlatformFull" (setting TargetPlatformFull)
|
| 455 | - , interpolateVar "BuildPlatformFull" (setting BuildPlatformFull)
|
|
| 456 | - , interpolateVar "HostPlatformFull" (setting HostPlatformFull)
|
|
| 461 | + , interpolateVar "BuildPlatformFull" $ ifM (not <$> crossStage stage) (setting TargetPlatformFull) (setting BuildPlatformFull)
|
|
| 462 | + , interpolateVar "HostPlatformFull" $ ifM (not <$> crossStage stage) (setting TargetPlatformFull) (setting HostPlatformFull)
|
|
| 457 | 463 | ]
|
| 458 | 464 | where
|
| 459 | 465 | interp = interpretInContext (semiEmptyTarget Stage2)
|
| ... | ... | @@ -483,8 +489,8 @@ ghcWrapper stage = do |
| 483 | 489 | -- "package.conf.d"). Callers supply the correct relative path. For bindists
|
| 484 | 490 | -- the layout is known statically; for in-tree builds callers compute it. For
|
| 485 | 491 | -- bindists, we omit @LibDir@ so it defaults to @topDir@ at runtime.
|
| 486 | -generateSettings :: FilePath -> Bool -> FilePath -> Expr String
|
|
| 487 | -generateSettings settingsFile includeLibDir rel_pkg_db = do
|
|
| 492 | +generateSettings :: FilePath -> Bool -> FilePath -> Stage -> Expr String
|
|
| 493 | +generateSettings settingsFile includeLibDir rel_pkg_db compilerStage = do
|
|
| 488 | 494 | ctx <- getContext
|
| 489 | 495 | stage <- getStage
|
| 490 | 496 | |
| ... | ... | @@ -499,7 +505,6 @@ generateSettings settingsFile includeLibDir rel_pkg_db = do |
| 499 | 505 | -- For cross compilers, LibDir points to the succeeding stage's lib dir
|
| 500 | 506 | -- (which contains the target architecture's libraries). For non-cross,
|
| 501 | 507 | -- it points to the preceding stage's lib dir as usual.
|
| 502 | - let compilerStage = predStage stage -- the GHC that builds packages in this stage
|
|
| 503 | 508 | isCrossLibDir <- expr $ crossStage compilerStage
|
| 504 | 509 | let stage_dir_stage = if isCrossLibDir then stage else compilerStage
|
| 505 | 510 |