[packages/ghc] - started playing with 8.8.2 but 8.8 cannot bootstrap itself (bugfixes are comming in 8.10)

arekm arekm at pld-linux.org
Mon Jan 20 19:56:31 CET 2020


commit b5cb5a553e9a42bfb885efae79de559939ad74ed
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Mon Jan 20 19:56:12 2020 +0100

    - started playing with 8.8.2 but 8.8 cannot bootstrap itself (bugfixes are comming in 8.10)

 build.patch                      |  11 ++++
 buildpath-abi-stability.patch    |  25 ++++++++
 ghc-pld.patch                    |  24 ++------
 ghc.spec                         | 126 +++++++++++++++++++++++++--------------
 x32-use-native-x86_64-insn.patch |  27 +++++++++
 5 files changed, 149 insertions(+), 64 deletions(-)
---
diff --git a/ghc.spec b/ghc.spec
index 8e68cba..708840e 100644
--- a/ghc.spec
+++ b/ghc.spec
@@ -5,10 +5,6 @@
 #
 # - http://hackage.haskell.org/trac/ghc/wiki/Building/Porting
 #
-# TODO:
-#	- teach ghc toolchain to always use ld.bfd,
-#	  or fix ld.gold to be usable for anything else than c/c++
-#
 # Conditional build:
 %bcond_with	bootstrap	# use foreign (non-rpm) ghc to bootstrap (extra 140MB to download)
 %bcond_with	unregistered	# non-registerised interpreter (use for build problems/new arches)
@@ -42,36 +38,47 @@
 Summary:	Glasgow Haskell Compilation system
 Summary(pl.UTF-8):	System kompilacji Glasgow Haskell
 Name:		ghc
-Version:	7.6.3
-Release:	6
+Version:	8.8.2
+Release:	0.1
 License:	BSD-like w/o adv. clause
 Group:		Development/Languages
-Source0:	http://haskell.org/ghc/dist/%{version}/%{name}-%{version}-src.tar.bz2
-# Source0-md5:	986d1f90ca30d60f7b2820d75c6b8ea7
+Source0:	http://haskell.org/ghc/dist/%{version}/%{name}-%{version}-src.tar.xz
+# Source0-md5:	29f1cf9f42397f38bf6fe7de1c15a934
 %if %{with bootstrap}
-Source3:	http://haskell.org/ghc/dist/%{version}/%{name}-%{version}-i386-unknown-linux.tar.bz2
-# Source3-md5:	37019b712ec6e5fb0732c27fb43667ee
-Source4:	http://haskell.org/ghc/dist/%{version}/%{name}-%{version}-x86_64-unknown-linux.tar.bz2
-# Source4-md5:	5c142b86355cfd390cd36c292e416db5
+Source3:	https://downloads.haskell.org/~ghc/%{version}/%{name}-%{version}-i386-deb9-linux.tar.xz
+# Source3-md5:	fdd35ab48401842710dd4215929565f1
+Source4:	https://downloads.haskell.org/~ghc/%{version}/%{name}-%{version}-x86_64-deb9-linux.tar.xz
+# Source4-md5:	f2fa48668602663450c75235912faeb5
+Source5:	http://ftp.ports.debian.org/debian-ports//pool-x32/main/g/ghc/ghc_8.8.1+dfsg1+is+8.6.5+dfsg1-2_x32.deb
+# Source5-md5:	8434820718903331406fa0c7f53feaa8
 %endif
 Patch0:		%{name}-pld.patch
 Patch1:		%{name}-pkgdir.patch
 Patch2:		%{name}-winpaths.patch
-Patch3:		%{name}-use-ld.bfd.patch
+Patch3:		build.patch
+Patch4:		buildpath-abi-stability.patch
+Patch5:		x32-use-native-x86_64-insn.patch
 URL:		http://haskell.org/ghc/
 BuildRequires:	OpenAL-devel
 BuildRequires:	OpenGL-GLU-devel
 BuildRequires:	OpenGL-devel
 BuildRequires:	OpenGL-glut-devel
-%{!?with_bootstrap:BuildRequires:	alex >= 2.0}
+BuildRequires:	binutils >= 4:2.30
 BuildRequires:	freealut-devel
-%{!?with_bootstrap:BuildRequires:	ghc >= 6.8}
 BuildRequires:	gmp-devel
-%{!?with_bootstrap:BuildRequires:	happy >= 1.16}
 BuildRequires:	ncurses-devel
 BuildRequires:	readline-devel
 BuildRequires:	rpmbuild(macros) >= 1.607
 BuildRequires:	sed >= 4.0
+%if %{with bootstrap}
+%ifarch %{x8664} %{ix86}
+BuildRequires:	compat-ncurses5
+%endif
+%else
+BuildRequires:	alex >= 2.0
+BuildRequires:	ghc >= 6.8
+BuildRequires:	happy >= 1.16
+%endif
 %if %{with doc}
 BuildRequires:	dblatex
 BuildRequires:	docbook-dtd42-xml
@@ -116,12 +123,9 @@ Provides:	ghc-time = %{gpv_time}
 Provides:	ghc-unix = %{gpv_unix}
 Provides:	haddock
 Obsoletes:	haddock
-ExclusiveArch:	%{ix86} %{x8664}
+ExclusiveArch:	%{ix86} %{x8664} x32
 BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
 
-# use ld.bfd
-%define		specflags	-fuse-ld=bfd
-
 # There is nothing that may or should be compressed
 %define		_noautocompressdoc	*
 
@@ -216,25 +220,52 @@ Dokumentacja do GHC.
 %prep
 %setup -q
 %if %{with bootstrap}
+
+# official binaries
+%ifarch %{ix86} %{x8664}
 %ifarch %{ix86}
-%{__tar} -xjf %{SOURCE3}
+%{__tar} -xf %{SOURCE3}
 %endif
 %ifarch %{x8664}
-%{__tar} -xjf %{SOURCE4}
+%{__tar} -xf %{SOURCE4}
 %endif
 mv %{name}-%{version} binsrc
 %endif
+
+# debian binaries for x32
+%ifarch x32
+install -d bindist
+cd bindist
+ar x %{SOURCE5}
+tar xf data.tar.xz
+ln -s usr/bin bin
+sed -i -e "s#/usr#$(pwd)/usr#g" bin/{ghc,ghc-pkg,haddock,runghc} var/lib/ghc/*/*.conf
+cp -a usr/lib/ghc/settings{,.org}
+sed -i -e 's#x86_64.*-ld.gold#ld.gold#g' usr/lib/ghc/settings
+sed -i -e 's#x86_64-linux-gnux32#%{_target_base_arch}-%{_target_vendor}-%{_target_os}%{?_gnu}#g' \
+	-e 's#gnux32-ar#gnux32-gcc-ar#g' \
+	-e 's#gnux32-ranlib#gnux32-gcc-ranlib#g' \
+	usr/lib/ghc/settings
+# make it relative
+ln -sf ../../../var/lib/ghc/package.conf.d usr/lib/ghc/package.conf.d
+
+# debian uses separate libtinfo, workaround
+ln -s %{_libdir}/libncurses.so.6 usr/lib/libtinfo.so.6
+LD_LIBRARY_PATH=$(pwd)/usr/lib; export LD_LIBRARY_PATH
+
+bin/ghc-pkg recache --global
+cd ..
+%endif
+%endif
+
 %patch0 -p1
-%patch1 -p1
-%patch2 -p1
+#%patch1 -p1
+#%patch2 -p1
 %patch3 -p1
+%patch4 -p1
+%patch5 -p1
 
 %build
-# use ld.bfd
-install -d our-ld
-ln -s %{_bindir}/ld.bfd our-ld/ld
-export PATH=$(pwd)/our-ld:$PATH
-
 %{__autoconf}
 cd libraries/terminfo
 %{__autoconf}
@@ -265,8 +296,21 @@ SplitObjs=NO
 EOF
 %endif
 
+%ifarch x32
+echo "INTEGER_LIBRARY = integer-simple" >> mk/build.mk
+
+# debian uses separate libtinfo, workaround
+LD_LIBRARY_PATH=$(pwd)/bindist/usr/lib; export LD_LIBRARY_PATH
+%endif
+
 top=$(pwd)
 %if %{with bootstrap}
+
+# don't depend on ncurses and do minimal things for bootstrap
+echo "libraries/haskeline_CONFIGURE_OPTS += --flag=-terminfo" >> mk/build.mk
+echo "utils/ghc-pkg_HC_OPTS += -DBOOTSTRAPPING" >> mk/build.mk
+
+%ifarch %{ix86} %{x8664}
 # we need to first install the tarball somewhere, as seems the programs don't
 # work out of the path otherwise
 if [ ! -f .bindist.install.mark ]; then
@@ -281,30 +325,20 @@ if [ ! -f .bindist.install.mark ]; then
 
 	touch .bindist.install.mark
 fi
+%endif
 
 PATH=$top/bindist/bin:$PATH:%{_prefix}/local/bin
 %endif
 
 %configure \
-	CONF_GCC_LINKER_OPTS_STAGE0="-fuse-ld=bfd" \
-	CONF_GCC_LINKER_OPTS_STAGE1="-fuse-ld=bfd" \
-	CONF_GCC_LINKER_OPTS_STAGE2="-fuse-ld=bfd" \
-	--target=%{_target_platform} \
-	--prefix=%{_prefix} \
-	--with-gcc="%{__cc}" \
-	--with-ld=/usr/bin/ld.bfd \
-	--with-nm=/usr/bin/nm \
 %if %{with bootstrap}
-	GhcPkgCmd=$top/bindist/bin/ghc-pkg \
-%endif
-%if %{with bootstrap2}
-	--with-ghc=$top/bindist/bin/ghc \
-%endif
-%if %{with bootstrap1}
-	--with-hc=$PWD/bindist/bin/ghc \
-	--with-ghc=$PWD/bindist/ghc/dist-stage2/build/ghc/ghc \
-	--with-hc=$PWD/bindist/ghc/dist-stage2/build/ghc/ghc \
+	CC_STAGE0="%{__cc}" \
+	GHC=$PWD/bindist/bin/ghc \
 %endif
+	--target=%{_target_platform} \
+	--prefix=%{_prefix} \
+	%{?with_unregistered:--enable-unregisterised} \
+	%{nil}
 
 %{__make}
 
diff --git a/build.patch b/build.patch
new file mode 100644
index 0000000..e423490
--- /dev/null
+++ b/build.patch
@@ -0,0 +1,11 @@
+--- ghc-8.8.2/configure.ac~	2020-01-12 23:14:36.000000000 +0100
++++ ghc-8.8.2/configure.ac	2020-01-19 16:08:44.055164413 +0100
+@@ -228,7 +228,7 @@ then
+     echo "This GHC (${WithGhc}) does not generate code for the build platform"
+     echo "   GHC target platform    : $bootstrap_target"
+     echo "   Desired build platform : $BuildPlatform"
+-    exit 1
++    #exit 1
+ fi
+ 
+ # Testing if we shall enable shared libs support on Solaris.
diff --git a/buildpath-abi-stability.patch b/buildpath-abi-stability.patch
new file mode 100644
index 0000000..c58fb11
--- /dev/null
+++ b/buildpath-abi-stability.patch
@@ -0,0 +1,25 @@
+Forwarded to https://ghc.haskell.org/trac/ghc/ticket/10424
+
+Index: ghc-8.8.1+dfsg1/compiler/iface/MkIface.hs
+===================================================================
+--- ghc-8.8.1+dfsg1.orig/compiler/iface/MkIface.hs
++++ ghc-8.8.1+dfsg1/compiler/iface/MkIface.hs
+@@ -713,7 +713,7 @@
+    iface_hash <- computeFingerprint putNameLiterally
+                       (mod_hash,
+                        ann_fn (mkVarOcc "module"),  -- See mkIfaceAnnCache
+-                       mi_usages iface0,
++                       usages,
+                        sorted_deps,
+                        mi_hpc iface0)
+ 
+@@ -748,6 +748,9 @@
+     (non_orph_fis,   orph_fis)   = mkOrphMap ifFamInstOrph (mi_fam_insts iface0)
+     fix_fn = mi_fix_fn iface0
+     ann_fn = mkIfaceAnnCache (mi_anns iface0)
++    -- Do not allow filenames to affect the interface
++    usages = [ case u of UsageFile _ fp -> UsageFile "" fp; _ -> u | u <- mi_usages iface0 ]
++
+ 
+ -- | Retrieve the orphan hashes 'mi_orphan_hash' for a list of modules
+ -- (in particular, the orphan modules which are transitively imported by the
diff --git a/ghc-pld.patch b/ghc-pld.patch
index 3eeecfd..3da9ddc 100644
--- a/ghc-pld.patch
+++ b/ghc-pld.patch
@@ -9,29 +9,17 @@
              test -z "[$]2" || eval "[$]2=ArchX86"
              ;;
          x86_64)
-@@ -185,7 +185,7 @@
+@@ -229,7 +229,7 @@ AC_DEFUN([FPTOOLS_SET_HASKELL_PLATFORM_V
  
      checkVendor() {
          case [$]1 in
--        dec|unknown|hp|apple|next|sun|sgi|ibm)
-+        pld|dec|unknown|hp|apple|next|sun|sgi|ibm)
+-        dec|none|unknown|hp|apple|next|sun|sgi|ibm|montavista|portbld|alpine)
++        dec|none|unknown|hp|apple|next|sun|sgi|ibm|montavista|portbld|alpine|pld)
              ;;
          *)
-             echo "Unknown vendor [$]1"
---- ghc-6.12.1/libraries/terminfo/configure.ac~	2009-09-15 08:09:05.000000000 +0200
-+++ ghc-6.12.1/libraries/terminfo/configure.ac	2010-04-08 16:43:45.040705349 +0200
-@@ -13,7 +13,8 @@
-     [curses_libraries=NONE])
- 
- 
--TERMINFO_INCLUDE_DIRS=
-+TERMINFO_INCLUDE_DIRS=/usr/include/ncursesw
-+CPPFLAGS="-I/usr/include/ncursesw $CPPFLAGS"
- TERMINFO_LIB_DIRS=
- if test "x$curses_libraries" != "xNONE"; then
-   LDFLAGS="-L$curses_libraries $LDFLAGS"
---- ghc-7.2.1/driver/split/ghc-split.lprl~	2011-08-07 19:10:05.000000000 +0200
-+++ ghc-7.2.1/driver/split/ghc-split.lprl	2011-09-26 11:13:36.907176266 +0200
+             AC_MSG_WARN([Unknown vendor [$]1])
+--- ghc-7.2.1/driver/split/ghc-split.pl~	2011-08-07 19:10:05.000000000 +0200
++++ ghc-7.2.1/driver/split/ghc-split.pl	2011-09-26 11:13:36.907176266 +0200
 @@ -225,7 +225,7 @@
                              if $TargetPlatform =~ /-apple-darwin/m;
      return(&process_asm_block_m68k($str))  if $TargetPlatform =~ /^m68k-/m;
diff --git a/x32-use-native-x86_64-insn.patch b/x32-use-native-x86_64-insn.patch
new file mode 100644
index 0000000..f329f93
--- /dev/null
+++ b/x32-use-native-x86_64-insn.patch
@@ -0,0 +1,27 @@
+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
+ .
+
+Index: ghc-8.8.1+dfsg1/rts/RtsSymbols.c
+===================================================================
+--- ghc-8.8.1+dfsg1.orig/rts/RtsSymbols.c
++++ ghc-8.8.1+dfsg1/rts/RtsSymbols.c
+@@ -939,7 +939,7 @@
+ 
+ 
+ // 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(__x86_64__) && defined(__ILP32__))
+ #define RTS_LIBGCC_SYMBOLS                             \
+       SymI_NeedsProto(__divdi3)                        \
+       SymI_NeedsProto(__udivdi3)                       \
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/ghc.git/commitdiff/b5cb5a553e9a42bfb885efae79de559939ad74ed



More information about the pld-cvs-commit mailing list