-
Notifications
You must be signed in to change notification settings - Fork 6
Simplify GHC packaging by extracting bootstrap and build tools #203
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
4 commits
Select commit
Hold shift + click to select a range
eee84bf
Simplify GHC packaging by extracting bootstrap and build tools
0chroma 5588966
Implement PR feedback: dynamic setup files, dynamic ncurses location,…
0chroma e16b694
enumerate single binaries in happy and alex outputs
0chroma 4ae6435
fix(ghc-bootstrap): prevent ldconfig pipeline failure under pipefail
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,42 @@ | ||
| let { BuildSpec, Local, OutputBin, Source, .. } = import "minimal.ncl" in | ||
| let base = import "../base/build.ncl" in | ||
| let bash = import "../bash/build.ncl" in | ||
| let ghc-bootstrap = import "../ghc-bootstrap/build.ncl" in | ||
| let gmp = import "../gmp/build.ncl" in | ||
| let toolchain = import "../toolchain/build.ncl" in | ||
|
|
||
| let version = "3.5.1.0" in | ||
| { | ||
| name = "alex", | ||
|
|
||
| build_deps = [ | ||
| { file = "build.sh" } | Local, | ||
| { | ||
| url = "https://hackage.haskell.org/package/alex-%{version}/alex-%{version}.tar.gz", | ||
| sha256 = "c92efe86f8eb959ee03be6c04ee57ebc7e4abc75a6c4b26551215d7443e92a07", | ||
| extract = true, | ||
| } | Source, | ||
| base, | ||
| bash, | ||
| ghc-bootstrap, | ||
| toolchain, | ||
| ], | ||
|
|
||
| runtime_deps = [ | ||
| base, | ||
| gmp, | ||
| ], | ||
|
|
||
| cmd = "./build.sh", | ||
| build_args = { | ||
| include version, | ||
| }, | ||
|
|
||
| outputs = { | ||
| alex = { glob = "usr/bin/alex" } | OutputBin, | ||
| }, | ||
|
|
||
| attrs = { | ||
| upstream_version = version, | ||
| }, | ||
| } | 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,19 @@ | ||
| #!/bin/bash | ||
| set -euo pipefail | ||
|
|
||
| cd "alex-$MINIMAL_ARG_VERSION" | ||
|
|
||
| # Determine setup file | ||
| SETUP_FILE="Setup.hs" | ||
| if [ -f Setup.lhs ]; then | ||
| SETUP_FILE="Setup.lhs" | ||
| elif [ ! -f Setup.hs ]; then | ||
| echo "import Distribution.Simple" > Setup.hs | ||
| echo "main = defaultMain" >> Setup.hs | ||
| SETUP_FILE="Setup.hs" | ||
| fi | ||
|
|
||
| ghc --make "$SETUP_FILE" | ||
| ./Setup configure --prefix=/usr | ||
| ./Setup build | ||
| ./Setup copy --destdir="$OUTPUT_DIR" | ||
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,64 @@ | ||
| let { BuildSpec, Local, OutputBin, OutputData, OutputLib, Source, .. } = import "minimal.ncl" in | ||
| let { target, .. } = import "config.ncl" in | ||
| let base = import "../base/build.ncl" in | ||
| let bash = import "../bash/build.ncl" in | ||
| let gmp = import "../gmp/build.ncl" in | ||
| let make = import "../make/build.ncl" in | ||
| let ncurses = import "../ncurses/build.ncl" in | ||
| let perl = import "../perl/build.ncl" in | ||
| let tar = import "../tar/build.ncl" in | ||
| let toolchain = import "../toolchain/build.ncl" in | ||
| let xz = import "../xz/build.ncl" in | ||
|
|
||
| let version = "9.8.1" in | ||
| { | ||
| name = "ghc-bootstrap", | ||
|
|
||
| build_deps = [ | ||
| { file = "build.sh" } | Local, | ||
| match { | ||
| { arch = 'Amd64, .. } => | ||
| { | ||
| url = "https://downloads.haskell.org/~ghc/%{version}/ghc-%{version}-x86_64-deb11-linux.tar.xz", | ||
| sha256 = "ca4dde3a6f34f1fe6d0783767671f02e862f1b0222ef2dc2c5c68cc2abc1abae", | ||
| extract = false, | ||
| } | Source, | ||
| { arch = 'Arm64, .. } => | ||
| { | ||
| url = "https://downloads.haskell.org/~ghc/%{version}/ghc-%{version}-aarch64-deb10-linux.tar.xz", | ||
| sha256 = "aab7af72614f8bf9ca624407aa4dbc69bc009c2b4cc1a0f3c062008db81bdb95", | ||
| extract = false, | ||
| } | Source, | ||
| } target, | ||
| base, | ||
| bash, | ||
| gmp, | ||
| make, | ||
| ncurses, | ||
| perl, | ||
| tar, | ||
| toolchain, | ||
| xz, | ||
| ], | ||
|
|
||
| runtime_deps = [ | ||
| base, | ||
| gmp, | ||
| ncurses, | ||
| ], | ||
|
|
||
| cmd = "./build.sh", | ||
| build_args = { | ||
| include version, | ||
| }, | ||
|
|
||
| outputs = { | ||
| bins = { glob = "usr/bin/*" } | OutputBin, | ||
| libs = { glob = "usr/lib/ghc-%{version}/**", allow_executable = true } | OutputData, | ||
| libtinfo = { glob = "usr/lib/*.so*" } | OutputLib, | ||
| }, | ||
|
|
||
| attrs = { | ||
| upstream_version = version, | ||
| }, | ||
| } | 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,90 @@ | ||
| #!/bin/bash | ||
| set -euo pipefail | ||
|
|
||
| BOOTSTRAP_ARCH="$(uname -m)" | ||
| case "$BOOTSTRAP_ARCH" in | ||
| x86_64) | ||
| BOOTSTRAP_TAR="ghc-${MINIMAL_ARG_VERSION}-x86_64-deb11-linux.tar.xz" | ||
| ;; | ||
| aarch64) | ||
| BOOTSTRAP_TAR="ghc-${MINIMAL_ARG_VERSION}-aarch64-deb10-linux.tar.xz" | ||
| ;; | ||
| *) | ||
| echo "Unsupported architecture: $BOOTSTRAP_ARCH" | ||
| exit 1 | ||
| ;; | ||
| esac | ||
|
|
||
| # Extract prebuilt GHC | ||
| mkdir -p bootstrap-src | ||
| tar -xof "$BOOTSTRAP_TAR" -C bootstrap-src --strip-components=1 | ||
|
|
||
| # Configure and install GHC to $OUTPUT_DIR/usr | ||
| cd bootstrap-src | ||
| ./configure --prefix=/usr | ||
| make install_bin install_lib update_package_db DESTDIR="$OUTPUT_DIR" | ||
|
|
||
| # Find the real ncurses library dynamically | ||
| NCURSES_PATH="" | ||
| for path in \ | ||
| /usr/lib/libncursesw.so.6 \ | ||
| /usr/lib/libncurses.so.6 \ | ||
| /usr/lib64/libncursesw.so.6 \ | ||
| /usr/lib64/libncurses.so.6 \ | ||
| /lib/*/libncursesw.so.6 \ | ||
| /lib/*/libncurses.so.6 \ | ||
| /usr/lib/*/libncursesw.so.6 \ | ||
| /usr/lib/*/libncurses.so.6 \ | ||
| /lib/libncursesw.so.6 \ | ||
| /lib/libncurses.so.6; do | ||
| if [ -f "$path" ]; then | ||
| NCURSES_PATH="$path" | ||
| break | ||
| fi | ||
| done | ||
|
|
||
| if [ -z "$NCURSES_PATH" ]; then | ||
| if command -v gcc >/dev/null 2>&1; then | ||
| for libname in libncursesw.so.6 libncurses.so.6; do | ||
| GCC_FOUND_PATH="$(gcc -print-file-name=$libname)" | ||
| if [ -f "$GCC_FOUND_PATH" ]; then | ||
| NCURSES_PATH="$GCC_FOUND_PATH" | ||
| break | ||
| fi | ||
| done | ||
| fi | ||
| fi | ||
|
|
||
| if [ -z "$NCURSES_PATH" ]; then | ||
| if command -v ldconfig >/dev/null 2>&1; then | ||
| for libname in libncursesw.so.6 libncurses.so.6; do | ||
| LDCONFIG_PATH="$(ldconfig -p | awk -v lib="$libname" '$0 ~ lib {print $NF; exit}')" | ||
| if [ -f "$LDCONFIG_PATH" ]; then | ||
| NCURSES_PATH="$LDCONFIG_PATH" | ||
| break | ||
| fi | ||
| done | ||
| fi | ||
| fi | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| if [ -z "$NCURSES_PATH" ]; then | ||
| echo "Error: Could not locate libncursesw.so.6 or libncurses.so.6" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| # We also need a libtinfo.so.6, which GHC expects. | ||
| mkdir -p "$OUTPUT_DIR/usr/lib" | ||
| cp -p "$NCURSES_PATH" "$OUTPUT_DIR/usr/lib/libtinfo.so.6" | ||
|
|
||
| # Let's also copy it in the GHC lib directory: | ||
| GHC_LIB_DIR="$OUTPUT_DIR/usr/lib/ghc-${MINIMAL_ARG_VERSION}/lib" | ||
| if [ -d "$GHC_LIB_DIR" ]; then | ||
| cp -p "$NCURSES_PATH" "$GHC_LIB_DIR/libtinfo.so.6" | ||
| fi | ||
|
|
||
| # Modify bootstrap settings to use standard ld instead of ld.gold | ||
| SETTINGS_FILE="$OUTPUT_DIR/usr/lib/ghc-${MINIMAL_ARG_VERSION}/lib/settings" | ||
| if [ -f "$SETTINGS_FILE" ]; then | ||
| sed -i 's/-fuse-ld=gold//g' "$SETTINGS_FILE" | ||
| sed -i 's|/usr/bin/ld.gold|/usr/bin/ld|g' "$SETTINGS_FILE" | ||
| fi | ||
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
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.