pkgsrc-Changes archive

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

CVS commit: pkgsrc/lang/ghc94



Module Name:    pkgsrc
Committed By:   pho
Date:           Wed Oct 11 03:07:31 UTC 2023

Modified Files:
        pkgsrc/lang/ghc94: bootstrap.mk
        pkgsrc/lang/ghc94/files: BOOTSTRAP.md
Added Files:
        pkgsrc/lang/ghc94/files: extract-vanilla-package-db

Log Message:
lang/ghc94: Fix broken "make bootstrap"

Bootstrapping the compiler without "cabal-install" is something GHC devs
rarely do, and it keeps bitrotting. This time I could make it work again,
but at some point we might end up having to distribute binaries of
cabal-install for each platform.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 pkgsrc/lang/ghc94/bootstrap.mk
cvs rdiff -u -r1.1 -r1.2 pkgsrc/lang/ghc94/files/BOOTSTRAP.md
cvs rdiff -u -r0 -r1.1 pkgsrc/lang/ghc94/files/extract-vanilla-package-db

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/lang/ghc94/bootstrap.mk
diff -u pkgsrc/lang/ghc94/bootstrap.mk:1.6 pkgsrc/lang/ghc94/bootstrap.mk:1.7
--- pkgsrc/lang/ghc94/bootstrap.mk:1.6  Tue Jun  6 12:41:44 2023
+++ pkgsrc/lang/ghc94/bootstrap.mk      Wed Oct 11 03:07:31 2023
@@ -1,4 +1,4 @@
-# $NetBSD: bootstrap.mk,v 1.6 2023/06/06 12:41:44 riastradh Exp $
+# $NetBSD: bootstrap.mk,v 1.7 2023/10/11 03:07:31 pho Exp $
 # -----------------------------------------------------------------------------
 # Select a bindist of bootstrapping compiler on a per-platform basis. See
 # ./files/BOOTSTRAP.md for details.
@@ -290,6 +290,26 @@ ${WRKDIR}/stamp-build-boot: ${WRKDIR}/st
 
        @${PHASE_MSG} "Building Hadrian for ${BOOT_GHC_VERSION}"
        ${CP} -f ${FILESDIR}/UserSettings.hs ${WRKSRC}/hadrian/
+# ${HADRIAN_BOOT_SOURCE} often contains libraries older than what we have
+# in pkgsrc. When that happens bootstrap.py tries to build Hadrian with
+# pkgsrc-installed libraries and fails because they aren't buildlinked. So
+# we must temporarily disable wrappers while building it.
+       saved_IFS="$$IFS"; \
+       IFS=":"; \
+       set -- $$PATH; \
+       IFS="$$saved_IFS"; \
+       pruned_path=; \
+       while ${TEST} "$$#" -gt 0; do \
+               if ${TEST} "$$1" != "${WRAPPER_BINDIR}"; then \
+                       if ${TEST} "$$pruned_path" = ""; then \
+                               pruned_path="$$1"; \
+                       else \
+                               pruned_path="$$pruned_path:$$1"; \
+                       fi; \
+               fi; \
+               shift; \
+       done; \
+       PATH="$$pruned_path"; \
        cd ${WRKSRC}/hadrian/bootstrap && \
                python bootstrap.py -s ${DISTDIR}/${DIST_SUBDIR}/${HADRIAN_BOOT_SOURCE}
 

Index: pkgsrc/lang/ghc94/files/BOOTSTRAP.md
diff -u pkgsrc/lang/ghc94/files/BOOTSTRAP.md:1.1 pkgsrc/lang/ghc94/files/BOOTSTRAP.md:1.2
--- pkgsrc/lang/ghc94/files/BOOTSTRAP.md:1.1    Sat Jan 21 04:49:25 2023
+++ pkgsrc/lang/ghc94/files/BOOTSTRAP.md        Wed Oct 11 03:07:31 2023
@@ -1,4 +1,4 @@
-<!-- $NetBSD: BOOTSTRAP.md,v 1.1 2023/01/21 04:49:25 pho Exp $ -->
+<!-- $NetBSD: BOOTSTRAP.md,v 1.2 2023/10/11 03:07:31 pho Exp $ -->
 
 # We need GHC to build GHC
 
@@ -60,11 +60,14 @@ skip this step. If not, install `misc/ca
 
 ```
 % cd ${WRKSRC}/hadrian
-% cabal configure
+% ../../../files/extract-vanilla-package-db ./packages.conf
+(The next command fails with an error but you can safely ignore it.)
+% cabal build --package-db=clear --package-db=./packages.conf --only-configure
+% cp dist-newstyle/cache/plan.json bootstrap/plan-${BOOT_VERSION}.json
 % cd ./bootstrap
 % cabal build --allow-newer
-% cp ../dist-newstyle/cache/plan.json plan-${BOOT_VERSION}.json
-% cabal run -v0 -- plan-${BOOT_VERSION}.json | \
+% cabal run -v0 --allow-newer hadrian-bootstrap-gen \
+      -- plan-${BOOT_VERSION}.json | \
       tee plan-bootstrap-${BOOT_VERSION}.json
 ```
 

Added files:

Index: pkgsrc/lang/ghc94/files/extract-vanilla-package-db
diff -u /dev/null pkgsrc/lang/ghc94/files/extract-vanilla-package-db:1.1
--- /dev/null   Wed Oct 11 03:07:31 2023
+++ pkgsrc/lang/ghc94/files/extract-vanilla-package-db  Wed Oct 11 03:07:31 2023
@@ -0,0 +1,29 @@
+#!/bin/sh
+set -eu
+
+# This script extracts the package DB originally came from GHC you are
+# using. Only needed when you create a hadrian bootstrap archive.
+
+if [ "$#" -lt 1 ]; then
+    echo >&2 "Usage: $0 PKG_DB_DIR"
+    exit
+fi
+PKG_DB_DIR="$1"
+
+mkdir -p "$PKG_DB_DIR"
+pkg_info -qL ghc | {
+    conf_dir_path=
+    while read path; do
+        conf_dir_removed="${path#*/package.conf.d/}"
+        if [ "$conf_dir_removed" != "$path" ]; then
+            echo "Copying ${path}..."
+            if [ "$conf_dir_path" = "" ]; then
+                conf_dir_path="${path%/${conf_dir_removed}}"
+            fi
+            sed -e "s|\\\${pkgroot}|${conf_dir_path}/..|g" \
+                < "${path}" \
+                > "${PKG_DB_DIR}/${conf_dir_removed}"
+        fi
+    done
+}
+ghc-pkg --package-db="$PKG_DB_DIR" recache



Home | Main Index | Thread Index | Old Index