Repository navigation
feat: add Haskell build toolchain (GHC, Cabal, Stack) #178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
5e9f2a7
feat: add Haskell build toolchain (GHC, Cabal, Stack)
0chroma e1eedd4
fix: remove extra blank line in ghc/build.sh
0chroma 8965f4b
fix(cabal,stack): use strict shell options in build scripts
0chroma 516a3d1
fix(cabal): set executable permission on build.sh
0chroma 57273af
ci: trigger re-run of minimal build check
0chroma 9c60178
fix(ghc): manually extract and remove nofib to avoid staging symlinks
0chroma 3b03915
fix(ghc): remove unnecessary boot step
0chroma 28bd7da
fix(ghc): strip source prefix and simplify build flags
0chroma e46526a
fix(ghc): use tar -xof to preserve original permissions
0chroma 3651e0c
fix(ghc): use #!/bin/bash shebang matching repo convention
0chroma 1d6c6d7
fix(cabal,stack): use #!/bin/bash shebang matching repo convention
0chroma 3e275b2
fix(ghc): add self-dependency to trigger replace_on_cycle for bootstr…
0chroma 0fc1c2c
fix(ghc): enable auto-extraction and cd into extracted directory
0chroma 566a6cf
fix(ghc): revert to manual extraction to avoid sandbox staging failure
0chroma c51209b
fix(haskell): address code review feedback
0chroma cdb9325
refactor(cabal,stack): simplify build command
0chroma c5701d9
fix(ghc, cabal): quote version variable and add cabal file regex
0chroma 0f4add6
fix(ghc): use /bin/sh instead of /bin/bash in build.sh to fix sandbox…
0chroma 37e205d
fix(ghc): restore robust manual bootstrap pipeline to avoid sandbox s…
0chroma 9d6cdd1
fix(ghc): remove --root flag from hadrian install, use default OUTPUT…
0chroma a34537b
fix(ghc): remove unused needs block, docs output, and mirror source_p…
0chroma 1c5137d
ghc: fix install step by staging to $OUTPUT_DIR via DESTDIR
0chroma a57128b
ghc: build cabal-install from source to break circular dependency
0chroma 00e2b76
ghc: replace cabal-install source build with stub
0chroma a27a3c3
ghc: add needs, runtime_deps, tests per guidelines
0chroma 852a4e1
ghc: add arm64 support via architecture-aware bootstrap
0chroma fa28b37
cabal: fix build with GHC 9.10.1 using bootstrap approach
0chroma c1c2ed3
stack: add missing cabal build dependency
0chroma b83c3fe
ghc: add toolchain to runtime deps and refresh package cache after in…
0chroma e6a1b90
ghc, cabal: remove redundant build_deps entries already in runtime_deps
0chroma b5bc9a0
stack: fix GHC version mismatch and remove pinned dependencies
0chroma c8c2df6
ghc: upgrade from 9.10.1 to 9.10.3
0chroma 8fcdaf3
ghc: force hadrian bootstrap to use the offline bootstrap-sources tar…
0chroma 757c74a
Fix GHC, Cabal, and Stack builds for GHC 9.10.3
0chroma 1d6295d
fix(ghc): allow executable files in libghc OutputData
0chroma File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| let { harness, .. } = import "minimal.ncl" in | ||
| harness { | ||
| name = "cabal", | ||
|
|
||
| build_packages = ["ghc", "cabal", "base"], | ||
|
|
||
| build_cmd = "cabal build", | ||
|
|
||
| # Predicates for when this harness is usable in a source tree - powers `minimal init` | ||
| matches_project_if_any = [ | ||
| { | ||
| file_regexes."cabal.project" = "*", | ||
| }, | ||
| { | ||
| file_regexes."*.cabal" = "*", | ||
| }, | ||
| ], | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| let { harness, .. } = import "minimal.ncl" in | ||
| harness { | ||
| name = "stack", | ||
|
|
||
| build_packages = ["stack", "ghc", "base"], | ||
|
|
||
| build_cmd = "stack build", | ||
|
|
||
| # Predicates for when this harness is usable in a source tree - powers `minimal init` | ||
| matches_project_if_any = [ | ||
| { | ||
| file_regexes."stack.yaml" = "*", | ||
| }, | ||
| ], | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| let { Attrs, BuildSpec, Local, Needs, OutputBin, OutputData, Source, .. } = import "minimal.ncl" in | ||
| let base = import "../base/build.ncl" in | ||
| let ghc = import "../ghc/build.ncl" in | ||
| let gmp = import "../gmp/build.ncl" in | ||
| let python = import "../python/build.ncl" in | ||
|
|
||
| let version = "3.12.1.0" in | ||
| { | ||
| name = "cabal", | ||
| build_deps = [ | ||
| { file = "build.sh" } | Local, | ||
| { file = "update_bootstrap_json.py" } | Local, | ||
| { | ||
| url = "https://github.com/haskell/cabal/archive/refs/tags/cabal-install-v%{version}.tar.gz", | ||
| sha256 = "84e883989cf44341dada05f866ec2b0256ac1f3bd111fcf80e7b6a7b77942af3", | ||
| extract = true, | ||
| strip_prefix = "cabal-cabal-install-v%{version}", | ||
| } | Source, | ||
| base, | ||
| ghc, | ||
| python, | ||
| ], | ||
| runtime_deps = [ | ||
| gmp, | ||
| ], | ||
|
|
||
| needs = | ||
| { | ||
| dns = {}, | ||
| internet = {}, | ||
| } | Needs, | ||
|
|
||
| cmd = "./build.sh", | ||
|
|
||
| build_args = { | ||
| include version, | ||
| }, | ||
|
|
||
| outputs = { | ||
| cabal = { glob = "usr/bin/cabal" } | OutputBin, | ||
| docs = { glob = "usr/share/doc/**" } | OutputData, | ||
| }, | ||
|
|
||
| attrs = | ||
| { | ||
| upstream_version = version, | ||
| source_provenance = { | ||
| category = 'GithubRepo, | ||
| owner = "haskell", | ||
| repo = "cabal", | ||
| }, | ||
| build_cost_multiple = 3, | ||
| } | Attrs, | ||
| } | BuildSpec |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| #!/bin/bash | ||
| set -euo pipefail | ||
|
|
||
| # Patch monorepo .cabal files to accept GHC 9.10.1's built-in Cabal-syntax-3.12.0.0 | ||
| # (cabal-install-3.12.1.0 expects ^>=3.12.1.0 but GHC 9.10.1 ships 3.12.0.0) | ||
| for cabal_file in \ | ||
| Cabal/Cabal.cabal \ | ||
| Cabal-syntax/Cabal-syntax.cabal \ | ||
| cabal-install-solver/cabal-install-solver.cabal \ | ||
| cabal-install/cabal-install.cabal; do | ||
| if [ -f "$cabal_file" ]; then | ||
| sed -i 's/Cabal-syntax\s*\^>=\s*3\.12\.1\.0/Cabal-syntax >= 3.12.0.0 \&\& < 3.13/g' "$cabal_file" | ||
| sed -i 's/Cabal\s*\^>=\s*3\.12\.1\.0/Cabal >= 3.12.0.0 \&\& < 3.13/g' "$cabal_file" | ||
| fi | ||
| done | ||
|
|
||
| # Generate a bootstrap JSON that matches the actual GHC in the sandbox | ||
| python3 update_bootstrap_json.py bootstrap/linux-9.8.2.json > bootstrap/linux-actual.json | ||
|
|
||
| # Run the bootstrap script with the generated JSON | ||
| python3 bootstrap/bootstrap.py -w "$(command -v ghc)" -d bootstrap/linux-actual.json | ||
|
|
||
| # The bootstrap script compiles cabal-install and installs to _build/bin | ||
| mkdir -p "$OUTPUT_DIR"/usr/bin | ||
| cp -v _build/bin/cabal "$OUTPUT_DIR"/usr/bin/cabal | ||
|
|
||
| # Install man pages (may not exist in all versions) | ||
| mkdir -p "$OUTPUT_DIR"/usr/share/man/man1 | ||
| cp -v doc/man/cabal.1 "$OUTPUT_DIR"/usr/share/man/man1/ 2>/dev/null || true | ||
|
|
||
| # Install documentation | ||
| mkdir -p "$OUTPUT_DIR"/usr/share/doc/cabal | ||
| cp -v README.md "$OUTPUT_DIR"/usr/share/doc/cabal/ 2>/dev/null || true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| #!/usr/bin/env python3 | ||
| import sys | ||
| import json | ||
| import subprocess | ||
|
|
||
| # Read existing JSON template | ||
| with open(sys.argv[1]) as f: | ||
| data = json.load(f) | ||
|
|
||
| # Query actual package versions from GHC | ||
| pkg_list_str = subprocess.check_output(['ghc-pkg', 'list', '--simple-output'], text=True) | ||
| actual_pkgs = {} | ||
| for item in pkg_list_str.strip().split(): | ||
| if '-' in item: | ||
| # Split on the last hyphen to handle packages like template-haskell | ||
| parts = item.rsplit('-', 1) | ||
| if len(parts) == 2: | ||
| actual_pkgs[parts[0]] = parts[1] | ||
|
|
||
| # Update the builtin list | ||
| new_builtin = [] | ||
| for entry in data.get('builtin', []): | ||
| name = entry['package'] | ||
| if name in actual_pkgs: | ||
| new_builtin.append({'package': name, 'version': actual_pkgs[name]}) | ||
| else: | ||
| new_builtin.append(entry) | ||
|
|
||
| data['builtin'] = new_builtin | ||
|
|
||
| # Update specific dependencies that are too old for GHC 9.10.3. | ||
| # Each entry maps a package name to new version, revision, source hash, and .cabal hash. | ||
| # All hashes are from Hackage and verified at packaging time. | ||
| dep_updates = { | ||
| 'th-compat': { | ||
| 'version': '0.1.7', | ||
| 'revision': 0, | ||
| 'src_sha256': '9e26f12230d38ae56dcf94f8c139799dc3b7376f3434d35ce74847a0a24fd5ff', | ||
| 'cabal_sha256': '449be09a4e3f46ea4645700c026624c4b6f066f508187326c284dbdea8884bc9', | ||
| }, | ||
| 'hashable': { | ||
| 'version': '1.4.7.0', | ||
| 'revision': 0, | ||
| 'src_sha256': '3baee4c9027a08830d148ec524cbc0471de645e1e8426d46780ef2758df0e8da', | ||
| 'cabal_sha256': '573f3ab242f75465a0d67ce9d84202650a1606575e6dbd6d31ffcf4767a9a379', | ||
| }, | ||
| 'async': { | ||
| 'version': '2.2.5', | ||
| 'revision': 2, | ||
| 'src_sha256': '1818473ebab9212afad2ed76297aefde5fae8b5d4404daf36939aece6a8f16f7', | ||
| 'cabal_sha256': 'cf9e6afba8e01830ca0d32a12b98d481cf389688762c80d1870a1db2061ebf35', | ||
| }, | ||
| 'lukko': { | ||
| 'version': '0.1.2', | ||
| 'revision': 0, | ||
| 'src_sha256': '72d86f8aa625b461f4397f737346f78a1700a7ffbff55cf6375c5e18916e986d', | ||
| 'cabal_sha256': '8a3004c2de2a0b5ef0634d3da6eae62ba8d8a734bab9ed8c6cfd749e7ca08997', | ||
| }, | ||
| 'HTTP': { | ||
| 'version': '4000.4.1', | ||
| 'revision': 6, | ||
| 'src_sha256': 'df31d8efec775124dab856d7177ddcba31be9f9e0836ebdab03d94392f2dd453', | ||
| 'cabal_sha256': 'ad36c6a1b3bc203b02751c8bffae8a684cc755661a2a567362cd4a0da1193c5e', | ||
| }, | ||
| 'hackage-security': { | ||
| 'version': '0.6.3.2', | ||
| 'revision': 0, | ||
| 'src_sha256': 'bf8f97868ed5219d0a13a90fcbfad819bbeba4ab368c5cb590b57202c98768f9', | ||
| 'cabal_sha256': 'ffb311c0750ff3fa159c101838e48ab79c1ea2a23c29fd5cd8932b208dfedb33', | ||
| }, | ||
| 'splitmix': { | ||
| 'version': '0.1.1', | ||
| 'revision': 0, | ||
| 'src_sha256': 'd678c41a603a62032cf7e5f8336bb8222c93990e4b59c8b291b7ca26c7eb12c7', | ||
| 'cabal_sha256': '8f92088f1c51c8d4569279a07565f8aa6b534a6735615b2295d2961dec8f1783', | ||
| }, | ||
| 'cryptohash-sha256': { | ||
| 'version': '0.11.102.1', | ||
| 'revision': 5, | ||
| 'src_sha256': '73a7dc7163871a80837495039a099967b11f5c4fe70a118277842f7a713c6bf6', | ||
| 'cabal_sha256': 'acb64f2af52d81b0bb92c266f11d43def726a7a7b74a2c23d219e160b54edec7', | ||
| }, | ||
| 'tar': { | ||
| 'version': '0.6.3.0', | ||
| 'revision': 0, | ||
| 'src_sha256': '50bb660feec8a524416d6934251b996eaa7e39d49ae107ad505ab700d43f6814', | ||
| 'cabal_sha256': 'b853b4296cb23386feda17dc0d9065af6709d22d684ec734aab65403d59ed547', | ||
| }, | ||
| 'random': { | ||
| 'version': '1.2.1.2', | ||
| 'revision': 0, | ||
| 'src_sha256': '790f4dc2d2327c453ff6aac7bf15399fd123d55e927935f68f84b5df42d9a4b4', | ||
| 'cabal_sha256': '32397de181e20ccaacf806ec70de9308cf044f089a2be37c936f3f8967bde867', | ||
| }, | ||
| 'zlib': { | ||
| 'version': '0.7.1.0', | ||
| 'revision': 0, | ||
| 'src_sha256': '6edd38b6b81df8d274952aa85affa6968ae86b2231e1d429ce8bc9083e6a55bc', | ||
| 'cabal_sha256': 'd6696f2b55ab4a50b8de57947abca308604eb7cf8287c40bf69cfa26133e24d3', | ||
| 'flags': ['-bundled-c-zlib', '+non-blocking-ffi', '-pkg-config'], | ||
| }, | ||
| 'ed25519': { | ||
| 'version': '0.0.5.0', | ||
| 'revision': 9, | ||
| 'cabal_sha256': 'f1550ddbe3b53f1087a035667364011460896cc2b1ff328b521c05ed5973bb78', | ||
| }, | ||
| } | ||
| new_deps = [] | ||
| for dep in data.get('dependencies', []): | ||
| name = dep['package'] | ||
| if name in dep_updates: | ||
| new_dep = dict(dep) | ||
| for key, value in dep_updates[name].items(): | ||
| new_dep[key] = value | ||
| new_deps.append(new_dep) | ||
| else: | ||
| new_deps.append(dep) | ||
|
|
||
| data['dependencies'] = new_deps | ||
|
|
||
| # Write back to stdout | ||
| json.dump(data, sys.stdout, indent=2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| let { Attrs, BuildSpec, Local, Needs, OutputBin, OutputData, OutputLib, Source, Test, .. } = import "minimal.ncl" in | ||
| let base = import "../base/build.ncl" in | ||
| let bash = import "../bash/build.ncl" in | ||
| let binutils = import "../binutils/build.ncl" in | ||
| let toolchain = import "../toolchain/build.ncl" in | ||
| let perl = import "../perl/build.ncl" in | ||
| let python = import "../python/build.ncl" in | ||
| let gmp = import "../gmp/build.ncl" in | ||
| let libffi = import "../libffi/build.ncl" in | ||
| let linux_headers = import "../linux_headers/build.ncl" in | ||
| let xz = import "../xz/build.ncl" in | ||
| let tar = import "../tar/build.ncl" in | ||
| let autoconf = import "../autoconf/build.ncl" in | ||
| let automake = import "../automake/build.ncl" in | ||
| let m4 = import "../m4/build.ncl" in | ||
| let curl = import "../curl/build.ncl" in | ||
| let make = import "../make/build.ncl" in | ||
|
|
||
| let version = "9.10.3" in | ||
| { | ||
| name = "ghc", | ||
|
|
||
| build_deps = [ | ||
| { file = "build.sh" } | Local, | ||
| { | ||
| url = "https://downloads.haskell.org/~ghc/%{version}/ghc-%{version}-src.tar.xz", | ||
| sha256 = "d266864b9e0b7b741abe8c9d6a790d7c01c21cf43a1419839119255878ebc59a", | ||
| extract = false, | ||
| } | Source, | ||
| { | ||
| url = "https://downloads.haskell.org/~ghc/9.8.1/ghc-9.8.1-x86_64-deb11-linux.tar.xz", | ||
| sha256 = "ca4dde3a6f34f1fe6d0783767671f02e862f1b0222ef2dc2c5c68cc2abc1abae", | ||
| extract = false, | ||
| } | Source, | ||
| { | ||
| url = "https://downloads.haskell.org/~ghc/9.8.1/ghc-9.8.1-aarch64-deb10-linux.tar.xz", | ||
| sha256 = "aab7af72614f8bf9ca624407aa4dbc69bc009c2b4cc1a0f3c062008db81bdb95", | ||
| extract = false, | ||
| } | Source, | ||
| { | ||
| url = "https://downloads.haskell.org/~ghc/%{version}/hadrian-bootstrap-sources/hadrian-bootstrap-sources-9.8.1.tar.gz", | ||
| sha256 = "eec7233763bc31801fcbc996edc9c1f5abae707c1661deb8b22f0a7c2780b5e9", | ||
| extract = false, | ||
| } | Source, | ||
| { | ||
| url = "https://hackage.haskell.org/package/alex-3.5.1.0/alex-3.5.1.0.tar.gz", | ||
| sha256 = "c92efe86f8eb959ee03be6c04ee57ebc7e4abc75a6c4b26551215d7443e92a07", | ||
| extract = false, | ||
| } | Source, | ||
| { | ||
| url = "https://hackage.haskell.org/package/happy-1.20.1.1/happy-1.20.1.1.tar.gz", | ||
| sha256 = "8b4e7dc5a6c5fd666f8f7163232931ab28746d0d17da8fa1cbd68be9e878881b", | ||
| extract = false, | ||
| } | Source, | ||
| base, | ||
| bash, | ||
| perl, | ||
| python, | ||
| gmp, | ||
| xz, | ||
| tar, | ||
| curl, | ||
| make, | ||
| autoconf, | ||
| automake, | ||
| m4, | ||
| ], | ||
|
|
||
| runtime_deps = [ | ||
| base, | ||
| binutils, | ||
| gmp, | ||
| libffi, | ||
| linux_headers, | ||
| toolchain, | ||
| ], | ||
|
|
||
| needs = | ||
| { | ||
| dns = {}, | ||
| internet = {}, | ||
| } | Needs, | ||
|
|
||
| cmd = "./build.sh", | ||
|
|
||
| build_args = { | ||
| include version, | ||
| }, | ||
|
|
||
| outputs = { | ||
| bins = { glob = "usr/bin/*" } | OutputBin, | ||
|
|
||
| libghc = { glob = "usr/lib/ghc*/**", allow_executable = true } | OutputData, | ||
| libs = { glob = "usr/lib/**/*.so*" } | OutputLib, | ||
| }, | ||
|
|
||
| attrs = | ||
| { | ||
| upstream_version = version, | ||
| build_cost_multiple = 6, | ||
| } | Attrs, | ||
|
|
||
| tests = { | ||
| version_check = | ||
| { | ||
| class = 'Standalone, | ||
| test_deps = [], | ||
| cmds = [["ghc", "--version"]], | ||
| } | Test, | ||
| }, | ||
| } | BuildSpec |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.