Source: ghc
Version: 9.4.7-1
Severity: normal
Tags: patch

Hi!

When src:ghc was switched from GNU Make to Hadrian, the build system lost
the ability to pass the parallel jobs provided in DEB_BUILD_OPTIONS to the
build process.

Luckily, Hadrian knows how to deal with parallel jobs using the -j option,
so we can just extract the number of parallel jobs from DEB_BUILD_OPTIONS
which is what the attached patch does:

--- ghc-9.4.7/debian/rules.orig 2023-10-18 21:49:38.000000000 +0200
+++ ghc-9.4.7/debian/rules      2023-11-25 19:59:40.401680294 +0100
@@ -95,6 +95,10 @@
        EXTRA_HADRIAN_FLAGS += "*.*.rts.*.opts += -O0"
 endif
 
+ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
+    NUMJOBS = $(patsubst parallel=%,%,$(filter 
parallel=%,$(DEB_BUILD_OPTIONS)))
+endif
+
 # Use system libffi
 EXTRA_CONFIGURE_FLAGS += --with-system-libffi
 
@@ -152,7 +156,7 @@
        $(error cross-compilation is not supported)
 endif
        hadrian/hadrian \
-               -V -j \
+               -V -j$(NUMJOBS) \
                --docs=no-haddocks --docs=no-sphinx-html --docs=no-sphinx-pdfs \
                binary-dist-dir \
                $(EXTRA_HADRIAN_FLAGS)
@@ -175,7 +179,7 @@
        $(error override_dh_auto_build-indep is not supported when cross 
compiling)
 endif
        hadrian/hadrian \
-               -V -j \
+               -V -j$(NUMJOBS) \
                --docs=no-sphinx-pdfs \
                binary-dist-dir \
                $(EXTRA_HADRIAN_FLAGS)

I adapted the above snippet from the debian/rules file for src:cmake [1] in case
you want to credit the original authors.

Thanks,
Adrian

> [1] https://salsa.debian.org/cmake-team/cmake/-/blob/master/debian/rules#L54

--
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
--- ghc-9.4.7/debian/rules.orig 2023-10-18 21:49:38.000000000 +0200
+++ ghc-9.4.7/debian/rules      2023-11-25 19:59:40.401680294 +0100
@@ -95,6 +95,10 @@
        EXTRA_HADRIAN_FLAGS += "*.*.rts.*.opts += -O0"
 endif
 
+ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
+    NUMJOBS = $(patsubst parallel=%,%,$(filter 
parallel=%,$(DEB_BUILD_OPTIONS)))
+endif
+
 # Use system libffi
 EXTRA_CONFIGURE_FLAGS += --with-system-libffi
 
@@ -152,7 +156,7 @@
        $(error cross-compilation is not supported)
 endif
        hadrian/hadrian \
-               -V -j \
+               -V -j$(NUMJOBS) \
                --docs=no-haddocks --docs=no-sphinx-html --docs=no-sphinx-pdfs \
                binary-dist-dir \
                $(EXTRA_HADRIAN_FLAGS)
@@ -175,7 +179,7 @@
        $(error override_dh_auto_build-indep is not supported when cross 
compiling)
 endif
        hadrian/hadrian \
-               -V -j \
+               -V -j$(NUMJOBS) \
                --docs=no-sphinx-pdfs \
                binary-dist-dir \
                $(EXTRA_HADRIAN_FLAGS)

Reply via email to