Skip to content

Commit

Permalink
pkg(ghc-cross): Enable iserv build
Browse files Browse the repository at this point in the history
Signed-off-by: Aditya Alok <[email protected]>
  • Loading branch information
MrAdityaAlok committed Mar 6, 2025
1 parent d452b71 commit ea8e51b
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 13 deletions.
8 changes: 4 additions & 4 deletions free-space.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/bin/sh

df -h
# df -h

sudo apt purge -yq $(dpkg -l | grep '^ii' | awk '{ print $2 }' | grep -P '(aspnetcore|cabal-|dotnet-|ghc-|libmono|mongodb-|mysql-|llvm-|liblldb-|php)') \
firefox google-chrome-stable microsoft-edge-stable mono-devel mono-runtime-common monodoc-manual ruby \
azure-cli powershell libgl1-mesa-dri shellcheck mercurial-common humanity-icon-theme google-cloud-cli

echo "Listing 100 largest packages after"
dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -n 100
# echo "Listing 100 largest packages after"
# dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -n 100

# Directories
sudo rm -fr /opt/ghc /opt/hostedtoolcache /usr/share/dotnet /usr/share/swift
Expand All @@ -28,4 +28,4 @@ sudo docker builder prune -a
sudo apt autoremove -yq
sudo apt clean

df -h
# df -h
30 changes: 21 additions & 9 deletions packages/ghc-cross/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,38 @@ termux_step_pre_configure() {

export target="$TERMUX_HOST_PLATFORM"

# NOTE: We do not build profiled libs. It exceeds the 6 hours limit of github CI.
export flavour="release+split_sections+late_ccs+no_profiled_libs"

if [ "$TERMUX_ARCH" = "arm" ]; then
target="armv7a-linux-androideabi"
fi
[[ "$TERMUX_ARCH" == "arm" ]] && target="armv7a-linux-androideabi"

TERMUX_PKG_EXTRA_CONFIGURE_ARGS="$TERMUX_PKG_EXTRA_CONFIGURE_ARGS --target=$target"

./boot.source
}

termux_step_make() {
(
unset CFLAGS CPPFLAGS LDFLAGS # For stage0 compilation.
./hadrian/build binary-dist-dir -j"$TERMUX_PKG_MAKE_PROCESSES" --flavour="$flavour" --docs=none \

./hadrian/build binary-dist-dir \
-j"$TERMUX_PKG_MAKE_PROCESSES" \
--flavour="perf" \
--docs=none \
"stage1.unix.ghc.link.opts += -optl-landroid-posix-semaphore"

echo "===> Starting iserv build"

# Patch to build iserv:
patch -p1 <"$TERMUX_PKG_BUILDER_DIR"/hadrian-enable-iserv.diff
patch -p1 <"$TERMUX_PKG_BUILDER_DIR"/hadrian-fix-program-rule.diff

./hadrian/build stage2:exe:iserv \
-j"$TERMUX_PKG_MAKE_PROCESSES" \
--flavour="perf" \
--docs=none
)
}

termux_step_make_install() {
cd _build/bindist/ghc-"$TERMUX_PKG_VERSION"-"$target" || exit 1
tar cJf "$TAR_OUTPUT_DIR"/ghc-"$TERMUX_PKG_VERSION"-"$target".tar.xz -C .. ghc-"$TERMUX_PKG_VERSION"-"$target"
tar cJf "$TAR_OUTPUT_DIR"/ghc-"$TERMUX_PKG_VERSION"-"$target".tar.xz -C _build/bindist ghc-"$TERMUX_PKG_VERSION"-"$target"
tar cJf "$TAR_OUTPUT_DIR"/iserv-"$TERMUX_PKG_VERSION"-"$target".tar.xz -C _build/stage1/bin "$target"-ghc-iserv
exit
}
18 changes: 18 additions & 0 deletions packages/ghc-cross/hadrian-enable-iserv.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# This Stage2 iserv will run under qemu emulated proot.

--- ghc-9.12.1/hadrian/src/Settings/Default.hs 2025-02-24 22:46:43.668323779 +0530
+++ ghc-9.12.1.mod/hadrian/src/Settings/Default.hs 2025-03-02 14:45:19.932865008 +0530
@@ -171,12 +173,12 @@
, transformers
, unlit
, xhtml
+ , iserv
, if winTarget then win32 else unix
]
, when (not cross)
[ haddock
, hpcBin
- , iserv
, runGhc
, ghcToolchainBin
]
17 changes: 17 additions & 0 deletions packages/ghc-cross/hadrian-fix-program-rule.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--- ghc-9.12.1/hadrian/src/Rules/Program.hs 2025-02-24 22:46:43.666788988 +0530
+++ ghc-9.12.1.mod/hadrian/src/Rules/Program.hs 2025-02-26 23:01:57.610058317 +0530
@@ -99,13 +99,7 @@
-- so we use pkgRegisteredLibraryFile instead.
registerPackages =<< contextDependencies ctx

- cross <- flag CrossCompiling
- -- For cross compiler, copy @stage0/bin/<pgm>@ to @stage1/bin/@.
- case (cross, stage) of
- (True, s) | s > stage0InTree -> do
- srcDir <- buildRoot <&> (-/- (stageString stage0InTree -/- "bin"))
- copyFile (srcDir -/- takeFileName bin) bin
- _ -> buildBinary rs bin ctx
+ buildBinary rs bin ctx

buildBinary :: [(Resource, Int)] -> FilePath -> Context -> Action ()
buildBinary rs bin context@Context {..} = do

0 comments on commit ea8e51b

Please sign in to comment.