Source: ghc Version: 7.10.3-7 Severity: normal Tags: patch Hi!
I recently bootstrapped ghc on x32. To achieve that, the following changes were necessary: * patch rts/Linker.c to use native 64-bit integer instructions on x32 * build the compiler unregisterised even though x86_64 has a NCG which needs some work to support x32 though * use integer-simple by default on x32 since integer-gmp currently has issues on x32 (sizeof(mp_limb_t) != sizeof(void *) is unsupported) The first patch is more discussed by upstream in detail in [1], since they were not sure yet whether the simple patch that I am using is safe not to break anything on other platforms. Attaching a debdiff with my changes in any case so that a discussion can be started. Cheers, Adrian > [1] https://ghc.haskell.org/trac/ghc/ticket/11571 -- .''`. John Paul Adrian Glaubitz : :' : Debian Developer - glaub...@debian.org `. `' Freie Universitaet Berlin - glaub...@physik.fu-berlin.de `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
diff -Nru old/ghc-7.10.3/debian/patches/series new/ghc-7.10.3/debian/patches/series --- old/ghc-7.10.3/debian/patches/series 2015-12-18 13:25:32.000000000 +0100 +++ new/ghc-7.10.3/debian/patches/series 2016-02-10 19:11:01.378870044 +0100 @@ -7,3 +7,4 @@ cabal-show-detail-direct.patch sh4-platform-detection-support.patch sparc64-initial-platform-support.patch +x32-use-native-x86_64-insn.patch diff -Nru old/ghc-7.10.3/debian/patches/x32-use-native-x86_64-insn.patch new/ghc-7.10.3/debian/patches/x32-use-native-x86_64-insn.patch --- old/ghc-7.10.3/debian/patches/x32-use-native-x86_64-insn.patch 1970-01-01 01:00:00.000000000 +0100 +++ new/ghc-7.10.3/debian/patches/x32-use-native-x86_64-insn.patch 2016-02-13 19:27:46.250266694 +0100 @@ -0,0 +1,25 @@ +Description: Use native x86_64 instructions on x32 + This patch enables a few native 64-bit integer instructions + on x32 which are available on this architecture despite using + 32-bit pointers. These instructions are present on x86_64 but + not on x86 and ghc checks the size of (void *) to determine + that. This method fails on x32 since despite using 32-bit + pointers and hence sizeof(void *) == 4, it still uses the + full x86_64 instruction set and software-emulated variants + of the aforementioned 64-bit integer instructions are + therefore not present in the toolchain which will make ghc + fail to build on x32. + See: https://ghc.haskell.org/trac/ghc/ticket/11571 + . + +--- ghc-7.10.3.orig/rts/Linker.c ++++ ghc-7.10.3/rts/Linker.c +@@ -1432,7 +1432,7 @@ typedef struct _RtsSymbolVal { + + + // 64-bit support functions in libgcc.a +-#if defined(__GNUC__) && SIZEOF_VOID_P <= 4 && !defined(_ABIN32) ++#if defined(__GNUC__) && SIZEOF_VOID_P <= 4 && !defined(_ABIN32) && !defined(__ILP32__) + #define RTS_LIBGCC_SYMBOLS \ + SymI_NeedsProto(__divdi3) \ + SymI_NeedsProto(__udivdi3) \ diff -Nru old/ghc-7.10.3/debian/rules new/ghc-7.10.3/debian/rules --- old/ghc-7.10.3/debian/rules 2016-01-05 11:09:35.000000000 +0100 +++ new/ghc-7.10.3/debian/rules 2016-02-13 19:33:46.001814498 +0100 @@ -43,6 +43,10 @@ BUILD_HADDOCK_DOCS=YES DEB_HOOGLE_TXT_DIR = /usr/lib/ghc-doc/hoogle/ +ifeq (x32,$(DEB_HOST_ARCH)) + EXTRA_CONFIGURE_FLAGS += --enable-unregisterised +endif + %: dh $@ --with autotools-dev @@ -64,6 +68,9 @@ echo "SRC_CC_OPTS += -fno-PIE" >> mk/build.mk echo "SRC_LD_OPTS += -no-pie" >> mk/build.mk endif +ifeq (x32,$(DEB_HOST_ARCH)) + echo "INTEGER_LIBRARY = integer-simple" >> mk/build.mk +endif ifneq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) # echo "GhcStage1HcOpts += -DDEBUG" >> mk/build.mk # echo "GhcStage2HcOpts += -DDEBUG" >> mk/build.mk