-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4e77c7e
commit 90f0567
Showing
18 changed files
with
358 additions
and
302 deletions.
There are no files selected for viewing
14 changes: 5 additions & 9 deletions
14
packages/ghc-libs/always-use-pic-on-android-for-dynexec.patch
This file contains 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 |
---|---|---|
@@ -1,15 +1,11 @@ | ||
--- ghc.orig/compiler/GHC/Driver/Session.hs 2022-11-07 01:10:29.000000000 +0530 | ||
+++ ghc.mod/compiler/GHC/Driver/Session.hs 2022-11-10 13:12:21.825682472 +0530 | ||
@@ -3763,6 +3763,12 @@ | ||
--- ghc-9.12.1/compiler/GHC/Driver/DynFlags.hs 2024-12-16 00:59:45.000000000 +0530 | ||
+++ ghc-9.12.1.mod/compiler/GHC/Driver/DynFlags.hs 2025-01-04 19:52:30.600705081 +0530 | ||
@@ -1311,6 +1311,8 @@ | ||
(OSDarwin, ArchAArch64) -> [Opt_PIC] | ||
(OSLinux, ArchAArch64) -> [Opt_PIC, Opt_ExternalDynamicRefs] | ||
(OSLinux, ArchARM {}) -> [Opt_PIC, Opt_ExternalDynamicRefs] | ||
+ (OSLinux, ArchX86) -> [Opt_PIC, Opt_ExternalDynamicRefs] | ||
+ (OSLinux, ArchX86_64) -> [Opt_PIC, Opt_ExternalDynamicRefs] | ||
+ (OSUnknown, ArchAArch64) -> [Opt_PIC, Opt_ExternalDynamicRefs] | ||
+ (OSUnknown, ArchARM {}) -> [Opt_PIC, Opt_ExternalDynamicRefs] | ||
+ (OSUnknown, ArchX86) -> [Opt_PIC, Opt_ExternalDynamicRefs] | ||
+ (OSUnknown, ArchX86_64) -> [Opt_PIC, Opt_ExternalDynamicRefs] | ||
+ (OSLinux, ArchX86) -> [Opt_PIC, Opt_ExternalDynamicRefs] | ||
(OSLinux, ArchRISCV64 {}) -> [Opt_PIC, Opt_ExternalDynamicRefs] | ||
(OSOpenBSD, ArchX86_64) -> [Opt_PIC] -- Due to PIE support in | ||
-- OpenBSD since 5.3 release | ||
-- (1 May 2013) we need to |
This file was deleted.
Oops, something went wrong.
This file contains 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 |
---|---|---|
@@ -1,132 +1,138 @@ | ||
TERMUX_PKG_HOMEPAGE=https://www.haskell.org/ghc/ | ||
TERMUX_PKG_DESCRIPTION="The Glasgow Haskell Compiler libraries" | ||
TERMUX_PKG_LICENSE="BSD 2-Clause, BSD 3-Clause, LGPL-2.1" | ||
TERMUX_PKG_MAINTAINER="Aditya Alok <alok@termux.org>" | ||
TERMUX_PKG_VERSION=9.2.5 | ||
TERMUX_PKG_REVISION=1 | ||
TERMUX_PKG_SRCURL="https://downloads.haskell.org/~ghc/${TERMUX_PKG_VERSION}/ghc-${TERMUX_PKG_VERSION}-src.tar.xz" | ||
TERMUX_PKG_SHA256=0606797d1b38e2d88ee2243f38ec6b9a1aa93e9b578e95f0de9a9c0a4144021c | ||
TERMUX_PKG_DEPENDS="libiconv, libffi, ncurses, libgmp, libandroid-posix-semaphore" | ||
TERMUX_PKG_LICENSE="custom" | ||
TERMUX_PKG_MAINTAINER="Aditya Alok <alok@termux.dev>" | ||
TERMUX_PKG_VERSION=9.12.1 | ||
TERMUX_PKG_SRCURL="https://downloads.haskell.org/~ghc/$TERMUX_PKG_VERSION/ghc-$TERMUX_PKG_VERSION-src.tar.xz" | ||
TERMUX_PKG_SHA256=4a7410bdeec70f75717087b8f94bf5a6598fd61b3a0e1f8501d8f10be1492754 | ||
TERMUX_PKG_DEPENDS="libiconv, libffi, libgmp, libandroid-posix-semaphore" | ||
TERMUX_PKG_BUILD_DEPENDS="dnsutils" | ||
TERMUX_PKG_BUILD_IN_SRC=true | ||
TERMUX_PKG_EXTRA_CONFIGURE_ARGS=" | ||
--disable-ld-override | ||
--build=x86_64-unknown-linux | ||
--host=x86_64-unknown-linux | ||
--with-system-libffi | ||
--with-ffi-includes=${TERMUX_PREFIX}/include | ||
--with-ffi-libraries=${TERMUX_PREFIX}/lib | ||
--with-gmp-includes=${TERMUX_PREFIX}/include | ||
--with-gmp-libraries=${TERMUX_PREFIX}/lib | ||
--with-iconv-includes=${TERMUX_PREFIX}/include | ||
--with-iconv-libraries=${TERMUX_PREFIX}/lib | ||
--with-curses-libraries=${TERMUX_PREFIX}/lib | ||
--with-curses-includes=${TERMUX_PREFIX}/include | ||
" | ||
--host=$TERMUX_BUILD_TUPLE | ||
--with-system-libffi" | ||
TERMUX_PKG_NO_STATICSPLIT=true | ||
TERMUX_PKG_REPLACES="ghc-libs-static" | ||
|
||
# 'network' is used by 'libiserv'. This will enable over the network support in 'iserv-proxy' which is | ||
# used to cross-compile haskell-template. | ||
termux_step_post_get_source() { | ||
mkdir -p "$TERMUX_PKG_SRCDIR"/libraries/network | ||
local tar_file="$TERMUX_PKG_CACHEDIR/network.tar" | ||
termux_download \ | ||
https://hackage.haskell.org/package/network-2.8.0.1/network-2.8.0.1.tar.gz \ | ||
"$tar_file" \ | ||
61f55dbfed0f0af721a8ea36079e9309fcc5a1be20783b44ae500d9e4399a846 | ||
tar xf "$tar_file" -C "$TERMUX_PKG_SRCDIR"/libraries/network --strip-components=1 | ||
# Alllow newer versions of 'bytestring': | ||
sed -ri 's|(bytestring) == .*|\1|' "$TERMUX_PKG_SRCDIR"/libraries/network/network.cabal | ||
# XXX: Please verify above command works when updating. | ||
termux_setup_ghc && termux_setup_cabal | ||
cabal update | ||
} | ||
|
||
termux_step_pre_configure() { | ||
termux_setup_ghc | ||
|
||
local host_platform="${TERMUX_HOST_PLATFORM}" | ||
[ "${TERMUX_ARCH}" = "arm" ] && host_platform="armv7a-linux-androideabi" | ||
TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" --target=${host_platform}" | ||
|
||
local extra_flags="-O -optl-Wl,-rpath=${TERMUX_PREFIX}/lib -optl-Wl,--enable-new-dtags" | ||
[ "${TERMUX_ARCH}" != "i686" ] && extra_flags+=" -fllvm" | ||
|
||
# Suppress warnings for LLVM 13 | ||
sed -i 's/LlvmMaxVersion=13/LlvmMaxVersion=15/' configure.ac | ||
|
||
export LIBTOOL && LIBTOOL="$(command -v libtool)" | ||
|
||
cp mk/build.mk.sample mk/build.mk | ||
cat >>mk/build.mk <<-EOF | ||
SRC_HC_OPTS = -O -H64m | ||
GhcStage1HcOpts = -O | ||
GhcStage2HcOpts = ${extra_flags} | ||
GhcLibHcOpts = ${extra_flags} -optl-landroid-posix-semaphore | ||
BuildFlavour = quick-cross | ||
GhcLibWays = v dyn | ||
BUILD_PROF_LIBS = NO | ||
HADDOCK_DOCS = NO | ||
BUILD_SPHINX_HTML = NO | ||
BUILD_SPHINX_PDF = NO | ||
BUILD_MAN = NO | ||
WITH_TERMINFO = YES | ||
DYNAMIC_GHC_PROGRAMS = YES | ||
SplitSections = YES | ||
StripLibraries = YES | ||
libraries/libiserv_CONFIGURE_OPTS += --flags=+network | ||
EOF | ||
|
||
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} | ||
+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 | ||
export CONF_CC_OPTS_STAGE1="$CFLAGS $CPPFLAGS" CONF_GCC_LINKER_OPTS_STAGE1="$LDFLAGS" | ||
export CONF_CC_OPTS_STAGE2="$CFLAGS $CPPFLAGS" CONF_GCC_LINKER_OPTS_STAGE2="$LDFLAGS" | ||
# export CONF_GCC_SUPPORTS_NO_PIE=NO # Linker says it does, but Android > 5.0 cannot run them. | ||
|
||
export target="$TERMUX_HOST_PLATFORM" | ||
if [ "$TERMUX_ARCH" = "arm" ]; then | ||
target="armv7a-linux-androideabi" | ||
fi | ||
TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" --target=$target" | ||
|
||
./boot.source | ||
} | ||
|
||
termux_step_make_install() { | ||
make install-strip INSTALL="$(command -v install) --strip-program=${STRIP}" | ||
termux_step_make() { | ||
termux_setup_ghc && termux_setup_cabal | ||
( | ||
# XXX: Temporary | ||
|
||
unset CFLAGS CPPFLAGS LDFLAGS # For stage0 compilation. | ||
|
||
./hadrian/build binary-dist-dir -j --flavour=quickest+no_profiled_libs --docs=none \ | ||
"stage1.*.ghc.*.opts += -optl-landroid-posix-semaphore" \ | ||
"stage2.*.ghc.*.opts += -optl-landroid-posix-semaphore" | ||
) | ||
} | ||
|
||
termux_step_post_make_install() { | ||
# We may build GHC with `llc-9` etc., but only `llc` is present in Termux | ||
sed -i 's/"LLVM llc command", "llc.*"/"LLVM llc command", "llc"/' \ | ||
"${TERMUX_PREFIX}/lib/ghc-${TERMUX_PKG_VERSION}/settings" | ||
sed -i 's/"LLVM opt command", "opt.*"/"LLVM opt command", "opt"/' \ | ||
"${TERMUX_PREFIX}/lib/ghc-${TERMUX_PKG_VERSION}/settings" | ||
__setup_proot_and_qemu() { | ||
mkdir -p "$TERMUX_PKG_CACHEDIR"/bin | ||
|
||
termux_download https://github.com/proot-me/proot/releases/download/v5.3.0/proot-v5.3.0-x86_64-static \ | ||
"$TERMUX_PKG_CACHEDIR/bin"/proot \ | ||
d1eb20cb201e6df08d707023efb000623ff7c10d6574839d7bb42d0adba6b4da | ||
|
||
if [[ "$TERMUX_ARCH" == "aarch64" ]]; then | ||
termux_download https://github.com/multiarch/qemu-user-static/releases/download/v7.2.0-1/qemu-aarch64-static \ | ||
"$TERMUX_PKG_CACHEDIR/bin"/qemu-static \ | ||
dce64b2dc6b005485c7aa735a7ea39cb0006bf7e5badc28b324b2cd0c73d883f | ||
elif [[ "$TERMUX_ARCH" == "arm" ]]; then | ||
termux_download https://github.com/multiarch/qemu-user-static/releases/download/v7.2.0-1/qemu-arm-static \ | ||
"$TERMUX_PKG_CACHEDIR/bin"/qemu-static \ | ||
9f07762a3cd0f8a199cb5471a92402a4765f8e2fcb7fe91a87ee75da9616a806 | ||
fi | ||
|
||
sed -i 's|"/usr/bin/libtool"|"libtool"|' \ | ||
"${TERMUX_PREFIX}/lib/ghc-${TERMUX_PKG_VERSION}/settings" | ||
chmod +x "$TERMUX_PKG_CACHEDIR"/bin/{proot,qemu-static} | ||
} | ||
|
||
__setup_termux_rootfs() { | ||
termux_download https://raw.githubusercontent.com/NotGlop/docker-drag/5413165a2453aa0bc275d7dc14aeb64e814d5cc0/docker_pull.py \ | ||
"$TERMUX_PKG_CACHEDIR"/docker_pull.py \ | ||
04e52b70c862884e75874b2fd229083fdf09a4bac35fc16fd7a0874ba20bd075 | ||
termux_download https://raw.githubusercontent.com/larsks/undocker/649f3fdeb0a9cf8aa794d90d6cc6a7c7698a25e6/undocker.py \ | ||
"$TERMUX_PKG_CACHEDIR"/undocker.py \ | ||
32bc122c53153abeb27491e6d45122eb8cef4f047522835bedf9b4b87877a907 | ||
|
||
( | ||
cd "$TERMUX_PKG_CACHEDIR" | ||
|
||
if [[ ! -f termux_"$TERMUX_ARCH"_termux-docker.tar ]]; then | ||
python docker_pull.py termux/termux-docker:"$TERMUX_ARCH" | ||
mv termux_termux-docker.tar termux_"$TERMUX_ARCH"_termux-docker.tar | ||
fi | ||
python undocker.py -o "$TERMUX_ROOTFS" <termux_"$TERMUX_ARCH"_termux-docker.tar | ||
# mv -f "$TERMUX_ROOTFS$TERMUX_PREFIX" "$TERMUX_ROOTFS$TERMUX_PREFIX.guest-prefix" &>/dev/null || : | ||
) | ||
|
||
cp "$TERMUX_PKG_BUILDER_DIR"/static-dns-hosts.txt "$TERMUX_ROOTFS"/system/etc/ | ||
cp "$TERMUX_PKG_BUILDER_DIR"/update-static-dns "$TERMUX_ROOTFS"/ | ||
chmod +x "$TERMUX_ROOTFS"/update-static-dns | ||
} | ||
|
||
termux_step_make_install() { | ||
export TERMUX_ROOTFS="$TERMUX_PKG_TMPDIR/$TERMUX_ARCH-termux-rootfs" | ||
|
||
__setup_proot_and_qemu | ||
__setup_termux_rootfs | ||
|
||
local proot_qemu="" | ||
if [[ "$TERMUX_ARCH" == "aarch64" ]] || [[ "$TERMUX_ARCH" == "arm" ]]; then | ||
proot_qemu="-q $TERMUX_PKG_CACHEDIR/bin/qemu-static" | ||
fi | ||
|
||
# $__proot_cmd bash | ||
# XXX: Temporary | ||
export target="$TERMUX_HOST_PLATFORM" | ||
if [ "$TERMUX_ARCH" = "arm" ]; then | ||
target="armv7a-linux-androideabi" | ||
fi | ||
|
||
__proot_cmd="env -i | ||
PATH=$TERMUX_PREFIX/bin:/host-termux-prefix/bin | ||
LD_LIBRARY_PATH=/host-termux-prefix/lib | ||
$TERMUX_PKG_CACHEDIR/bin/proot | ||
-b $TERMUX_PKG_SRCDIR/_build/bindist:/ghc-bindist | ||
-b $TERMUX_PREFIX:/host-termux-prefix | ||
$proot_qemu -R $TERMUX_ROOTFS -w /ghc-bindist/ghc-$TERMUX_PKG_VERSION-$target" | ||
|
||
$__proot_cmd /update-static-dns | ||
$__proot_cmd apt update | ||
$__proot_cmd apt upgrade -yq -o Dpkg::Options::=--force-confnew | ||
$__proot_cmd pkg i clang ndk-multilib binutils-is-llvm make -y | ||
$__proot_cmd env CC="clang" CXX="clang++" LD="ld.lld" AR="llvm-ar" NM="llvm-nm" STRIP="llvm-strip" ./configure --prefix=/host-termux-prefix --build="$target" | ||
$__proot_cmd make install | ||
|
||
sed -i "s|/host-termux-prefix|$TERMUX_PREFIX|g" "$TERMUX_PREFIX"/bin/"$target"-{ghc,ghc-pkg,hsc2hs-ghc,hp2ps-ghc,ghci}-"$TERMUX_PKG_VERSION" | ||
|
||
# We may build GHC with `llc-9` etc., but only `llc` is present in Termux | ||
# sed -i 's/"LLVM llc command", "llc.*"/"LLVM llc command", "llc"/' \ | ||
# "$TERMUX_PREFIX/lib/$target-ghc-$TERMUX_PKG_VERSION/lib/settings" || : | ||
# sed -i 's/"LLVM opt command", "opt.*"/"LLVM opt command", "opt"/' \ | ||
# "$TERMUX_PREFIX/lib/$target-ghc-$TERMUX_PKG_VERSION/lib/settings" || : | ||
} | ||
|
||
termux_step_install_license() { | ||
install -Dm600 -t "${TERMUX_PREFIX}/share/doc/${TERMUX_PKG_NAME}" \ | ||
"${TERMUX_PKG_SRCDIR}/LICENSE" | ||
install -Dm600 -t "$TERMUX_PREFIX/share/doc/$TERMUX_PKG_NAME" \ | ||
"$TERMUX_PKG_SRCDIR/LICENSE" | ||
} |
This file contains 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,11 @@ | ||
--- ghc-9.12.1/libraries/Cabal/Cabal/src/Distribution/Simple/InstallDirs.hs 2024-12-16 01:00:10.000000000 +0530 | ||
+++ ghc-9.12.1.mod/libraries/Cabal/Cabal/src/Distribution/Simple/InstallDirs.hs 2025-01-04 20:05:06.846734461 +0530 | ||
@@ -205,7 +205,7 @@ | ||
windowsProgramFilesDir <- getWindowsProgramFilesDir | ||
return (windowsProgramFilesDir </> "Haskell") | ||
Haiku -> return "/boot/system/non-packaged" | ||
- _ -> return "/usr/local" | ||
+ _ -> return "@TERMUX_PREFIX@" | ||
installLibDir <- | ||
case buildOS of | ||
Windows -> return "$prefix" |
This file was deleted.
Oops, something went wrong.
This file contains 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 @@ | ||
# Linker says it supports `-no-pie`, but Android > 5.0 cannot run them. | ||
--- ghc-9.12.1/m4/fp_gcc_supports_no_pie.m4 2024-12-16 00:59:46.000000000 +0530 | ||
+++ ghc-9.12.1.mod/m4/fp_gcc_supports_no_pie.m4 2025-01-19 19:33:34.411548356 +0530 | ||
@@ -6,15 +6,5 @@ | ||
[ | ||
AC_REQUIRE([AC_PROG_CC]) | ||
AC_MSG_CHECKING([whether CC supports -no-pie]) | ||
- echo 'int main() { return 0; }' > conftest.c | ||
- "$CC" $CONF_GCC_CC_OPTS_STAGE2 -c conftest.c | ||
- # Some GCC versions only warn when passed an unrecognized flag. | ||
- if "$CC" $CONF_GCC_LINKER_OPTS_STAGE2 -no-pie -Werror conftest.o -o conftest > conftest.txt 2>&1 && ! grep -i unrecognized conftest.txt > /dev/null 2>&1; then | ||
- CONF_GCC_SUPPORTS_NO_PIE=YES | ||
- AC_MSG_RESULT([yes]) | ||
- else | ||
CONF_GCC_SUPPORTS_NO_PIE=NO | ||
- AC_MSG_RESULT([no]) | ||
- fi | ||
- rm -f conftest.c conftest.o conftest | ||
]) |
This file contains 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,14 @@ | ||
--- ghc-9.12.1/rts/linker/ElfTypes.h 2024-12-16 00:59:46.000000000 +0530 | ||
+++ ghc-9.12.1.mod/rts/linker/ElfTypes.h 2025-01-04 21:31:55.550538431 +0530 | ||
@@ -8,6 +8,11 @@ | ||
#include <elf.h> | ||
#include "linker/InitFini.h" | ||
|
||
+#define ELF32_ST_VISIBILITY(o) ((o) & 0x03) | ||
+ | ||
+/* For ELF64 the definitions are the same. */ | ||
+#define ELF64_ST_VISIBILITY(o) ELF32_ST_VISIBILITY(o) | ||
+ | ||
/* | ||
* Define a set of types which can be used for both ELF32 and ELF64 | ||
*/ |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.