Cheng Shao pushed to branch wip/validate-fix-werror at Glasgow Haskell Compiler / GHC
Commits:
-
18513365
by Matthew Pickering at 2026-03-21T04:43:26-04:00
-
4636d906
by mangoiv at 2026-03-21T04:44:10-04:00
-
2e3a2805
by mangoiv at 2026-03-21T04:44:10-04:00
-
de54e264
by Cheng Shao at 2026-03-21T17:52:08+01:00
-
b9bd73de
by Cheng Shao at 2026-03-21T17:52:08+01:00
-
da946a16
by Cheng Shao at 2026-03-21T17:03:51+00:00
-
955b1cf8
by Cheng Shao at 2026-03-21T17:03:51+00:00
-
3b1aeb50
by Cheng Shao at 2026-03-21T17:03:51+00:00
30 changed files:
- .gitlab-ci.yml
- .gitlab/generate-ci/flake.lock
- .gitlab/generate-ci/gen_ci.hs
- .gitlab/jobs.yaml
- .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py
- .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py
- compiler/GHC/Tc/Types/Origin.hs
- docs/users_guide/utils.py
- hadrian/src/Settings/Flavours/Validate.hs
- libraries/ghc-internal/src/GHC/Internal/Conc/IO.hs
- libraries/ghc-internal/src/GHC/Internal/Event/Control.hs
- libraries/ghc-internal/src/GHC/Internal/Event/KQueue.hsc
- libraries/ghc-internal/src/GHC/Internal/Float.hs
- libraries/ghc-internal/src/GHC/Internal/Float/RealFracMethods.hs
- libraries/ghc-internal/src/GHC/Internal/IO/FD.hs
- libraries/ghc-internal/src/GHC/Internal/Int.hs
- libraries/ghc-internal/src/GHC/Internal/RTS/Flags.hsc
- libraries/ghc-internal/src/GHC/Internal/RTS/Flags/Test.hsc
- libraries/ghc-internal/src/GHC/Internal/System/Environment.hs
- libraries/ghc-internal/src/GHC/Internal/System/Environment/Blank.hsc
- libraries/ghc-internal/src/GHC/Internal/System/IO.hs
- libraries/ghc-internal/src/GHC/Internal/System/Posix/Internals.hs
- libraries/ghc-internal/src/GHC/Internal/TopHandler.hs
- libraries/ghci/GHCi/Message.hs
- libraries/ghci/GHCi/Run.hs
- libraries/ghci/GHCi/Server.hs
- rts/Interpreter.c
- + testsuite/tests/ghci/custom-external-interpreter-commands/Main.hs
- + testsuite/tests/ghci/custom-external-interpreter-commands/all.T
- + testsuite/tests/ghci/custom-external-interpreter-commands/custom-external-interpreter-commands.stdout
Changes:
| ... | ... | @@ -1212,10 +1212,6 @@ ghcup-metadata-nightly: |
| 1212 | 1212 | artifacts: false
|
| 1213 | 1213 | - job: nightly-x86_64-linux-ubuntu22_04-validate
|
| 1214 | 1214 | artifacts: false
|
| 1215 | - - job: nightly-x86_64-linux-ubuntu20_04-validate
|
|
| 1216 | - artifacts: false
|
|
| 1217 | - - job: nightly-x86_64-linux-ubuntu18_04-validate
|
|
| 1218 | - artifacts: false
|
|
| 1219 | 1215 | - job: nightly-x86_64-linux-rocky8-validate
|
| 1220 | 1216 | artifacts: false
|
| 1221 | 1217 | - job: nightly-x86_64-darwin-validate
|
| ... | ... | @@ -5,11 +5,11 @@ |
| 5 | 5 | "systems": "systems"
|
| 6 | 6 | },
|
| 7 | 7 | "locked": {
|
| 8 | - "lastModified": 1710146030,
|
|
| 9 | - "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
|
|
| 8 | + "lastModified": 1731533236,
|
|
| 9 | + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
|
| 10 | 10 | "owner": "numtide",
|
| 11 | 11 | "repo": "flake-utils",
|
| 12 | - "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
|
|
| 12 | + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
|
| 13 | 13 | "type": "github"
|
| 14 | 14 | },
|
| 15 | 15 | "original": {
|
| ... | ... | @@ -20,12 +20,10 @@ |
| 20 | 20 | },
|
| 21 | 21 | "nixpkgs": {
|
| 22 | 22 | "locked": {
|
| 23 | - "lastModified": 1724334015,
|
|
| 24 | - "narHash": "sha256-5sfvc0MswIRNdRWioUhG58rGKGn2o90Ck6l6ClpwQqA=",
|
|
| 25 | - "owner": "NixOS",
|
|
| 26 | - "repo": "nixpkgs",
|
|
| 27 | - "rev": "6d204f819efff3d552a88d0a44b5aaaee172b784",
|
|
| 28 | - "type": "github"
|
|
| 23 | + "lastModified": 0,
|
|
| 24 | + "narHash": "sha256-M0yS4AafhKxPPmOHGqIV0iKxgNO8bHDWdl1kOwGBwRY=",
|
|
| 25 | + "path": "/nix/store/nbylyyw8k98a0an6p6nz0hvk5psygwb8-source",
|
|
| 26 | + "type": "path"
|
|
| 29 | 27 | },
|
| 30 | 28 | "original": {
|
| 31 | 29 | "id": "nixpkgs",
|
| ... | ... | @@ -122,8 +122,6 @@ data LinuxDistro |
| 122 | 122 | | Ubuntu2404LoongArch64
|
| 123 | 123 | | Ubuntu2404
|
| 124 | 124 | | Ubuntu2204
|
| 125 | - | Ubuntu2004
|
|
| 126 | - | Ubuntu1804
|
|
| 127 | 125 | | Alpine312
|
| 128 | 126 | | Alpine323
|
| 129 | 127 | | AlpineWasm
|
| ... | ... | @@ -326,8 +324,6 @@ distroName Debian13Riscv = "deb13-riscv" |
| 326 | 324 | distroName Debian12Wine = "deb12-wine"
|
| 327 | 325 | distroName Fedora43 = "fedora43"
|
| 328 | 326 | distroName Ubuntu2404LoongArch64 = "ubuntu24_04-loongarch"
|
| 329 | -distroName Ubuntu1804 = "ubuntu18_04"
|
|
| 330 | -distroName Ubuntu2004 = "ubuntu20_04"
|
|
| 331 | 327 | distroName Ubuntu2204 = "ubuntu22_04"
|
| 332 | 328 | distroName Ubuntu2404 = "ubuntu24_04"
|
| 333 | 329 | distroName Alpine312 = "alpine3_12"
|
| ... | ... | @@ -1193,9 +1189,7 @@ debian_i386 = |
| 1193 | 1189 | |
| 1194 | 1190 | ubuntu_x86 :: [JobGroup Job]
|
| 1195 | 1191 | ubuntu_x86 =
|
| 1196 | - [ disableValidate (standardBuilds Amd64 (Linux Ubuntu1804))
|
|
| 1197 | - , disableValidate (standardBuilds Amd64 (Linux Ubuntu2004))
|
|
| 1198 | - , disableValidate (standardBuilds Amd64 (Linux Ubuntu2204))
|
|
| 1192 | + [ disableValidate (standardBuilds Amd64 (Linux Ubuntu2204))
|
|
| 1199 | 1193 | , disableValidate (standardBuilds Amd64 (Linux Ubuntu2404))
|
| 1200 | 1194 | ]
|
| 1201 | 1195 |
| ... | ... | @@ -3385,132 +3385,6 @@ |
| 3385 | 3385 | "XZ_OPT": "-9"
|
| 3386 | 3386 | }
|
| 3387 | 3387 | },
|
| 3388 | - "nightly-x86_64-linux-ubuntu18_04-validate": {
|
|
| 3389 | - "after_script": [
|
|
| 3390 | - ".gitlab/ci.sh save_cache",
|
|
| 3391 | - ".gitlab/ci.sh save_test_output",
|
|
| 3392 | - ".gitlab/ci.sh clean",
|
|
| 3393 | - "cat ci_timings.txt"
|
|
| 3394 | - ],
|
|
| 3395 | - "allow_failure": false,
|
|
| 3396 | - "artifacts": {
|
|
| 3397 | - "expire_in": "8 weeks",
|
|
| 3398 | - "paths": [
|
|
| 3399 | - "ghc-x86_64-linux-ubuntu18_04-validate.tar.xz",
|
|
| 3400 | - "junit.xml",
|
|
| 3401 | - "unexpected-test-output.tar.gz"
|
|
| 3402 | - ],
|
|
| 3403 | - "reports": {
|
|
| 3404 | - "junit": "junit.xml"
|
|
| 3405 | - },
|
|
| 3406 | - "when": "always"
|
|
| 3407 | - },
|
|
| 3408 | - "cache": {
|
|
| 3409 | - "key": "x86_64-linux-ubuntu18_04-$CACHE_REV",
|
|
| 3410 | - "paths": [
|
|
| 3411 | - "cabal-cache",
|
|
| 3412 | - "toolchain"
|
|
| 3413 | - ]
|
|
| 3414 | - },
|
|
| 3415 | - "dependencies": [],
|
|
| 3416 | - "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-ubuntu18_04:$DOCKER_REV",
|
|
| 3417 | - "needs": [
|
|
| 3418 | - {
|
|
| 3419 | - "artifacts": false,
|
|
| 3420 | - "job": "hadrian-ghc-in-ghci"
|
|
| 3421 | - }
|
|
| 3422 | - ],
|
|
| 3423 | - "rules": [
|
|
| 3424 | - {
|
|
| 3425 | - "if": "(\"true\" == \"true\") && ($RELEASE_JOB != \"yes\") && ($NIGHTLY)",
|
|
| 3426 | - "when": "on_success"
|
|
| 3427 | - }
|
|
| 3428 | - ],
|
|
| 3429 | - "script": [
|
|
| 3430 | - "sudo chown ghc:ghc -R .",
|
|
| 3431 | - ".gitlab/ci.sh setup",
|
|
| 3432 | - ".gitlab/ci.sh configure",
|
|
| 3433 | - ".gitlab/ci.sh build_hadrian",
|
|
| 3434 | - ".gitlab/ci.sh test_hadrian"
|
|
| 3435 | - ],
|
|
| 3436 | - "stage": "full-build",
|
|
| 3437 | - "tags": [
|
|
| 3438 | - "x86_64-linux"
|
|
| 3439 | - ],
|
|
| 3440 | - "variables": {
|
|
| 3441 | - "BIGNUM_BACKEND": "gmp",
|
|
| 3442 | - "BIN_DIST_NAME": "ghc-x86_64-linux-ubuntu18_04-validate",
|
|
| 3443 | - "BUILD_FLAVOUR": "validate",
|
|
| 3444 | - "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
|
|
| 3445 | - "INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
|
|
| 3446 | - "RUNTEST_ARGS": "",
|
|
| 3447 | - "TEST_ENV": "x86_64-linux-ubuntu18_04-validate",
|
|
| 3448 | - "XZ_OPT": "-9"
|
|
| 3449 | - }
|
|
| 3450 | - },
|
|
| 3451 | - "nightly-x86_64-linux-ubuntu20_04-validate": {
|
|
| 3452 | - "after_script": [
|
|
| 3453 | - ".gitlab/ci.sh save_cache",
|
|
| 3454 | - ".gitlab/ci.sh save_test_output",
|
|
| 3455 | - ".gitlab/ci.sh clean",
|
|
| 3456 | - "cat ci_timings.txt"
|
|
| 3457 | - ],
|
|
| 3458 | - "allow_failure": false,
|
|
| 3459 | - "artifacts": {
|
|
| 3460 | - "expire_in": "8 weeks",
|
|
| 3461 | - "paths": [
|
|
| 3462 | - "ghc-x86_64-linux-ubuntu20_04-validate.tar.xz",
|
|
| 3463 | - "junit.xml",
|
|
| 3464 | - "unexpected-test-output.tar.gz"
|
|
| 3465 | - ],
|
|
| 3466 | - "reports": {
|
|
| 3467 | - "junit": "junit.xml"
|
|
| 3468 | - },
|
|
| 3469 | - "when": "always"
|
|
| 3470 | - },
|
|
| 3471 | - "cache": {
|
|
| 3472 | - "key": "x86_64-linux-ubuntu20_04-$CACHE_REV",
|
|
| 3473 | - "paths": [
|
|
| 3474 | - "cabal-cache",
|
|
| 3475 | - "toolchain"
|
|
| 3476 | - ]
|
|
| 3477 | - },
|
|
| 3478 | - "dependencies": [],
|
|
| 3479 | - "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-ubuntu20_04:$DOCKER_REV",
|
|
| 3480 | - "needs": [
|
|
| 3481 | - {
|
|
| 3482 | - "artifacts": false,
|
|
| 3483 | - "job": "hadrian-ghc-in-ghci"
|
|
| 3484 | - }
|
|
| 3485 | - ],
|
|
| 3486 | - "rules": [
|
|
| 3487 | - {
|
|
| 3488 | - "if": "(\"true\" == \"true\") && ($RELEASE_JOB != \"yes\") && ($NIGHTLY)",
|
|
| 3489 | - "when": "on_success"
|
|
| 3490 | - }
|
|
| 3491 | - ],
|
|
| 3492 | - "script": [
|
|
| 3493 | - "sudo chown ghc:ghc -R .",
|
|
| 3494 | - ".gitlab/ci.sh setup",
|
|
| 3495 | - ".gitlab/ci.sh configure",
|
|
| 3496 | - ".gitlab/ci.sh build_hadrian",
|
|
| 3497 | - ".gitlab/ci.sh test_hadrian"
|
|
| 3498 | - ],
|
|
| 3499 | - "stage": "full-build",
|
|
| 3500 | - "tags": [
|
|
| 3501 | - "x86_64-linux"
|
|
| 3502 | - ],
|
|
| 3503 | - "variables": {
|
|
| 3504 | - "BIGNUM_BACKEND": "gmp",
|
|
| 3505 | - "BIN_DIST_NAME": "ghc-x86_64-linux-ubuntu20_04-validate",
|
|
| 3506 | - "BUILD_FLAVOUR": "validate",
|
|
| 3507 | - "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
|
|
| 3508 | - "INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
|
|
| 3509 | - "RUNTEST_ARGS": "",
|
|
| 3510 | - "TEST_ENV": "x86_64-linux-ubuntu20_04-validate",
|
|
| 3511 | - "XZ_OPT": "-9"
|
|
| 3512 | - }
|
|
| 3513 | - },
|
|
| 3514 | 3388 | "nightly-x86_64-linux-ubuntu22_04-validate": {
|
| 3515 | 3389 | "after_script": [
|
| 3516 | 3390 | ".gitlab/ci.sh save_cache",
|
| ... | ... | @@ -5192,134 +5066,6 @@ |
| 5192 | 5066 | "XZ_OPT": "-9"
|
| 5193 | 5067 | }
|
| 5194 | 5068 | },
|
| 5195 | - "release-x86_64-linux-ubuntu18_04-release": {
|
|
| 5196 | - "after_script": [
|
|
| 5197 | - ".gitlab/ci.sh save_cache",
|
|
| 5198 | - ".gitlab/ci.sh save_test_output",
|
|
| 5199 | - ".gitlab/ci.sh clean",
|
|
| 5200 | - "cat ci_timings.txt"
|
|
| 5201 | - ],
|
|
| 5202 | - "allow_failure": false,
|
|
| 5203 | - "artifacts": {
|
|
| 5204 | - "expire_in": "1 year",
|
|
| 5205 | - "paths": [
|
|
| 5206 | - "ghc-x86_64-linux-ubuntu18_04-release.tar.xz",
|
|
| 5207 | - "junit.xml",
|
|
| 5208 | - "unexpected-test-output.tar.gz"
|
|
| 5209 | - ],
|
|
| 5210 | - "reports": {
|
|
| 5211 | - "junit": "junit.xml"
|
|
| 5212 | - },
|
|
| 5213 | - "when": "always"
|
|
| 5214 | - },
|
|
| 5215 | - "cache": {
|
|
| 5216 | - "key": "x86_64-linux-ubuntu18_04-$CACHE_REV",
|
|
| 5217 | - "paths": [
|
|
| 5218 | - "cabal-cache",
|
|
| 5219 | - "toolchain"
|
|
| 5220 | - ]
|
|
| 5221 | - },
|
|
| 5222 | - "dependencies": [],
|
|
| 5223 | - "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-ubuntu18_04:$DOCKER_REV",
|
|
| 5224 | - "needs": [
|
|
| 5225 | - {
|
|
| 5226 | - "artifacts": false,
|
|
| 5227 | - "job": "hadrian-ghc-in-ghci"
|
|
| 5228 | - }
|
|
| 5229 | - ],
|
|
| 5230 | - "rules": [
|
|
| 5231 | - {
|
|
| 5232 | - "if": "(\"true\" == \"true\") && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null)",
|
|
| 5233 | - "when": "on_success"
|
|
| 5234 | - }
|
|
| 5235 | - ],
|
|
| 5236 | - "script": [
|
|
| 5237 | - "sudo chown ghc:ghc -R .",
|
|
| 5238 | - ".gitlab/ci.sh setup",
|
|
| 5239 | - ".gitlab/ci.sh configure",
|
|
| 5240 | - ".gitlab/ci.sh build_hadrian",
|
|
| 5241 | - ".gitlab/ci.sh test_hadrian"
|
|
| 5242 | - ],
|
|
| 5243 | - "stage": "full-build",
|
|
| 5244 | - "tags": [
|
|
| 5245 | - "x86_64-linux"
|
|
| 5246 | - ],
|
|
| 5247 | - "variables": {
|
|
| 5248 | - "BIGNUM_BACKEND": "gmp",
|
|
| 5249 | - "BIN_DIST_NAME": "ghc-x86_64-linux-ubuntu18_04-release",
|
|
| 5250 | - "BUILD_FLAVOUR": "release",
|
|
| 5251 | - "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
|
|
| 5252 | - "IGNORE_PERF_FAILURES": "all",
|
|
| 5253 | - "INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
|
|
| 5254 | - "RUNTEST_ARGS": "",
|
|
| 5255 | - "TEST_ENV": "x86_64-linux-ubuntu18_04-release",
|
|
| 5256 | - "XZ_OPT": "-9"
|
|
| 5257 | - }
|
|
| 5258 | - },
|
|
| 5259 | - "release-x86_64-linux-ubuntu20_04-release": {
|
|
| 5260 | - "after_script": [
|
|
| 5261 | - ".gitlab/ci.sh save_cache",
|
|
| 5262 | - ".gitlab/ci.sh save_test_output",
|
|
| 5263 | - ".gitlab/ci.sh clean",
|
|
| 5264 | - "cat ci_timings.txt"
|
|
| 5265 | - ],
|
|
| 5266 | - "allow_failure": false,
|
|
| 5267 | - "artifacts": {
|
|
| 5268 | - "expire_in": "1 year",
|
|
| 5269 | - "paths": [
|
|
| 5270 | - "ghc-x86_64-linux-ubuntu20_04-release.tar.xz",
|
|
| 5271 | - "junit.xml",
|
|
| 5272 | - "unexpected-test-output.tar.gz"
|
|
| 5273 | - ],
|
|
| 5274 | - "reports": {
|
|
| 5275 | - "junit": "junit.xml"
|
|
| 5276 | - },
|
|
| 5277 | - "when": "always"
|
|
| 5278 | - },
|
|
| 5279 | - "cache": {
|
|
| 5280 | - "key": "x86_64-linux-ubuntu20_04-$CACHE_REV",
|
|
| 5281 | - "paths": [
|
|
| 5282 | - "cabal-cache",
|
|
| 5283 | - "toolchain"
|
|
| 5284 | - ]
|
|
| 5285 | - },
|
|
| 5286 | - "dependencies": [],
|
|
| 5287 | - "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-ubuntu20_04:$DOCKER_REV",
|
|
| 5288 | - "needs": [
|
|
| 5289 | - {
|
|
| 5290 | - "artifacts": false,
|
|
| 5291 | - "job": "hadrian-ghc-in-ghci"
|
|
| 5292 | - }
|
|
| 5293 | - ],
|
|
| 5294 | - "rules": [
|
|
| 5295 | - {
|
|
| 5296 | - "if": "(\"true\" == \"true\") && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null)",
|
|
| 5297 | - "when": "on_success"
|
|
| 5298 | - }
|
|
| 5299 | - ],
|
|
| 5300 | - "script": [
|
|
| 5301 | - "sudo chown ghc:ghc -R .",
|
|
| 5302 | - ".gitlab/ci.sh setup",
|
|
| 5303 | - ".gitlab/ci.sh configure",
|
|
| 5304 | - ".gitlab/ci.sh build_hadrian",
|
|
| 5305 | - ".gitlab/ci.sh test_hadrian"
|
|
| 5306 | - ],
|
|
| 5307 | - "stage": "full-build",
|
|
| 5308 | - "tags": [
|
|
| 5309 | - "x86_64-linux"
|
|
| 5310 | - ],
|
|
| 5311 | - "variables": {
|
|
| 5312 | - "BIGNUM_BACKEND": "gmp",
|
|
| 5313 | - "BIN_DIST_NAME": "ghc-x86_64-linux-ubuntu20_04-release",
|
|
| 5314 | - "BUILD_FLAVOUR": "release",
|
|
| 5315 | - "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
|
|
| 5316 | - "IGNORE_PERF_FAILURES": "all",
|
|
| 5317 | - "INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
|
|
| 5318 | - "RUNTEST_ARGS": "",
|
|
| 5319 | - "TEST_ENV": "x86_64-linux-ubuntu20_04-release",
|
|
| 5320 | - "XZ_OPT": "-9"
|
|
| 5321 | - }
|
|
| 5322 | - },
|
|
| 5323 | 5069 | "release-x86_64-linux-ubuntu22_04-release": {
|
| 5324 | 5070 | "after_script": [
|
| 5325 | 5071 | ".gitlab/ci.sh save_cache",
|
| ... | ... | @@ -7472,130 +7218,6 @@ |
| 7472 | 7218 | "TEST_ENV": "x86_64-linux-rocky8-validate"
|
| 7473 | 7219 | }
|
| 7474 | 7220 | },
|
| 7475 | - "x86_64-linux-ubuntu18_04-validate": {
|
|
| 7476 | - "after_script": [
|
|
| 7477 | - ".gitlab/ci.sh save_cache",
|
|
| 7478 | - ".gitlab/ci.sh save_test_output",
|
|
| 7479 | - ".gitlab/ci.sh clean",
|
|
| 7480 | - "cat ci_timings.txt"
|
|
| 7481 | - ],
|
|
| 7482 | - "allow_failure": false,
|
|
| 7483 | - "artifacts": {
|
|
| 7484 | - "expire_in": "2 weeks",
|
|
| 7485 | - "paths": [
|
|
| 7486 | - "ghc-x86_64-linux-ubuntu18_04-validate.tar.xz",
|
|
| 7487 | - "junit.xml",
|
|
| 7488 | - "unexpected-test-output.tar.gz"
|
|
| 7489 | - ],
|
|
| 7490 | - "reports": {
|
|
| 7491 | - "junit": "junit.xml"
|
|
| 7492 | - },
|
|
| 7493 | - "when": "always"
|
|
| 7494 | - },
|
|
| 7495 | - "cache": {
|
|
| 7496 | - "key": "x86_64-linux-ubuntu18_04-$CACHE_REV",
|
|
| 7497 | - "paths": [
|
|
| 7498 | - "cabal-cache",
|
|
| 7499 | - "toolchain"
|
|
| 7500 | - ]
|
|
| 7501 | - },
|
|
| 7502 | - "dependencies": [],
|
|
| 7503 | - "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-ubuntu18_04:$DOCKER_REV",
|
|
| 7504 | - "needs": [
|
|
| 7505 | - {
|
|
| 7506 | - "artifacts": false,
|
|
| 7507 | - "job": "hadrian-ghc-in-ghci"
|
|
| 7508 | - }
|
|
| 7509 | - ],
|
|
| 7510 | - "rules": [
|
|
| 7511 | - {
|
|
| 7512 | - "if": "((($ONLY_JOBS) && ($ONLY_JOBS =~ /.*\\bx86_64-linux-ubuntu18_04-validate(\\s|$).*/)) || (($ONLY_JOBS == null) && (\"disabled\" != \"disabled\"))) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)",
|
|
| 7513 | - "when": "on_success"
|
|
| 7514 | - }
|
|
| 7515 | - ],
|
|
| 7516 | - "script": [
|
|
| 7517 | - "sudo chown ghc:ghc -R .",
|
|
| 7518 | - ".gitlab/ci.sh setup",
|
|
| 7519 | - ".gitlab/ci.sh configure",
|
|
| 7520 | - ".gitlab/ci.sh build_hadrian",
|
|
| 7521 | - ".gitlab/ci.sh test_hadrian"
|
|
| 7522 | - ],
|
|
| 7523 | - "stage": "full-build",
|
|
| 7524 | - "tags": [
|
|
| 7525 | - "x86_64-linux"
|
|
| 7526 | - ],
|
|
| 7527 | - "variables": {
|
|
| 7528 | - "BIGNUM_BACKEND": "gmp",
|
|
| 7529 | - "BIN_DIST_NAME": "ghc-x86_64-linux-ubuntu18_04-validate",
|
|
| 7530 | - "BUILD_FLAVOUR": "validate",
|
|
| 7531 | - "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
|
|
| 7532 | - "INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
|
|
| 7533 | - "RUNTEST_ARGS": "",
|
|
| 7534 | - "TEST_ENV": "x86_64-linux-ubuntu18_04-validate"
|
|
| 7535 | - }
|
|
| 7536 | - },
|
|
| 7537 | - "x86_64-linux-ubuntu20_04-validate": {
|
|
| 7538 | - "after_script": [
|
|
| 7539 | - ".gitlab/ci.sh save_cache",
|
|
| 7540 | - ".gitlab/ci.sh save_test_output",
|
|
| 7541 | - ".gitlab/ci.sh clean",
|
|
| 7542 | - "cat ci_timings.txt"
|
|
| 7543 | - ],
|
|
| 7544 | - "allow_failure": false,
|
|
| 7545 | - "artifacts": {
|
|
| 7546 | - "expire_in": "2 weeks",
|
|
| 7547 | - "paths": [
|
|
| 7548 | - "ghc-x86_64-linux-ubuntu20_04-validate.tar.xz",
|
|
| 7549 | - "junit.xml",
|
|
| 7550 | - "unexpected-test-output.tar.gz"
|
|
| 7551 | - ],
|
|
| 7552 | - "reports": {
|
|
| 7553 | - "junit": "junit.xml"
|
|
| 7554 | - },
|
|
| 7555 | - "when": "always"
|
|
| 7556 | - },
|
|
| 7557 | - "cache": {
|
|
| 7558 | - "key": "x86_64-linux-ubuntu20_04-$CACHE_REV",
|
|
| 7559 | - "paths": [
|
|
| 7560 | - "cabal-cache",
|
|
| 7561 | - "toolchain"
|
|
| 7562 | - ]
|
|
| 7563 | - },
|
|
| 7564 | - "dependencies": [],
|
|
| 7565 | - "image": "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-ubuntu20_04:$DOCKER_REV",
|
|
| 7566 | - "needs": [
|
|
| 7567 | - {
|
|
| 7568 | - "artifacts": false,
|
|
| 7569 | - "job": "hadrian-ghc-in-ghci"
|
|
| 7570 | - }
|
|
| 7571 | - ],
|
|
| 7572 | - "rules": [
|
|
| 7573 | - {
|
|
| 7574 | - "if": "((($ONLY_JOBS) && ($ONLY_JOBS =~ /.*\\bx86_64-linux-ubuntu20_04-validate(\\s|$).*/)) || (($ONLY_JOBS == null) && (\"disabled\" != \"disabled\"))) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)",
|
|
| 7575 | - "when": "on_success"
|
|
| 7576 | - }
|
|
| 7577 | - ],
|
|
| 7578 | - "script": [
|
|
| 7579 | - "sudo chown ghc:ghc -R .",
|
|
| 7580 | - ".gitlab/ci.sh setup",
|
|
| 7581 | - ".gitlab/ci.sh configure",
|
|
| 7582 | - ".gitlab/ci.sh build_hadrian",
|
|
| 7583 | - ".gitlab/ci.sh test_hadrian"
|
|
| 7584 | - ],
|
|
| 7585 | - "stage": "full-build",
|
|
| 7586 | - "tags": [
|
|
| 7587 | - "x86_64-linux"
|
|
| 7588 | - ],
|
|
| 7589 | - "variables": {
|
|
| 7590 | - "BIGNUM_BACKEND": "gmp",
|
|
| 7591 | - "BIN_DIST_NAME": "ghc-x86_64-linux-ubuntu20_04-validate",
|
|
| 7592 | - "BUILD_FLAVOUR": "validate",
|
|
| 7593 | - "CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
|
|
| 7594 | - "INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
|
|
| 7595 | - "RUNTEST_ARGS": "",
|
|
| 7596 | - "TEST_ENV": "x86_64-linux-ubuntu20_04-validate"
|
|
| 7597 | - }
|
|
| 7598 | - },
|
|
| 7599 | 7221 | "x86_64-linux-ubuntu22_04-validate": {
|
| 7600 | 7222 | "after_script": [
|
| 7601 | 7223 | ".gitlab/ci.sh save_cache",
|
| ... | ... | @@ -21,8 +21,6 @@ def job_triple(job_name): |
| 21 | 21 | 'release-x86_64-linux-rocky8-release': 'x86_64-rocky8-linux',
|
| 22 | 22 | 'release-x86_64-linux-ubuntu24_04-release': 'x86_64-ubuntu24_04-linux',
|
| 23 | 23 | 'release-x86_64-linux-ubuntu22_04-release': 'x86_64-ubuntu22_04-linux',
|
| 24 | - 'release-x86_64-linux-ubuntu20_04-release': 'x86_64-ubuntu20_04-linux',
|
|
| 25 | - 'release-x86_64-linux-ubuntu18_04-release': 'x86_64-ubuntu18_04-linux',
|
|
| 26 | 24 | 'release-x86_64-linux-fedora43-release': 'x86_64-fedora43-linux',
|
| 27 | 25 | 'release-x86_64-linux-fedora43-release+debug_info': 'x86_64-fedora43-linux-dwarf',
|
| 28 | 26 | 'release-x86_64-linux-deb13-release': 'x86_64-deb13-linux',
|
| ... | ... | @@ -195,8 +195,6 @@ def mk_new_yaml(release_mode, version, date, pipeline_type, job_map): |
| 195 | 195 | return mk_one_metadata(release_mode, version, job_map, mk_from_platform(pipeline_type, platform))
|
| 196 | 196 | |
| 197 | 197 | # Here are all the bindists we can distribute
|
| 198 | - ubuntu1804 = mk(ubuntu("18_04"))
|
|
| 199 | - ubuntu2004 = mk(ubuntu("20_04"))
|
|
| 200 | 198 | ubuntu2204 = mk(ubuntu("22_04"))
|
| 201 | 199 | ubuntu2404 = mk(ubuntu("24_04"))
|
| 202 | 200 | rocky8 = mk(rocky("8"))
|
| ... | ... | @@ -227,15 +225,13 @@ def mk_new_yaml(release_mode, version, date, pipeline_type, job_map): |
| 227 | 225 | , "( >= 12 && < 13 )": deb12
|
| 228 | 226 | , ">= 13": deb13
|
| 229 | 227 | , "unknown_versioning": deb11 }
|
| 230 | - , "Linux_Ubuntu" : { "unknown_versioning": ubuntu2004
|
|
| 231 | - , "( >= 18 && < 19 )": ubuntu1804
|
|
| 232 | - , "( >= 19 && < 21 )": ubuntu2004
|
|
| 233 | - , "( >= 21 && < 24 )": ubuntu2204
|
|
| 228 | + , "Linux_Ubuntu" : { "unknown_versioning": ubuntu2204
|
|
| 229 | + , "( < 24 )": ubuntu2204
|
|
| 234 | 230 | , "( >= 24 )": ubuntu2404
|
| 235 | 231 | }
|
| 236 | - , "Linux_Mint" : { "< 20": ubuntu1804
|
|
| 237 | - , ">= 20": ubuntu2004
|
|
| 238 | - , "unknown_versioning": ubuntu2004 }
|
|
| 232 | + , "Linux_Mint" : { "< 24": ubuntu2204
|
|
| 233 | + , ">= 24": ubuntu2404
|
|
| 234 | + , "unknown_versioning": ubuntu2204 }
|
|
| 239 | 235 | , "Linux_CentOS" : { "( >= 8 && < 9 )" : rocky8
|
| 240 | 236 | , "unknown_versioning" : rocky8 }
|
| 241 | 237 | , "Linux_Fedora" : { ">= 43": fedora43
|
| ... | ... | @@ -83,7 +83,6 @@ import qualified Data.Kind as Hs |
| 83 | 83 | import Data.List.NonEmpty (NonEmpty (..))
|
| 84 | 84 | import Data.Maybe (isNothing)
|
| 85 | 85 | import qualified Data.Semigroup as Semi
|
| 86 | -import GHC.Generics
|
|
| 87 | 86 | |
| 88 | 87 | {- *********************************************************************
|
| 89 | 88 | * *
|
| 1 | 1 | from docutils import nodes
|
| 2 | 2 | |
| 3 | -# N.B. `packaging` is not available in Ubuntu 18.04 or Debian 9
|
|
| 4 | -# See #23818.
|
|
| 5 | -try:
|
|
| 6 | - from packaging.version import parse as parse_version
|
|
| 7 | -except ImportError as e:
|
|
| 8 | - from distutils.version import LooseVersion as parse_version
|
|
| 3 | +from packaging.version import parse as parse_version
|
|
| 9 | 4 | |
| 10 | 5 | # Taken from Docutils source inside the ListTable class. We must bypass
|
| 11 | 6 | # using the class itself, but this function comes in handy.
|
| ... | ... | @@ -8,7 +8,7 @@ import {-# SOURCE #-} Settings.Default |
| 8 | 8 | |
| 9 | 9 | -- Please update doc/flavours.md when changing this file.
|
| 10 | 10 | validateFlavour :: Flavour
|
| 11 | -validateFlavour = enableLinting $ quickValidateFlavour
|
|
| 11 | +validateFlavour = enableLinting $ werror $ quickValidateFlavour
|
|
| 12 | 12 | { name = "validate"
|
| 13 | 13 | , extraArgs = validateArgs <> defaultHaddockExtraArgs
|
| 14 | 14 | , ghcDebugAssertions = (<= Stage1)
|
| ... | ... | @@ -58,7 +58,7 @@ module GHC.Internal.Conc.IO |
| 58 | 58 | #endif
|
| 59 | 59 | ) where
|
| 60 | 60 | |
| 61 | -import GHC.Internal.Base (otherwise, pure, return, ($))
|
|
| 61 | +import GHC.Internal.Base (otherwise, return, ($))
|
|
| 62 | 62 | import GHC.Internal.Conc.Sync as Sync
|
| 63 | 63 | import GHC.Internal.Err (errorWithoutStackTrace)
|
| 64 | 64 | import GHC.Internal.STM as STM
|
| ... | ... | @@ -82,6 +82,10 @@ import qualified GHC.Internal.Wasm.Prim.Conc as Wasm |
| 82 | 82 | import qualified GHC.Internal.Wasm.Prim.Flag as Wasm
|
| 83 | 83 | #endif
|
| 84 | 84 | |
| 85 | +#if defined(javascript_HOST_ARCH)
|
|
| 86 | +import GHC.Internal.Base (pure)
|
|
| 87 | +#endif
|
|
| 88 | + |
|
| 85 | 89 | ensureIOManagerIsRunning :: IO ()
|
| 86 | 90 | #if defined(javascript_HOST_ARCH)
|
| 87 | 91 | ensureIOManagerIsRunning = pure ()
|
| ... | ... | @@ -29,7 +29,7 @@ module GHC.Internal.Event.Control |
| 29 | 29 | #include <ghcplatform.h>
|
| 30 | 30 | #include "EventConfig.h"
|
| 31 | 31 | |
| 32 | -import GHC.Internal.Base (fmap, otherwise, pure, return, when, ($), (.))
|
|
| 32 | +import GHC.Internal.Base (fmap, otherwise, return, when, ($), (.))
|
|
| 33 | 33 | import GHC.Internal.Classes (Eq(..), (&&))
|
| 34 | 34 | import GHC.Internal.IORef
|
| 35 | 35 | import GHC.Internal.Conc.Signal (Signal)
|
| ... | ... | @@ -56,6 +56,10 @@ import GHC.Internal.Foreign.C.Types (CULLong(..)) |
| 56 | 56 | import GHC.Internal.Foreign.C.Error (eAGAIN, eWOULDBLOCK, eBADF)
|
| 57 | 57 | #endif
|
| 58 | 58 | |
| 59 | +#if defined(wasm32_HOST_ARCH)
|
|
| 60 | +import GHC.Internal.Base (pure)
|
|
| 61 | +#endif
|
|
| 62 | + |
|
| 59 | 63 | data ControlMessage = CMsgWakeup
|
| 60 | 64 | | CMsgDie
|
| 61 | 65 | | CMsgSignal {-# UNPACK #-} !(ForeignPtr Word8)
|
| ... | ... | @@ -33,7 +33,7 @@ import GHC.Internal.Data.Bits (Bits(..), FiniteBits(..)) |
| 33 | 33 | import GHC.Internal.Err (errorWithoutStackTrace, undefined)
|
| 34 | 34 | import GHC.Internal.Int
|
| 35 | 35 | import GHC.Internal.Data.Maybe (Maybe(..), catMaybes)
|
| 36 | -import GHC.Internal.Types (Bool(..), Int, IO)
|
|
| 36 | +import GHC.Internal.Types (Bool(..), IO)
|
|
| 37 | 37 | import GHC.Internal.Word (Word16, Word32)
|
| 38 | 38 | import GHC.Internal.Foreign.C.Error (throwErrnoIfMinus1, eINTR, eINVAL,
|
| 39 | 39 | eNOTSUP, getErrno, throwErrno)
|
| ... | ... | @@ -185,12 +185,12 @@ import GHC.Internal.Prim ( |
| 185 | 185 | decodeFloat_Int#, divideFloat#, double2Float#, eqWord#, expDouble#,
|
| 186 | 186 | expFloat#, expm1Double#, expm1Float#, fabsDouble#, fabsFloat#,
|
| 187 | 187 | float2Double#, geFloat#, gtFloat#, gtWord#, int2Float#, int2Double#,
|
| 188 | - int2Word#, int64ToInt#, leFloat#, log1pDouble#, log1pFloat#, logDouble#,
|
|
| 188 | + int2Word#, leFloat#, log1pDouble#, log1pFloat#, logDouble#,
|
|
| 189 | 189 | logFloat#, ltFloat#, ltWord#, minusFloat#, minusWord#, negateDouble#,
|
| 190 | 190 | negateFloat#, negateInt#, plusFloat#, powerFloat#, sinDouble#, sinFloat#,
|
| 191 | 191 | sinhDouble#, sinhFloat#, sqrtDouble#, sqrtFloat#, tanDouble#, tanFloat#,
|
| 192 | 192 | tanhDouble#, tanhFloat#, timesFloat#, uncheckedIShiftRA#, uncheckedShiftL#,
|
| 193 | - word2Float#, word2Double#, word2Int#, word64ToWord#,
|
|
| 193 | + word2Float#, word2Double#, word2Int#,
|
|
| 194 | 194 | (+#), (+##), (-#), (-##), (*##), (**##), (/##), (<#), (<##), (<=#), (<=##),
|
| 195 | 195 | (>#), (>##), (>=#), (>=##),
|
| 196 | 196 | )
|
| ... | ... | @@ -206,6 +206,13 @@ import GHC.Internal.Float.RealFracMethods |
| 206 | 206 | import GHC.Internal.Float.ConversionUtils
|
| 207 | 207 | import GHC.Internal.Bignum.BigNat
|
| 208 | 208 | |
| 209 | +#if WORD_SIZE_IN_BITS == 64
|
|
| 210 | +import GHC.Internal.Prim (
|
|
| 211 | + int64ToInt#,
|
|
| 212 | + word64ToWord#,
|
|
| 213 | + )
|
|
| 214 | +#endif
|
|
| 215 | + |
|
| 209 | 216 | infixr 8 **
|
| 210 | 217 | |
| 211 | 218 | -- $setup
|
| ... | ... | @@ -66,7 +66,7 @@ import GHC.Internal.Classes (Ord(..)) |
| 66 | 66 | import GHC.Internal.Num () -- instance Num Integer
|
| 67 | 67 | -- (We could remove uses with a little effort)
|
| 68 | 68 | import GHC.Internal.Prim (
|
| 69 | - Int#, eqFloat#, decodeFloat_Int#, double2Int#, float2Int#, int2Float#,
|
|
| 69 | + eqFloat#, decodeFloat_Int#, double2Int#, float2Int#, int2Float#,
|
|
| 70 | 70 | int2Double#, int2Word#, ltFloat#, minusFloat#, negateFloat#, negateDouble#,
|
| 71 | 71 | negateInt#, uncheckedIShiftL#, uncheckedIShiftRA#, uncheckedIShiftRL#,
|
| 72 | 72 | (+#), (-#), (<#), (>#), (-##), (==##), (<##),
|
| ... | ... | @@ -86,6 +86,10 @@ import GHC.Internal.Prim ( |
| 86 | 86 | |
| 87 | 87 | #else
|
| 88 | 88 | |
| 89 | +import GHC.Internal.Prim (
|
|
| 90 | + Int#,
|
|
| 91 | + )
|
|
| 92 | + |
|
| 89 | 93 | #define TO64 integerToInt#
|
| 90 | 94 | #define FROM64 IS
|
| 91 | 95 | #define MINUS64 ( -# )
|
| ... | ... | @@ -355,4 +359,3 @@ foreign import ccall unsafe "rintDouble" |
| 355 | 359 | |
| 356 | 360 | foreign import ccall unsafe "rintFloat"
|
| 357 | 361 | c_rintFloat :: Float -> Float |
| 358 | - |
| ... | ... | @@ -30,7 +30,7 @@ module GHC.Internal.IO.FD ( |
| 30 | 30 | ) where
|
| 31 | 31 | |
| 32 | 32 | import GHC.Internal.Base (
|
| 33 | - String, fmap, id, otherwise, pure, return, when, ($), (.), (++), (>>=),
|
|
| 33 | + String, fmap, otherwise, pure, return, when, ($), (.), (++), (>>=),
|
|
| 34 | 34 | )
|
| 35 | 35 | import GHC.Internal.Bits
|
| 36 | 36 | import GHC.Internal.Classes (Eq(..), Ord(..), not, (&&), (||))
|
| ... | ... | @@ -58,6 +58,10 @@ import GHC.Internal.Err (error) |
| 58 | 58 | import GHC.Internal.Windows
|
| 59 | 59 | import GHC.Internal.IO.SubSystem ((<!>))
|
| 60 | 60 | import GHC.Internal.Foreign.Storable
|
| 61 | +#else
|
|
| 62 | +import GHC.Internal.Base (
|
|
| 63 | + id,
|
|
| 64 | + )
|
|
| 61 | 65 | #endif
|
| 62 | 66 | |
| 63 | 67 | import GHC.Internal.Foreign.C.Types
|
| ... | ... | @@ -51,7 +51,7 @@ import GHC.Internal.Classes ( |
| 51 | 51 | Eq(..), Ord(..),
|
| 52 | 52 | eqInt, neInt, gtInt, geInt, ltInt, leInt,
|
| 53 | 53 | divInt8#, divInt16#, divInt32#,
|
| 54 | - divModInt8#, divModInt16#, divModInt32#, divModInt#,
|
|
| 54 | + divModInt8#, divModInt16#, divModInt32#,
|
|
| 55 | 55 | modInt8#, modInt16#, modInt32#,
|
| 56 | 56 | (&&), (||),
|
| 57 | 57 | )
|
| ... | ... | @@ -63,6 +63,12 @@ import GHC.Internal.Arr |
| 63 | 63 | import GHC.Internal.Show
|
| 64 | 64 | import GHC.Internal.Types (Bool(..), Float, Double, Int(..), isTrue#)
|
| 65 | 65 | |
| 66 | +#if WORD_SIZE_IN_BITS == 64
|
|
| 67 | +import GHC.Internal.Classes (
|
|
| 68 | + divModInt#,
|
|
| 69 | + )
|
|
| 70 | +#endif
|
|
| 71 | + |
|
| 66 | 72 | ------------------------------------------------------------------------
|
| 67 | 73 | -- type Int8
|
| 68 | 74 | ------------------------------------------------------------------------
|
| ... | ... | @@ -66,7 +66,7 @@ import GHC.Internal.Ptr |
| 66 | 66 | import GHC.Internal.Types (Bool(..), Double, Int)
|
| 67 | 67 | import GHC.Internal.Word
|
| 68 | 68 | import GHC.Internal.Base (
|
| 69 | - String, otherwise, pure, return, (.), (++), (<*>), (=<<),
|
|
| 69 | + String, otherwise, return, (.), (++), (<*>), (=<<),
|
|
| 70 | 70 | )
|
| 71 | 71 | import GHC.Internal.Enum
|
| 72 | 72 | import GHC.Internal.Generics (Generic)
|
| ... | ... | @@ -74,6 +74,10 @@ import GHC.Internal.IO |
| 74 | 74 | import GHC.Internal.Real
|
| 75 | 75 | import GHC.Internal.Show
|
| 76 | 76 | |
| 77 | +#if defined(javascript_HOST_ARCH)
|
|
| 78 | +import GHC.Internal.Base (pure)
|
|
| 79 | +#endif
|
|
| 80 | + |
|
| 77 | 81 | -- | 'RtsTime' is defined as a @StgWord64@ in @stg/Types.h@
|
| 78 | 82 | --
|
| 79 | 83 | -- @since base-4.8.2.0
|
| ... | ... | @@ -8,16 +8,20 @@ module GHC.Internal.RTS.Flags.Test |
| 8 | 8 | )
|
| 9 | 9 | where
|
| 10 | 10 | |
| 11 | -import GHC.Internal.Base (pure)
|
|
| 12 | 11 | import GHC.Internal.Ptr
|
| 13 | -import GHC.Internal.Foreign.C.Types
|
|
| 14 | -import GHC.Internal.Foreign.Marshal.Utils
|
|
| 15 | 12 | import GHC.Internal.Foreign.Storable
|
| 16 | 13 | import GHC.Internal.Data.Functor ((<$>))
|
| 17 | 14 | import GHC.Internal.Types (Bool(..), Int, IO)
|
| 18 | 15 | import GHC.Internal.Word (Word32)
|
| 19 | 16 | import GHC.Internal.Real (fromIntegral)
|
| 20 | 17 | |
| 18 | +#if defined(javascript_HOST_ARCH)
|
|
| 19 | +import GHC.Internal.Base (pure)
|
|
| 20 | +#else
|
|
| 21 | +import GHC.Internal.Foreign.C.Types
|
|
| 22 | +import GHC.Internal.Foreign.Marshal.Utils
|
|
| 23 | +#endif
|
|
| 24 | + |
|
| 21 | 25 | #include "Rts.h"
|
| 22 | 26 | #include "rts/Flags.h"
|
| 23 | 27 |
| ... | ... | @@ -49,9 +49,13 @@ import GHC.Internal.Base (fmap) |
| 49 | 49 | import GHC.Internal.Classes (Ord(..))
|
| 50 | 50 | import GHC.Internal.Control.Exception.Base (bracket)
|
| 51 | 51 | import GHC.Internal.Err (undefined)
|
| 52 | +#else
|
|
| 53 | +import GHC.Internal.Base (
|
|
| 54 | + map, (++),
|
|
| 55 | + )
|
|
| 52 | 56 | #endif
|
| 53 | 57 | import GHC.Internal.Base (
|
| 54 | - String, liftM, map, mapM, otherwise, return, ($), (.), (++), (>>=),
|
|
| 58 | + String, liftM, mapM, otherwise, return, ($), (.), (>>=),
|
|
| 55 | 59 | )
|
| 56 | 60 | import GHC.Internal.List (null, elem, takeWhile, break)
|
| 57 | 61 | import GHC.Internal.Maybe (Maybe(..))
|
| ... | ... | @@ -43,7 +43,7 @@ import GHC.Internal.Classes (Eq(..)) |
| 43 | 43 | import GHC.Internal.Data.Functor
|
| 44 | 44 | import GHC.Internal.Data.List (elem, null, takeWhile)
|
| 45 | 45 | import GHC.Internal.Foreign.C.String
|
| 46 | -import GHC.Internal.Base (String, otherwise, return, ($))
|
|
| 46 | +import GHC.Internal.Base (String, otherwise, ($))
|
|
| 47 | 47 | #if defined(mingw32_HOST_OS)
|
| 48 | 48 | import GHC.Internal.Base ((.))
|
| 49 | 49 | import GHC.Internal.Foreign.Ptr
|
| ... | ... | @@ -51,6 +51,7 @@ import GHC.Internal.Windows |
| 51 | 51 | import GHC.Internal.Control.Monad
|
| 52 | 52 | import GHC.Internal.Data.List (lookup)
|
| 53 | 53 | #else
|
| 54 | +import GHC.Internal.Base (return)
|
|
| 54 | 55 | import GHC.Internal.Foreign.C.Error
|
| 55 | 56 | import GHC.Internal.Foreign.C.Types
|
| 56 | 57 | import GHC.Internal.Real (fromIntegral)
|
| ... | ... | @@ -249,6 +249,7 @@ import GHC.Internal.Base (String, failIO, otherwise, return, ($), (.), (>>=)) |
| 249 | 249 | import GHC.Internal.List
|
| 250 | 250 | #if !defined(mingw32_HOST_OS)
|
| 251 | 251 | import GHC.Internal.IORef
|
| 252 | +import GHC.Internal.Types (Int)
|
|
| 252 | 253 | #endif
|
| 253 | 254 | import GHC.Internal.Num
|
| 254 | 255 | import GHC.Internal.IO hiding ( bracket, onException )
|
| ... | ... | @@ -262,7 +263,7 @@ import GHC.Internal.IO.Encoding |
| 262 | 263 | import GHC.Internal.Text.Read
|
| 263 | 264 | import GHC.Internal.IO.StdHandles
|
| 264 | 265 | import GHC.Internal.Show
|
| 265 | -import GHC.Internal.Types (Bool(..), Char, Int)
|
|
| 266 | +import GHC.Internal.Types (Bool(..), Char)
|
|
| 266 | 267 | -----------------------------------------------------------------------------
|
| 267 | 268 | -- Standard IO
|
| 268 | 269 |
| ... | ... | @@ -46,19 +46,20 @@ import GHC.Internal.Data.Maybe |
| 46 | 46 | |
| 47 | 47 | #if !defined(HTYPE_TCFLAG_T)
|
| 48 | 48 | import GHC.Internal.System.IO.Error
|
| 49 | +#if !defined(mingw32_HOST_OS)
|
|
| 50 | +import GHC.Internal.Err (errorWithoutStackTrace)
|
|
| 51 | +#endif
|
|
| 49 | 52 | #endif
|
| 50 | 53 | |
| 51 | 54 | import GHC.Internal.Base (
|
| 52 | 55 | String, otherwise, pure, return, when, ($), (++), (>>=),
|
| 53 | 56 | )
|
| 54 | 57 | import GHC.Internal.Bits
|
| 55 | -import GHC.Internal.Classes (Eq(..), Ord(..), not, (&&), (||))
|
|
| 56 | -import GHC.Internal.CString (cstringLength#)
|
|
| 57 | -import GHC.Internal.Err (errorWithoutStackTrace)
|
|
| 58 | +import GHC.Internal.Classes (Eq(..), not, (&&), (||))
|
|
| 58 | 59 | import GHC.Internal.Num
|
| 59 | 60 | import GHC.Internal.Prim (yield#)
|
| 60 | 61 | import GHC.Internal.Real
|
| 61 | -import GHC.Internal.Types (Bool(..), Int(..))
|
|
| 62 | +import GHC.Internal.Types (Bool(..))
|
|
| 62 | 63 | import GHC.Internal.Word
|
| 63 | 64 | import GHC.Internal.IO
|
| 64 | 65 | import GHC.Internal.IO.IOMode
|
| ... | ... | @@ -71,10 +72,13 @@ import GHC.Internal.Int (Int64) |
| 71 | 72 | #endif
|
| 72 | 73 | |
| 73 | 74 | #if !defined(mingw32_HOST_OS)
|
| 75 | +import GHC.Internal.CString (cstringLength#)
|
|
| 76 | +import GHC.Internal.Classes (Ord(..))
|
|
| 74 | 77 | import {-# SOURCE #-} GHC.Internal.IO.Encoding (getFileSystemEncoding)
|
| 75 | 78 | import GHC.Internal.Foreign.Marshal.Utils
|
| 76 | 79 | import GHC.Internal.Foreign.Storable
|
| 77 | 80 | import qualified GHC.Internal.Foreign.C.String.Encoding as GHC
|
| 81 | +import GHC.Internal.Types (Int(..))
|
|
| 78 | 82 | #else
|
| 79 | 83 | import GHC.Internal.Int
|
| 80 | 84 | import GHC.Internal.Data.OldList (elem)
|
| ... | ... | @@ -39,12 +39,12 @@ module GHC.Internal.TopHandler ( |
| 39 | 39 | import GHC.Internal.Control.Exception
|
| 40 | 40 | import GHC.Internal.Data.Maybe
|
| 41 | 41 | |
| 42 | -import GHC.Internal.Classes (Eq(..), Ord(..), (&&))
|
|
| 42 | +import GHC.Internal.Classes (Eq(..))
|
|
| 43 | 43 | import GHC.Internal.Foreign.C.Error
|
| 44 | 44 | import GHC.Internal.Foreign.C.Types
|
| 45 | 45 | import GHC.Internal.Foreign.C.String
|
| 46 | 46 | import GHC.Internal.Base (
|
| 47 | - String, const, failIO, otherwise, pure, return, ($), (++), (>>),
|
|
| 47 | + String, failIO, return, ($), (++), (>>),
|
|
| 48 | 48 | )
|
| 49 | 49 | import GHC.Internal.Conc.Sync hiding (throwTo)
|
| 50 | 50 | import GHC.Internal.Prim (Weak#, seq)
|
| ... | ... | @@ -67,6 +67,17 @@ import GHC.Internal.Conc.Signal |
| 67 | 67 | import GHC.Internal.Data.Dynamic (toDyn)
|
| 68 | 68 | #endif
|
| 69 | 69 | |
| 70 | +#if !defined(HAVE_SIGNAL_H)
|
|
| 71 | +import GHC.Internal.Base (pure)
|
|
| 72 | +#endif
|
|
| 73 | + |
|
| 74 | +#if !defined(mingw32_HOST_OS) && !defined(javascript_HOST_ARCH)
|
|
| 75 | +import GHC.Internal.Base (
|
|
| 76 | + const, otherwise,
|
|
| 77 | + )
|
|
| 78 | +import GHC.Internal.Classes (Ord(..), (&&))
|
|
| 79 | +#endif
|
|
| 80 | + |
|
| 70 | 81 | -- Note [rts_setMainThread must be called unsafely]
|
| 71 | 82 | -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 72 | 83 | -- rts_setMainThread must be called as unsafe, because it
|
| ... | ... | @@ -246,6 +246,11 @@ data Message a where |
| 246 | 246 | :: RemoteRef (ResumeContext ())
|
| 247 | 247 | -> Message (EvalStatus ())
|
| 248 | 248 | |
| 249 | + -- | User-defined request encoded as a tag/payload pair. This is left
|
|
| 250 | + -- uninterpreted by GHC and is meant for GHC API applications to be able to supply
|
|
| 251 | + -- their own interpreter which understands additional commands.
|
|
| 252 | + CustomMessage :: Word8 -> ByteString -> Message ByteString
|
|
| 253 | + |
|
| 249 | 254 | deriving instance Show (Message a)
|
| 250 | 255 | |
| 251 | 256 | -- | Used to dynamically create a data constructor's info table at
|
| ... | ... | @@ -602,6 +607,7 @@ getMessage = do |
| 602 | 607 | 38 -> Msg <$> (ResumeSeq <$> get)
|
| 603 | 608 | 39 -> Msg <$> (LookupSymbolInDLL <$> get <*> get)
|
| 604 | 609 | 40 -> Msg <$> (WhereFrom <$> get)
|
| 610 | + 41 -> Msg <$> (CustomMessage <$> get <*> get)
|
|
| 605 | 611 | _ -> error $ "Unknown Message code " ++ (show b)
|
| 606 | 612 | |
| 607 | 613 | putMessage :: Message a -> Put
|
| ... | ... | @@ -648,6 +654,7 @@ putMessage m = case m of |
| 648 | 654 | ResumeSeq a -> putWord8 38 >> put a
|
| 649 | 655 | LookupSymbolInDLL dll str -> putWord8 39 >> put dll >> put str
|
| 650 | 656 | WhereFrom a -> putWord8 40 >> put a
|
| 657 | + CustomMessage tag payload -> putWord8 41 >> put tag >> put payload
|
|
| 651 | 658 | |
| 652 | 659 | {-
|
| 653 | 660 | Note [Parallelize CreateBCOs serialization]
|
| ... | ... | @@ -125,6 +125,7 @@ run m = case m of |
| 125 | 125 | Shutdown -> unexpectedMessage m
|
| 126 | 126 | RunTH {} -> unexpectedMessage m
|
| 127 | 127 | RunModFinalizers {} -> unexpectedMessage m
|
| 128 | + CustomMessage {} -> unexpectedMessage m
|
|
| 128 | 129 | |
| 129 | 130 | unexpectedMessage :: Message a -> b
|
| 130 | 131 | unexpectedMessage m = error ("GHCi.Run.Run: unexpected message: " ++ show m)
|
| 1 | 1 | {-# LANGUAGE CPP, RankNTypes, RecordWildCards, GADTs, ScopedTypeVariables #-}
|
| 2 | 2 | module GHCi.Server
|
| 3 | - ( serv
|
|
| 3 | + ( MessageHook
|
|
| 4 | + , CustomMessageHandler
|
|
| 5 | + , serv
|
|
| 6 | + , servWithCustom
|
|
| 4 | 7 | , defaultServer
|
| 8 | + , defaultServerWithCustom
|
|
| 5 | 9 | )
|
| 6 | 10 | where
|
| 7 | 11 | |
| ... | ... | @@ -10,8 +14,8 @@ import GHCi.Run |
| 10 | 14 | import GHCi.Signals
|
| 11 | 15 | import GHCi.TH
|
| 12 | 16 | import GHCi.Message
|
| 13 | -#if defined(wasm32_HOST_ARCH)
|
|
| 14 | 17 | import Data.ByteString (ByteString)
|
| 18 | +#if defined(wasm32_HOST_ARCH)
|
|
| 15 | 19 | import qualified Data.ByteString.Builder as B
|
| 16 | 20 | import qualified Data.ByteString.Internal as B
|
| 17 | 21 | import qualified Data.ByteString.Unsafe as B
|
| ... | ... | @@ -36,11 +40,27 @@ import System.IO |
| 36 | 40 | |
| 37 | 41 | type MessageHook = Msg -> IO Msg
|
| 38 | 42 | |
| 43 | +-- | How to interpret the 'CustomCommand'.
|
|
| 44 | +type CustomMessageHandler = Word8 -> ByteString -> IO (Maybe ByteString)
|
|
| 45 | + |
|
| 46 | +noCustomHandler :: CustomMessageHandler
|
|
| 47 | +noCustomHandler _ _ = return Nothing
|
|
| 48 | + |
|
| 39 | 49 | trace :: String -> IO ()
|
| 40 | 50 | trace s = getProgName >>= \name -> hPrintf stderr "[%20s] %s\n" name s
|
| 41 | 51 | |
| 42 | 52 | serv :: Bool -> MessageHook -> Pipe -> (forall a .IO a -> IO a) -> IO ()
|
| 43 | -serv verbose hook pipe restore = loop
|
|
| 53 | +serv verbose hook pipe restore =
|
|
| 54 | + servWithCustom verbose hook pipe restore noCustomHandler
|
|
| 55 | + |
|
| 56 | +servWithCustom
|
|
| 57 | + :: Bool
|
|
| 58 | + -> MessageHook
|
|
| 59 | + -> Pipe
|
|
| 60 | + -> (forall a .IO a -> IO a)
|
|
| 61 | + -> CustomMessageHandler
|
|
| 62 | + -> IO ()
|
|
| 63 | +servWithCustom verbose hook pipe restore customHandler = loop
|
|
| 44 | 64 | where
|
| 45 | 65 | loop = do
|
| 46 | 66 | when verbose $ trace "reading pipe..."
|
| ... | ... | @@ -50,6 +70,7 @@ serv verbose hook pipe restore = loop |
| 50 | 70 | |
| 51 | 71 | when verbose $ trace ("msg: " ++ (show msg))
|
| 52 | 72 | case msg of
|
| 73 | + CustomMessage tag payload -> handleCustom tag payload
|
|
| 53 | 74 | Shutdown -> return ()
|
| 54 | 75 | RunTH st q ty loc -> wrapRunTH $ runTH pipe st q ty loc
|
| 55 | 76 | RunModFinalizers st qrefs -> wrapRunTH $ runModFinalizerRefs pipe st qrefs
|
| ... | ... | @@ -61,6 +82,13 @@ serv verbose hook pipe restore = loop |
| 61 | 82 | writePipe pipe (put r)
|
| 62 | 83 | loop
|
| 63 | 84 | |
| 85 | + handleCustom tag payload = do
|
|
| 86 | + mresp <- customHandler tag payload
|
|
| 87 | + case mresp of
|
|
| 88 | + Just resp -> reply resp
|
|
| 89 | + Nothing ->
|
|
| 90 | + error $ "GHCi.Server: unhandled CustomMessage with tag " ++ show tag
|
|
| 91 | + |
|
| 64 | 92 | -- Run some TH code, which may interact with GHC by sending
|
| 65 | 93 | -- THMessage requests, and then finally send RunTHDone followed by a
|
| 66 | 94 | -- QResult. For an overview of how TH works with Remote GHCi, see
|
| ... | ... | @@ -109,12 +137,24 @@ serv verbose hook pipe restore = loop |
| 109 | 137 | -- | Default server
|
| 110 | 138 | #if defined(wasm32_HOST_ARCH)
|
| 111 | 139 | defaultServer :: Callback (JSVal -> IO ()) -> Callback (IO JSUint8Array) -> Callback (JSUint8Array -> IO ()) -> IO ()
|
| 112 | -defaultServer cb_sig cb_recv cb_send = do
|
|
| 140 | +defaultServer cb_sig cb_recv cb_send =
|
|
| 141 | + defaultServerWithCustom cb_sig cb_recv cb_send noCustomHandler
|
|
| 142 | + |
|
| 143 | +defaultServerWithCustom
|
|
| 144 | + :: Callback (JSVal -> IO ())
|
|
| 145 | + -> Callback (IO JSUint8Array)
|
|
| 146 | + -> Callback (JSUint8Array -> IO ())
|
|
| 147 | + -> CustomMessageHandler
|
|
| 148 | + -> IO ()
|
|
| 149 | +defaultServerWithCustom cb_sig cb_recv cb_send customHandler = do
|
|
| 113 | 150 | args <- getArgs
|
| 114 | 151 | let rest = args
|
| 115 | 152 | #else
|
| 116 | 153 | defaultServer :: IO ()
|
| 117 | -defaultServer = do
|
|
| 154 | +defaultServer = defaultServerWithCustom noCustomHandler
|
|
| 155 | + |
|
| 156 | +defaultServerWithCustom :: CustomMessageHandler -> IO ()
|
|
| 157 | +defaultServerWithCustom customHandler = do
|
|
| 118 | 158 | args <- getArgs
|
| 119 | 159 | (outh, inh, rest) <-
|
| 120 | 160 | case args of
|
| ... | ... | @@ -152,7 +192,7 @@ defaultServer = do |
| 152 | 192 | putStrLn "Waiting 3s"
|
| 153 | 193 | threadDelay 3000000
|
| 154 | 194 | |
| 155 | - uninterruptibleMask $ serv verbose hook pipe
|
|
| 195 | + uninterruptibleMask $ \restore -> servWithCustom verbose hook pipe restore customHandler
|
|
| 156 | 196 | |
| 157 | 197 | where hook = return -- empty hook
|
| 158 | 198 | -- we cannot allow any async exceptions while communicating, because
|
| ... | ... | @@ -718,7 +718,7 @@ slow_spw(void *Sp, StgStack *cur_stack, StgWord offset_words){ |
| 718 | 718 | }
|
| 719 | 719 | // 2b. Access the element if there is no underflow frame, it must be right
|
| 720 | 720 | // at the top of the stack.
|
| 721 | - else if(Sp_plusW(offset_words) < (StgPtr)(cur_stack->stack + cur_stack->stack_size)) {
|
|
| 721 | + else if(Sp_plusW(offset_words) < (void*)(cur_stack->stack + cur_stack->stack_size)) {
|
|
| 722 | 722 | // Still inside the stack chunk
|
| 723 | 723 | return Sp_plusW(offset_words);
|
| 724 | 724 | } else {
|
| ... | ... | @@ -2469,7 +2469,7 @@ run_BCO: |
| 2469 | 2469 | threadStackUnderflow(cap, cap->r.rCurrentTSO);
|
| 2470 | 2470 | LOAD_STACK_POINTERS;
|
| 2471 | 2471 | by -= sp_to_uf;
|
| 2472 | - } else if (Sp_plusW(by) < (StgPtr)(stk->stack + stk->stack_size)) {
|
|
| 2472 | + } else if (Sp_plusW(by) < (void*)(stk->stack + stk->stack_size)) {
|
|
| 2473 | 2473 | // we're within the first stack chunk, this chunk has
|
| 2474 | 2474 | // no underflow frame
|
| 2475 | 2475 | break;
|
| 1 | +{-# LANGUAGE OverloadedStrings, GADTs, TypeAbstractions #-}
|
|
| 2 | +module Main (main) where
|
|
| 3 | + |
|
| 4 | +import qualified Data.Binary as Bin
|
|
| 5 | +import qualified Data.ByteString as BS
|
|
| 6 | +import qualified Data.ByteString.Lazy as BL
|
|
| 7 | +import Control.Exception (bracket)
|
|
| 8 | +import Control.Monad (void)
|
|
| 9 | +import Data.Word (Word8)
|
|
| 10 | +import GHCi.Message
|
|
| 11 | + ( Message(..)
|
|
| 12 | + , mkPipeFromHandles
|
|
| 13 | + , remoteCall
|
|
| 14 | + , Pipe
|
|
| 15 | + )
|
|
| 16 | +import GHCi.Server
|
|
| 17 | + ( CustomMessageHandler
|
|
| 18 | + , defaultServerWithCustom
|
|
| 19 | + )
|
|
| 20 | +import System.Environment
|
|
| 21 | + ( getArgs
|
|
| 22 | + , getExecutablePath
|
|
| 23 | + , getProgName
|
|
| 24 | + , withArgs
|
|
| 25 | + )
|
|
| 26 | +import System.Exit (exitFailure)
|
|
| 27 | +import System.IO
|
|
| 28 | + ( Handle
|
|
| 29 | + , BufferMode(..)
|
|
| 30 | + , hSetBuffering
|
|
| 31 | + , hSetBinaryMode
|
|
| 32 | + , hClose
|
|
| 33 | + , hPutStrLn
|
|
| 34 | + , stderr
|
|
| 35 | + )
|
|
| 36 | +import System.Posix.IO
|
|
| 37 | + ( createPipe
|
|
| 38 | + , fdToHandle
|
|
| 39 | + , setFdOption
|
|
| 40 | + , FdOption(CloseOnExec)
|
|
| 41 | + )
|
|
| 42 | +import System.Process
|
|
| 43 | + ( createProcess
|
|
| 44 | + , proc
|
|
| 45 | + , std_in
|
|
| 46 | + , std_out
|
|
| 47 | + , std_err
|
|
| 48 | + , StdStream(Inherit)
|
|
| 49 | + , terminateProcess
|
|
| 50 | + , waitForProcess
|
|
| 51 | + , ProcessHandle
|
|
| 52 | + )
|
|
| 53 | +import Text.Read (readMaybe)
|
|
| 54 | + |
|
| 55 | +--------------------------------------------------------------------------------
|
|
| 56 | +-- Shared request/response definitions and helpers
|
|
| 57 | + |
|
| 58 | +data ClientCommand a where
|
|
| 59 | + SquareCommand :: Int -> ClientCommand Int
|
|
| 60 | + MulCommand :: Int -> Int -> ClientCommand Int
|
|
| 61 | + |
|
| 62 | +deriving instance (Show (ClientCommand a))
|
|
| 63 | + |
|
| 64 | +data Some c f where
|
|
| 65 | + Some :: c a => f a -> Some c f
|
|
| 66 | + |
|
| 67 | + |
|
| 68 | +instance Bin.Binary (Some Bin.Binary ClientCommand) where
|
|
| 69 | + put (Some i) =
|
|
| 70 | + case i of
|
|
| 71 | + SquareCommand n -> Bin.put (0 :: Word8) >> Bin.put n
|
|
| 72 | + MulCommand m n -> Bin.put (1 :: Word8) >> Bin.put m >> Bin.put n
|
|
| 73 | + |
|
| 74 | + get = do
|
|
| 75 | + (tag :: Word8) <- Bin.get
|
|
| 76 | + fmap Some $ case tag of
|
|
| 77 | + 0 -> SquareCommand <$> Bin.get
|
|
| 78 | + 1 -> MulCommand <$> Bin.get <*> Bin.get
|
|
| 79 | + |
|
| 80 | + |
|
| 81 | +customTag :: Word8
|
|
| 82 | +customTag = 0x42
|
|
| 83 | + |
|
| 84 | +encodeLazy :: Bin.Binary a => a -> BS.ByteString
|
|
| 85 | +encodeLazy = BL.toStrict . Bin.encode
|
|
| 86 | + |
|
| 87 | +decodeLazy :: Bin.Binary a => BS.ByteString -> Either String a
|
|
| 88 | +decodeLazy bs =
|
|
| 89 | + case Bin.decodeOrFail (BL.fromStrict bs) of
|
|
| 90 | + Left (_, _, err) -> Left err
|
|
| 91 | + Right (_, _, a) -> Right a
|
|
| 92 | + |
|
| 93 | +--------------------------------------------------------------------------------
|
|
| 94 | +-- Mode selection
|
|
| 95 | + |
|
| 96 | +data Mode
|
|
| 97 | + = RunClient Int
|
|
| 98 | + | RunServer [String] -- forwarded to GHCi.Server
|
|
| 99 | + |
|
| 100 | +defaultInput :: Int
|
|
| 101 | +defaultInput = 12
|
|
| 102 | + |
|
| 103 | +parseMode :: [String] -> Either String Mode
|
|
| 104 | +parseMode [] = Right (RunClient defaultInput)
|
|
| 105 | +parseMode ["client"] = Right (RunClient defaultInput)
|
|
| 106 | +parseMode ["client", nStr] =
|
|
| 107 | + case readMaybe nStr of
|
|
| 108 | + Just n -> Right (RunClient n)
|
|
| 109 | + Nothing -> Left $ "Unable to parse integer argument: " ++ nStr
|
|
| 110 | +parseMode ("client":_) = Left "Too many arguments for client mode."
|
|
| 111 | +parseMode ("server":rest) = Right (RunServer rest)
|
|
| 112 | +parseMode args = Left "Unknown mode, use client/server"
|
|
| 113 | + |
|
| 114 | +usage :: IO ()
|
|
| 115 | +usage = do
|
|
| 116 | + prog <- getProgName
|
|
| 117 | + putStrLn $ unlines
|
|
| 118 | + [ "Usage:"
|
|
| 119 | + , " " ++ prog ++ " [client [n]] Run the client and square n (default 12)."
|
|
| 120 | + , " " ++ prog ++ " server <write-fd> <read-fd> Run as an iserv process."
|
|
| 121 | + ]
|
|
| 122 | + |
|
| 123 | +--------------------------------------------------------------------------------
|
|
| 124 | +-- Client/server drivers
|
|
| 125 | + |
|
| 126 | +main :: IO ()
|
|
| 127 | +main = do
|
|
| 128 | + args <- getArgs
|
|
| 129 | + case parseMode args of
|
|
| 130 | + Left err -> do
|
|
| 131 | + hPutStrLn stderr err
|
|
| 132 | + usage
|
|
| 133 | + exitFailure
|
|
| 134 | + Right (RunClient n) -> runClient n
|
|
| 135 | + Right (RunServer serverArgs) ->
|
|
| 136 | + withArgs serverArgs (defaultServerWithCustom (customHandler handleClientCommand))
|
|
| 137 | + |
|
| 138 | +handleClientCommand :: ClientCommand a -> IO a
|
|
| 139 | +handleClientCommand (SquareCommand n) = pure $ n * n
|
|
| 140 | +handleClientCommand (MulCommand n m) = pure $ n * m
|
|
| 141 | + |
|
| 142 | + |
|
| 143 | +customMessage :: (Show a, Bin.Binary a) => Pipe -> ClientCommand a -> IO a
|
|
| 144 | +customMessage pipe c = do
|
|
| 145 | + let payload = encodeLazy (Some @Bin.Binary c)
|
|
| 146 | + putStrLn $ "Sending: " ++ show c
|
|
| 147 | + respBytes <- remoteCall pipe (CustomMessage customTag payload)
|
|
| 148 | + case decodeLazy respBytes of
|
|
| 149 | + Left err -> error $ "Decode error: " ++ err
|
|
| 150 | + Right res -> pure res
|
|
| 151 | + |
|
| 152 | + |
|
| 153 | +runClient :: Int -> IO ()
|
|
| 154 | +runClient input = do
|
|
| 155 | + serverExe <- getExecutablePath
|
|
| 156 | + withServer serverExe $ \hFromServer hToServer -> do
|
|
| 157 | + pipe <- mkPipeFromHandles hFromServer hToServer
|
|
| 158 | + res <- customMessage pipe (SquareCommand input)
|
|
| 159 | + putStrLn $ "Square returned: " ++ show res
|
|
| 160 | + res2 <- customMessage pipe (MulCommand 2 res)
|
|
| 161 | + putStrLn $ "Mul returned: " ++ show res2
|
|
| 162 | + |
|
| 163 | +withServer :: FilePath -> (Handle -> Handle -> IO a) -> IO a
|
|
| 164 | +withServer serverExe action = do
|
|
| 165 | + (ghcRead, serverWrite) <- createPipe
|
|
| 166 | + (serverRead, ghcWrite) <- createPipe
|
|
| 167 | + mapM_ (\h -> setFdOption h CloseOnExec False) [serverWrite, serverRead]
|
|
| 168 | + let args = ["server", show serverWrite, show serverRead]
|
|
| 169 | + (_, _, _, ph) <- createProcess (proc serverExe args)
|
|
| 170 | + { std_in = Inherit
|
|
| 171 | + , std_out = Inherit
|
|
| 172 | + , std_err = Inherit
|
|
| 173 | + }
|
|
| 174 | + bracket (mkHandles ghcRead ghcWrite)
|
|
| 175 | + (\(hFromServer, hToServer) -> do
|
|
| 176 | + hClose hFromServer
|
|
| 177 | + hClose hToServer
|
|
| 178 | + terminateProcess ph
|
|
| 179 | + void (waitForProcess ph))
|
|
| 180 | + (\(hFromServer, hToServer) -> action hFromServer hToServer)
|
|
| 181 | + where
|
|
| 182 | + mkHandles r w = do
|
|
| 183 | + hR <- fdToHandle r
|
|
| 184 | + hW <- fdToHandle w
|
|
| 185 | + mapM_ (`hSetBuffering` NoBuffering) [hR, hW]
|
|
| 186 | + mapM_ (`hSetBinaryMode` True) [hR, hW]
|
|
| 187 | + pure (hR, hW)
|
|
| 188 | + |
|
| 189 | +--------------------------------------------------------------------------------
|
|
| 190 | +-- Custom handler
|
|
| 191 | + |
|
| 192 | +customHandler :: (Bin.Binary (Some Bin.Binary f)) => (forall a . f a -> IO a) -> CustomMessageHandler
|
|
| 193 | +customHandler handler tag payload
|
|
| 194 | + | tag == customTag =
|
|
| 195 | + case decodeLazy payload of
|
|
| 196 | + Left err -> do
|
|
| 197 | + hPutStrLn stderr $ "Custom handler decode error: " ++ err
|
|
| 198 | + pure Nothing
|
|
| 199 | + Right (Some @Bin.Binary r) -> do
|
|
| 200 | + res <- handler r
|
|
| 201 | + pure . Just $ encodeLazy res
|
|
| 202 | + | otherwise = pure Nothing |
| 1 | +test('custom-external-interpreter-commands',
|
|
| 2 | + [ extra_files(['Main.hs'])
|
|
| 3 | + , windows_skip
|
|
| 4 | + , when(config.cross, skip)
|
|
| 5 | + , req_process
|
|
| 6 | + , req_interp
|
|
| 7 | + , omit_ways(prof_ways)
|
|
| 8 | + ],
|
|
| 9 | + multimod_compile_and_run,
|
|
| 10 | + ['Main.hs', '-package ghci']) |
| 1 | +Sending: SquareCommand 12
|
|
| 2 | +Square returned: 144
|
|
| 3 | +Sending: MulCommand 2 144
|
|
| 4 | +Mul returned: 288 |