Package: ghc
Version: 7.10.3-2
Severity: normal
Tags: patch
User: [email protected]
Usertags: origin-ubuntu ubuntu-patch xenial

The newly-bootstrapped Ubuntu s390x architecture has its toolchain
configured to use PIE by default (I presume by customer request, though
I don't know the details).  Binaries built by GHC segfault immediately
if PIE is in use.  I think it would make sense to just disable PIE on
s390x; it's not enabled by default on Debian s390x, but -fno-PIE/-no-pie
should be harmless.

Disabling this both during the GHC build itself and for things that the
resulting /usr/bin/ghc compiles requires a couple of different pieces.
Here's a tested patch (which could be refactored later if more
architectures have this problem in future):

diff --git a/p/ghc/debian/rules b/p/ghc/debian/rules
index b285537..ca8d8f3 100755
--- a/p/ghc/debian/rules
+++ b/p/ghc/debian/rules
@@ -34,6 +34,12 @@ ProjectVersion=$(shell cat VERSION)
 
 GHC=$(firstword $(shell bash -c "type -p ghc"))
 EXTRA_CONFIGURE_FLAGS=--with-ghc="$(GHC)"
+ifeq (s390x,$(DEB_HOST_ARCH))
+  EXTRA_CONFIGURE_FLAGS += \
+       CONF_CC_OPTS_STAGE2=-fno-PIE \
+       CONF_GCC_LINKER_OPTS_STAGE2=-no-pie \
+       CONF_LD_LINKER_OPTS_STAGE2=-no-pie
+endif
 BUILD_HADDOCK_DOCS=YES
 DEB_HOOGLE_TXT_DIR = /usr/lib/ghc-doc/hoogle/
 
@@ -51,6 +57,10 @@ endif
 ifeq (armhf,$(DEB_HOST_ARCH))
        echo "SRC_HC_OPTS += -D__ARM_PCS_VFP" >> mk/build.mk
 endif
+ifeq (s390x,$(DEB_HOST_ARCH))
+       echo "SRC_CC_OPTS += -fno-PIE" >> mk/build.mk
+       echo "SRC_LD_OPTS += -no-pie" >> mk/build.mk
+endif
 ifneq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
 #      echo "GhcStage1HcOpts += -DDEBUG" >> mk/build.mk
 #      echo "GhcStage2HcOpts += -DDEBUG" >> mk/build.mk

Thanks,

-- 
Colin Watson                                       [[email protected]]

Reply via email to