summaryrefslogtreecommitdiff
path: root/mk
diff options
context:
space:
mode:
authorpho <pho@pkgsrc.org>2022-02-23 16:03:00 +0000
committerpho <pho@pkgsrc.org>2022-02-23 16:03:00 +0000
commit9f80039c290a90b35a3af5630a933e49035c4cf3 (patch)
treec42ede66774cb24231466da7c7af8590e73ea2d9 /mk
parent53c89b69caba7fae5016306d63ceca8f4ee2f9f4 (diff)
downloadpkgsrc-9f80039c290a90b35a3af5630a933e49035c4cf3.tar.gz
mk/haskell.mk: Add a package-settable variable HASKELL_ENABLE_DYNAMIC_EXECUTABLE
Prior to this change, packages that install both libraries and executables were both linked dynamically when HASKELL_ENABLE_SHARED_LIBRARY is set to yes. This turned out to be problematic when the executables end up depending on hundreds of shared objects (which occurs rather frequently for tools written in Haskell): the dynamic linker spends several seconds upon loading the executables to resolve all the symbols. Now we can selectively opt out from dynamic linkage by setting HASKELL_ENABLE_DYNAMIC_EXECUTABLE to no. This should be done carefully, because linking executables with static Haskell libraries means that those executables will also use static RTS. This causes problems if they use GHC API to interpret Haskell code at run time: static RTS would violate PaX MPROTECT and suffer from ASLR while loading static objects.
Diffstat (limited to 'mk')
-rw-r--r--mk/haskell.mk21
1 files changed, 18 insertions, 3 deletions
diff --git a/mk/haskell.mk b/mk/haskell.mk
index e187cacedf2..4beb6f1eb65 100644
--- a/mk/haskell.mk
+++ b/mk/haskell.mk
@@ -1,4 +1,4 @@
-# $NetBSD: haskell.mk,v 1.41 2022/02/12 08:38:15 pho Exp $
+# $NetBSD: haskell.mk,v 1.42 2022/02/23 16:03:00 pho Exp $
#
# This Makefile fragment handles Haskell Cabal packages. Package
# configuration, building, installation, registration and unregistration
@@ -19,6 +19,13 @@
# Possible values: 0 1 2
# Default value: 2
#
+# HASKELL_ENABLE_DYNAMIC_EXECUTABLE
+# Whether executables in the package should be linked dynamically or
+# not.
+#
+# Possible values: yes, no
+# Default value: inherits ${HASKELL_ENABLE_SHARED_LIBRARY}
+#
# User-settable variables:
#
# HASKELL_ENABLE_SHARED_LIBRARY
@@ -62,6 +69,7 @@ _SYS_VARS.haskell= \
HOMEPAGE UNLIMIT_RESOURCES PREFIX
_DEF_VARS.haskell= \
BUILDLINK_PASSTHRU_DIRS \
+ HASKELL_ENABLE_DYNAMIC_EXECUTABLE \
HASKELL_OPTIMIZATION_LEVEL \
HASKELL_PKG_NAME \
USE_LANGUAGES \
@@ -110,6 +118,7 @@ TOOLS_FAIL+= pkg-config
UNLIMIT_RESOURCES+= datasize virtualsize
HASKELL_OPTIMIZATION_LEVEL?= 2
+HASKELL_ENABLE_DYNAMIC_EXECUTABLE?= ${HASKELL_ENABLE_SHARED_LIBRARY}
HASKELL_ENABLE_SHARED_LIBRARY?= yes
HASKELL_ENABLE_LIBRARY_PROFILING?= yes
HASKELL_ENABLE_HADDOCK_DOCUMENTATION?= yes
@@ -150,10 +159,16 @@ PKGSRC_OVERRIDE_MKPIE= yes
CONFIGURE_ARGS+= --ghc-option=-fPIC --ghc-option=-pie
.endif
+.if ${HASKELL_ENABLE_DYNAMIC_EXECUTABLE} == "yes"
+CONFIGURE_ARGS+= --enable-executable-dynamic
+.else
+CONFIGURE_ARGS+= --disable-executable-dynamic
+.endif
+
.if ${HASKELL_ENABLE_SHARED_LIBRARY} == "yes"
-CONFIGURE_ARGS+= --enable-shared --enable-executable-dynamic
+CONFIGURE_ARGS+= --enable-shared
.else
-CONFIGURE_ARGS+= --disable-shared --disable-executable-dynamic
+CONFIGURE_ARGS+= --disable-shared
.endif
.if ${HASKELL_ENABLE_LIBRARY_PROFILING} == "yes"