Looks like there's a cheap way to shrink Haskell binaries. As advertised it does a pretty good job:
-rwxr-xr-x 1 _pbuild _pbuild 115M Jan 23 09:02 /usr/ports/pobj/pandoc-2.19.2/pandoc-2.19.2/dist-newstyle/build/x86_64-openbsd/ghc-9.2.5/pandoc-2.19.2/x/pandoc/build/pandoc/pandoc -rwxr-xr-x 1 root bin 135M Jan 13 17:09 /usr/local/bin/pandoc I didn't do much testing beyond checking the very basics, but wanted to share this soon in case somebody wants to play along. Yes, it does rely on us shipping lld on amd64 which is the only platform with lang/ghc. Thanks Greg >From fe79c6fa8b4a46072bcb6651ebfd3b4c58ddf4f0 Mon Sep 17 00:00:00 2001 From: Greg Steuck <[email protected]> Date: Mon, 23 Jan 2023 09:11:17 -0800 Subject: [PATCH] Shrink Haskell binaries size via link time deduplication http://brandon.si/code/linking-smaller-haskell-binaries/ --- devel/cabal/cabal.port.mk | 3 +++ 1 file changed, 3 insertions(+) diff --git a/devel/cabal/cabal.port.mk b/devel/cabal/cabal.port.mk index 8e0ed30d9e8..8ebd4f31db7 100644 --- a/devel/cabal/cabal.port.mk +++ b/devel/cabal/cabal.port.mk @@ -85,6 +85,9 @@ MODCABAL_post-extract += \ && echo "packages: ${WRKDIR}/${_package}-${_version}/${_package}.cabal" >> ${WRKSRC}/cabal.project.local .endfor # MODCABAL_MANIFEST +MODCABAL_post-extract += \ + && echo "\npackage *\n ghc-options: -split-sections\npackage ${MODCABAL_STEM}\n ld-options: -fuse-ld=lld -Wl,--gc-sections,--build-id" >> ${WRKSRC}/cabal.project.local + # Automatically copies the cabal.project file if any. MODCABAL_post-extract += \ && (test -f ${FILESDIR}/cabal.project \ -- 2.39.0
