pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/mk mk/haskell.mk: Add a package-settable variable HASK...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/950bbfe064cb
branches:  trunk
changeset: 374483:950bbfe064cb
user:      pho <pho%pkgsrc.org@localhost>
date:      Wed Feb 23 16:03:00 2022 +0000

description:
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:

 mk/haskell.mk |  21 ++++++++++++++++++---
 1 files changed, 18 insertions(+), 3 deletions(-)

diffs (58 lines):

diff -r d048dd8ec027 -r 950bbfe064cb mk/haskell.mk
--- a/mk/haskell.mk     Wed Feb 23 16:01:20 2022 +0000
+++ b/mk/haskell.mk     Wed Feb 23 16:03:00 2022 +0000
@@ -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 @@
        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 @@
 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 @@
 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"



Home | Main Index | Thread Index | Old Index