Skip to content

Commit

Permalink
feat: update ghc cross tools to 9.2.5
Browse files Browse the repository at this point in the history
Signed-off-by: Aditya Alok <dev.aditya.alok@gmail.com>
  • Loading branch information
MrAdityaAlok committed Nov 15, 2022
1 parent 29c4f3b commit 018fe78
Showing 1 changed file with 31 additions and 17 deletions.
48 changes: 31 additions & 17 deletions scripts/ghc/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ TERMUX_PKG_HOMEPAGE=https://www.haskell.org/ghc/
TERMUX_PKG_DESCRIPTION="The Glasgow Haskell Cross Compilation system for Android"
TERMUX_PKG_LICENSE="BSD 2-Clause, BSD 3-Clause, LGPL-2.1"
TERMUX_PKG_MAINTAINER="MrAdityaAlok <dev.aditya.alok@gmail.com>"
TERMUX_PKG_VERSION=8.10.7
TERMUX_PKG_VERSION=9.2.5
TERMUX_PKG_SRCURL="http://downloads.haskell.org/~ghc/${TERMUX_PKG_VERSION}/ghc-${TERMUX_PKG_VERSION}-src.tar.xz"
TERMUX_PKG_SHA256=e3eef6229ce9908dfe1ea41436befb0455fefb1932559e860ad4c606b0d03c9d
TERMUX_PKG_SHA256=0606797d1b38e2d88ee2243f38ec6b9a1aa93e9b578e95f0de9a9c0a4144021c
TERMUX_PKG_BUILD_IN_SRC=true
TERMUX_PKG_BUILD_DEPENDS="iconv, libffi, libgmp, ncurses"
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
Expand All @@ -20,7 +20,6 @@ TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
--with-iconv-libraries=${TERMUX_PREFIX}/lib
--with-curses-libraries=${TERMUX_PREFIX}/lib
--with-curses-includes=${TERMUX_PREFIX}/include
--with-curses-libraries-stage0=/usr/lib
"

termux_step_pre_configure() {
Expand All @@ -36,22 +35,22 @@ termux_step_pre_configure() {

for tool in llc opt; do
local wrapper="${_WRAPPER_BIN}/${tool}"
cat >"$wrapper" <<-EOF
cat > "$wrapper" <<- EOF
#!$(command -v sh)
exec /usr/lib/llvm-12/bin/${tool} "\$@"
EOF
chmod 0700 "$wrapper"
done

local ar_wrapper="${_WRAPPER_BIN}/${_TERMUX_HOST_PLATFORM}-ar"
cat >"$ar_wrapper" <<-EOF
cat > "$ar_wrapper" <<- EOF
#!$(command -v sh)
exec $(command -v ${AR}) "\$@"
EOF
chmod 0700 "$ar_wrapper"

local strip_wrapper="${_WRAPPER_BIN}/${_TERMUX_HOST_PLATFORM}-strip"
cat >"$strip_wrapper" <<-EOF
cat > "$strip_wrapper" <<- EOF
#!$(command -v sh)
exec $(command -v ${STRIP}) "\$@"
EOF
Expand All @@ -64,10 +63,10 @@ termux_step_pre_configure() {
[ "${TERMUX_ARCH}" != "i686" ] && EXTRA_FLAGS+=" -fllvm"

# Suppress warnings for LLVM 13
sed -i 's/LlvmMaxVersion=13/LlvmMaxVersion=14/' configure.ac
sed -i 's/LlvmMaxVersion=13/LlvmMaxVersion=15/' configure.ac

cp mk/build.mk.sample mk/build.mk
cat >>mk/build.mk <<-EOF
cat >> mk/build.mk <<- EOF
SRC_HC_OPTS = -O -H64m
GhcStage2HcOpts = ${EXTRA_FLAGS}
GhcLibHcOpts = ${EXTRA_FLAGS}
Expand All @@ -87,22 +86,37 @@ termux_step_pre_configure() {
Stage1Only = YES
EOF

patch -Np1 <<-EOF
--- ghc-8.10.7/rules/build-package-data.mk 2021-06-21 12:24:36.000000000 +0530
+++ ghc-8.10.7-patch/rules/build-package-data.mk 2022-01-27 20:31:28.901997265 +0530
patch -p1 <<- EOF
--- ghc.orig/rules/build-package-data.mk 2022-11-07 01:10:29.000000000 +0530
+++ ghc.mod/rules/build-package-data.mk 2022-11-11 13:08:01.992488180 +0530
@@ -68,6 +68,12 @@
\$1_\$2_CONFIGURE_LDFLAGS = \$\$(SRC_LD_OPTS) \$\$(\$1_LD_OPTS) \$\$(\$1_\$2_LD_OPTS)
\$1_\$2_CONFIGURE_CPPFLAGS = \$\$(SRC_CPP_OPTS) \$\$(CONF_CPP_OPTS_STAGE\$3) \$\$(\$1_CPP_OPTS) \$\$(\$1_\$2_CPP_OPTS)
+ifneq "\$3" "0"
+ \$1_\$2_CONFIGURE_LDFLAGS += $LDFLAGS
+ \$1_\$2_CONFIGURE_CPPFLAGS += $CPPFLAGS
+ \$1_\$2_CONFIGURE_CFLAGS += $CFLAGS
+ \$1_\$2_CONFIGURE_LDFLAGS += ${LDFLAGS}
+ \$1_\$2_CONFIGURE_CPPFLAGS += ${CPPFLAGS}
+ \$1_\$2_CONFIGURE_CFLAGS += ${CFLAGS}
+endif
+
\$1_\$2_CONFIGURE_OPTS += --configure-option=CFLAGS="\$\$(\$1_\$2_CONFIGURE_CFLAGS)"
\$1_\$2_CONFIGURE_OPTS += --configure-option=LDFLAGS="\$\$(\$1_\$2_CONFIGURE_LDFLAGS)"
\$1_\$2_CONFIGURE_OPTS += --configure-option=CPPFLAGS="\$\$(\$1_\$2_CONFIGURE_CPPFLAGS)"
@@ -104,9 +110,12 @@
\$1_\$2_CONFIGURE_OPTS += --configure-option=--with-gmp
endif
-
ifneq "\$\$(CURSES_LIB_DIRS)" ""
-\$1_\$2_CONFIGURE_OPTS += --configure-option=--with-curses-libraries="\$\$(CURSES_LIB_DIRS)"
+ ifeq "\$3" "0"
+ \$1_\$2_CONFIGURE_OPTS += --configure-option=--with-curses-libraries="/usr/lib"
+ else
+ \$1_\$2_CONFIGURE_OPTS += --configure-option=--with-curses-libraries="\$\$(CURSES_LIB_DIRS)"
+ endif
endif
\$1_\$2_CONFIGURE_OPTS += --configure-option=--host=\$(TargetPlatformFull)
EOF

./boot
Expand All @@ -113,17 +127,17 @@ termux_step_make_install() {

# Generate a setup script for GHC to be used by Termux CI.
# This is not necessary but will help free up space on CI as well as decrease build time.
cat >"./simple_setup.hs" <<-EOF
cat > "./simple_setup.hs" <<- EOF
import Distribution.Simple
main = defaultMain
EOF

cat >"./configure_setup.hs" <<-EOF
cat > "./configure_setup.hs" <<- EOF
import Distribution.Simple
main = defaultMainWithHooks autoconfUserHooks
EOF

cat >"./make_setup.hs" <<-EOF
cat > "./make_setup.hs" <<- EOF
import Distribution.Make
main = defaultMain
EOF
Expand Down

0 comments on commit 018fe78

Please sign in to comment.