Now that we landed ghc-9.6 is a good time to have `make test` fixed. It
took some doing to have them all fixed upstream and even then some of the
fixes are still not in 9.6. Anyway, OK?

>From fe0577aab710d1a3c5c5e4178088ffe96a2da07d Mon Sep 17 00:00:00 2001
From: Greg Steuck <g...@nest.cx>
Date: Sun, 14 Jan 2024 14:20:59 -0800
Subject: [PATCH 1/2] Remove sphinx dependency now that we no longer build
 lang/ghc docs

---
 lang/ghc/Makefile | 20 ++------------------
 lang/ghc/distinfo |  2 --
 2 files changed, 2 insertions(+), 20 deletions(-)

diff --git a/lang/ghc/Makefile b/lang/ghc/Makefile
index 9aa4f19d65c..1612e816c88 100644
--- a/lang/ghc/Makefile
+++ b/lang/ghc/Makefile
@@ -39,8 +39,8 @@ LIB_DEPENDS =         converters/libiconv \
                        devel/libffi
 
 BUILD_DEPENDS =                archivers/bzip2 \
-                       archivers/gtar \
-                       textproc/py-sphinx${MODPY_FLAVOR}>=4.0.2
+                       archivers/gtar
+
 RUN_DEPENDS =
 
 SITES =                        
https://downloads.haskell.org/ghc/${GHC_VERSION}/
@@ -61,17 +61,7 @@ DISTFILES.boot =     ${BINDISTFILE-${MACHINE_ARCH}}
 DISTFILES.noextract =  hadrian-sources-${BIN_VER}.tar.gz
 SITES.noextract =      https://openbsd.dead-parrot.de/distfiles/
 
-# sphinx-rtd-theme update patch set
-# mirrored from 
https://gitlab.haskell.org/ghc/ghc/-/commit/70526f5bd8886126f49833ef20604a2c6477780a.patch
-# "GIT binary patch" (gpatch doesn't handle it, patch segfaults)
-# (sorry! -sthen)
-SITES.p =              https://spacehopper.org/mirrors/
-DISTFILES.p +=         ghc-rtd-update-70526f5bd8.diff
 EXTRACT_ONLY =         ${DISTFILES} ${DISTFILES.boot}
-BUILD_DEPENDS +=       devel/git
-pre-patch:
-       cd ${WRKSRC}; env -i git apply 
${FULLDISTDIR}/ghc-rtd-update-70526f5bd8.diff
-
 
 # Substvars for all libraries, assuming that ghc-boot, ghc-boot-th,
 # ghc-heap and ghci will always have the same version number as ghc.
@@ -136,9 +126,6 @@ CONFIGURE_ENV +=    
CONF_GCC_LINKER_OPTS_STAGE0="${GHC_CC_OPTS}" \
                        CONF_GCC_LINKER_OPTS_STAGE2="${GHC_CC_OPTS}" \
                        CONF_CC_OPTS_STAGE2="${GHC_CC_OPTS}"
 
-# Do not pick up gpatch
-CONFIGURE_ENV +=       ac_cv_path_PatchCmd=/usr/bin/patch
-
 MAKE_FLAGS +=          StripLibraries=YES \
                        INSTALL_BIN_OPTS=-s \
                        HSCOLOUR_SRCS=NO \
@@ -147,9 +134,6 @@ MAKE_FLAGS +=               StripLibraries=YES \
 # haddock: ... <stdout>: commitBuffer: invalid argument (invalid character)
 MAKE_ENV =     LC_ALL=en_US.UTF-8
 
-# For mktexpk (via dvips when building the PostScript documentation):
-PORTHOME =             ${WRKDIR}
-
 TEST_DEPENDS = print/ghostscript/gnu ${MODPY_RUN_DEPENDS}
 
 post-extract:
diff --git a/lang/ghc/distinfo b/lang/ghc/distinfo
index 2a2065aa251..3c92fd3f3be 100644
--- a/lang/ghc/distinfo
+++ b/lang/ghc/distinfo
@@ -2,11 +2,9 @@ SHA256 (ghc/ghc-9.6.4.20240111-amd64.tar.xz) = 
CedJ29vBFZyl1e+DgcUqPfjHMDRKmEOsX
 SHA256 (ghc/ghc-9.6.4.20240111-shlibs-amd64.tar.gz) = 
Nb3trqnIF8H5kfKEkeGLr+sl4rPeFsbW/gfkelRprrY=
 SHA256 (ghc/ghc-9.6.4-src.tar.xz) = 
EL8luLBxdP3ZhotcDFbBfA7x7ctiR7S4ZL6TNlG/1MA=
 SHA256 (ghc/ghc-9.6.4-testsuite.tar.xz) = 
bhMoL76//b+gpJiJQ3REyakM/ldgxHlpzUJFhUwzjXM=
-SHA256 (ghc/ghc-rtd-update-70526f5bd8.diff) = 
maCALPRglB5J9LJEQxBqMGdVbH4qK2gqVuaU5xmYdNU=
 SHA256 (ghc/hadrian-sources-9.6.4.20240111.tar.gz) = 
wMMJfyP7Pr6xjb/tj9Kz5iZugGr6+duMwJ23aGsUWy0=
 SIZE (ghc/ghc-9.6.4-src.tar.xz) = 29451856
 SIZE (ghc/ghc-9.6.4-testsuite.tar.xz) = 7075820
 SIZE (ghc/ghc-9.6.4.20240111-amd64.tar.xz) = 74706384
 SIZE (ghc/ghc-9.6.4.20240111-shlibs-amd64.tar.gz) = 3544885
-SIZE (ghc/ghc-rtd-update-70526f5bd8.diff) = 4245853
 SIZE (ghc/hadrian-sources-9.6.4.20240111.tar.gz) = 2125322
\ No newline at end of file
-- 
2.43.0

>From 11e6bf454004e8e60894c7259f8c3a8fbd49525d Mon Sep 17 00:00:00 2001
From: Greg Steuck <g...@nest.cx>
Date: Sat, 27 Jan 2024 19:16:24 -0800
Subject: [PATCH 2/2] Fix `make test` in lang/ghc

---
 lang/ghc/Makefile                             | 31 ++++++++++---------
 .../patches/patch-compiler_GHC_Unit_State_hs  |  2 +-
 .../patch-libraries_process_tests_all_T       | 12 +++++++
 .../patches/patch-testsuite_driver_testlib_py | 10 +++---
 4 files changed, 33 insertions(+), 22 deletions(-)
 create mode 100644 lang/ghc/patches/patch-libraries_process_tests_all_T

diff --git a/lang/ghc/Makefile b/lang/ghc/Makefile
index 1612e816c88..dc02ebab65a 100644
--- a/lang/ghc/Makefile
+++ b/lang/ghc/Makefile
@@ -132,7 +132,7 @@ MAKE_FLAGS +=               StripLibraries=YES \
                        BUILD_SPHINX_PDF=NO
 
 # haddock: ... <stdout>: commitBuffer: invalid argument (invalid character)
-MAKE_ENV =     LC_ALL=en_US.UTF-8
+MAKE_ENV +=    LC_ALL=en_US.UTF-8
 
 TEST_DEPENDS = print/ghostscript/gnu ${MODPY_RUN_DEPENDS}
 
@@ -162,17 +162,20 @@ post-patch:
        cd ${WRKSRC} && \
        ${MODPY_BIN} hadrian/bootstrap/bootstrap.py --no-archive -w ../bin/ghc \
                -s ${FULLDISTDIR}/hadrian-sources-${BIN_VER}.tar.gz
-do-build:
-       cd ${WRKSRC} && \
+
+HADRIAN = \
        env -i ${AUTOCONF_ENV} ${MAKE_ENV} \
        _build/bin/hadrian '*.*.ghc.link.opts+=-optl-Wl,--no-execute-only' \
-               '*.*.ghc.link.opts+=-optl-Qunused-arguments' \
-               '*.*.ghc.link.opts+=-L/usr/local/lib' \
-               --docs=none \
-               --flavour=release${TRANSFORMER} \
-               --no-color \
-               --jobs=${MAKE_JOBS} \
-               binary-dist-dir
+       '*.*.ghc.link.opts+=-optl-Qunused-arguments' \
+       '*.*.ghc.link.opts+=-L/usr/local/lib' \
+       --docs=none \
+       --flavour=release${TRANSFORMER} \
+       --no-color \
+       --jobs=${MAKE_JOBS}
+
+do-build:
+       cd ${WRKSRC} && \
+       ${HADRIAN} binary-dist-dir
        ln -sf 
${WRKSRC}/_build/bindist/ghc-${GHC_VERSION}{-x86_64-unknown-openbsd,}
 
 do-install:
@@ -181,11 +184,9 @@ do-install:
        env -i ${MAKE_ENV} ${FAKE_SETUP} ${MAKE_PROGRAM} ${ALL_FAKE_FLAGS} -f 
${MAKE_FILE} ${FAKE_TARGET}
 
 do-test:
-       ulimit -c 0 -n 1024 && \
-       cd ${WRKSRC}/testsuite/tests && \
-       exec ${SETENV} ${MAKE_ENV} LC_CTYPE=en_US.UTF-8 \
-               ${MAKE_PROGRAM} ${MAKE_FLAGS} \
-               PYTHON="${MODPY_BIN}"
+       ln -sf /usr/bin/false ${WRKDIR}/bin/git
+       cd ${WRKSRC} && \
+       ulimit -s 8192 -d 10485760 -n 1024 && env  ${HADRIAN} test
 
 # It doesn't matter whether this is the actual date of the bootstrapper
 # build. It's just used to get different distfiles whenever new
diff --git a/lang/ghc/patches/patch-compiler_GHC_Unit_State_hs 
b/lang/ghc/patches/patch-compiler_GHC_Unit_State_hs
index 937671f8614..e75eb5e0e6c 100644
--- a/lang/ghc/patches/patch-compiler_GHC_Unit_State_hs
+++ b/lang/ghc/patches/patch-compiler_GHC_Unit_State_hs
@@ -5,7 +5,7 @@ Uses $topdir/include as the very first place to find 
DerivedConstants.h
 Index: compiler/GHC/Unit/State.hs
 --- compiler/GHC/Unit/State.hs.orig
 +++ compiler/GHC/Unit/State.hs
-@@ -661,7 +661,13 @@ initUnits logger dflags cached_dbs home_units = do
+@@ -672,7 +672,13 @@ initUnits logger dflags cached_dbs home_units = do
        -- really need to use the platform constants but they have not been 
loaded.
        case lookupUnitId unit_state rtsUnitId of
          Nothing   -> return Nothing
diff --git a/lang/ghc/patches/patch-libraries_process_tests_all_T 
b/lang/ghc/patches/patch-libraries_process_tests_all_T
new file mode 100644
index 00000000000..eec5ef90114
--- /dev/null
+++ b/lang/ghc/patches/patch-libraries_process_tests_all_T
@@ -0,0 +1,12 @@
+Disable a test fixed in the next version:
+https://github.com/haskell/process/issues/266
+
+Index: libraries/process/tests/all.T
+--- libraries/process/tests/all.T.orig
++++ libraries/process/tests/all.T
+@@ -50,4 +50,4 @@ test('process011',
+      compile_and_run, [''])
+ 
+ test('T8343', js_broken(22349), compile_and_run, [''])
+-test('processT251', js_broken(22349), compile_and_run, [''])
++test('processT251', [when(opsys('openbsd'), skip), js_broken(22349)], 
compile_and_run, [''])
diff --git a/lang/ghc/patches/patch-testsuite_driver_testlib_py 
b/lang/ghc/patches/patch-testsuite_driver_testlib_py
index 229cddc1799..a3243e8f046 100644
--- a/lang/ghc/patches/patch-testsuite_driver_testlib_py
+++ b/lang/ghc/patches/patch-testsuite_driver_testlib_py
@@ -1,21 +1,19 @@
 Index: testsuite/driver/testlib.py
 --- testsuite/driver/testlib.py.orig
 +++ testsuite/driver/testlib.py
-@@ -2146,6 +2146,13 @@ def compare_outputs(way: WayName,
+@@ -2146,6 +2146,11 @@ def compare_outputs(way: WayName,
      actual_raw = read_no_crs(actual_path)
      actual_str = normaliser(actual_raw)
  
 +    # Strip OpenBSDs linker warnings about strcpy(3) & friends.
 +    if config.os == 'openbsd':
-+        actual_str = re.sub('.*: In function .*:\n+(.*:[0-9]+:[0-9]+:\n)?:? 
*warning: .* is .* misused, please use .*\n',
-+                            '', actual_str)
-+        actual_str = re.sub('.*/libgmp\.so\.[0-9]*\.[0-9]*: warning: .* is .* 
misused, please use .*\n',
++        actual_str = re.sub('.*warning:.* misused, please use .*\n',
 +                            '', actual_str)
 +
      # See Note [Output comparison].
      if whitespace_normaliser(expected_str) == 
whitespace_normaliser(actual_str):
          return True
-@@ -2162,7 +2169,7 @@ def compare_outputs(way: WayName,
+@@ -2162,7 +2167,7 @@ def compare_outputs(way: WayName,
  
          if config.verbose >= 1 and _expect_pass(way):
              # See Note [Output comparison].
@@ -24,7 +22,7 @@ Index: testsuite/driver/testlib.py
                                                          
actual_normalised_path),
                          stdout=diff_file,
                          print_output=True)
-@@ -2170,7 +2177,7 @@ def compare_outputs(way: WayName,
+@@ -2170,7 +2175,7 @@ def compare_outputs(way: WayName,
              # If for some reason there were no non-whitespace differences,
              # then do a full diff
              if r == 0:
-- 
2.43.0

Reply via email to