Bug#910664: Acknowledgement (ghc: ghc package can no longer be cross-compiled)

Helmut Grohne helmut at subdivi.de
Sun Dec 10 20:01:57 GMT 2023


user debian-cross at lists.debian.org
usertags 910664 + ftcbfs
tags 910664 + patch
thanks

Hi,

Given that the earlier bug about haskell-devscripts-minimal has been
fixed, I happen to have looked into this.

First and foremost, ghc now actively refuses being cross build with an
$(error ...). Would you mind weakening this to a $(warning ...)? While
that you don't want to support cross building of ghc, would you mind
others (like me) supporting it? Yes, it would still fail, but then
https://crossqa.debian.net/src/ghc could show a more useful reason for
that failure. (patch attached)

Then when you get past the $(error ...), stage1 tools are not found. In
a cross build, ghc prefixes these with the host gnu triplet. A bit of
renaming is required to make this work. (patch attached)

And then we run into:

On Tue, Oct 09, 2018 at 03:24:41PM +0200, John Paul Adrian Glaubitz wrote:
> This change to the debian/rules file helps to get a bit further:
> 
> --- debian/rules.orig   2018-09-26 11:08:46.000000000 +0200
> +++ debian/rules        2018-10-09 15:22:43.080942145 +0200
> @@ -126,6 +126,7 @@
>         echo 'V=1'                                     >> mk/build.mk
>         dh_auto_configure -- \
>                 $(EXTRA_CONFIGURE_FLAGS) \
> +               --host=$(DEB_BUILD_GNU_TYPE) \
>                 --with-system-libffi --libdir=/usr/lib
>  
>  override_dh_auto_build:
> 
> But it will still fail with:

I think this is wrong. The current ghc packaging includes this flag, but
ghc uses the same terminology as Debian, so when we say
--host=$(DEB_BUILD_GNU_TYPE) we ask it to produce a cross compiler, but
we really wanted a cross built ghc. One of the issues referenced from
the earlier $(error ...) also hints that this value is wrong for --host:
https://gitlab.haskell.org/ghc/ghc/-/issues/22006 Unless you have strong
reasons for why that should be correct, I suggest that we change it to
--host=$(DEB_HOST_GNU_TYPE). (not included in patch)

So this is where we are. I think we can make progress here if you want
to support this work. I'm also a big fan of actionable bug reports and
in having a patch, this bug becomes actionable. Given that you (ghc
maintainers) are evidently not interested in doing the work here, I also
suggest that you close this bug when applying the patch and letting
cross users file new bugs with new patches. Let me know what you think
about this.

Helmut
-------------- next part --------------
diff --minimal -Nru ghc-9.4.7/debian/changelog ghc-9.4.7/debian/changelog
--- ghc-9.4.7/debian/changelog	2023-10-18 21:50:19.000000000 +0200
+++ ghc-9.4.7/debian/changelog	2023-12-10 20:03:52.000000000 +0100
@@ -1,3 +1,10 @@
+ghc (9.4.7-1.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Improve cross building. (Closes: #-1)
+
+ -- Helmut Grohne <helmut at subdivi.de>  Sun, 10 Dec 2023 20:03:52 +0100
+
 ghc (9.4.7-1) unstable; urgency=medium
 
   * Upload to unstable
diff --minimal -Nru ghc-9.4.7/debian/rules ghc-9.4.7/debian/rules
--- ghc-9.4.7/debian/rules	2023-10-18 21:49:38.000000000 +0200
+++ ghc-9.4.7/debian/rules	2023-12-10 20:03:52.000000000 +0100
@@ -47,8 +47,10 @@
   EXTRA_HADRIAN_FLAGS += --flavour=quickest
   # Do not build docs *at all* (avoid dependency on Sphinx)
   EXTRA_HADRIAN_FLAGS += --docs=none
+  STAGE1_TOOL = _build/stage1/bin/$(DEB_HOST_GNU_TYPE)-
   BUILD_CROSS = YES
 else
+  STAGE1_TOOL = _build/stage1/bin/
   BUILD_CROSS = NO
 endif
 
@@ -149,7 +151,7 @@
 ifeq (YES,$(BUILD_CROSS))
 	# See https://gitlab.haskell.org/ghc/ghc/-/issues/23975
 	# and https://gitlab.haskell.org/ghc/ghc/-/issues/22006
-	$(error cross-compilation is not supported)
+	$(warning cross-compilation is not supported)
 endif
 	hadrian/hadrian \
 		-V -j \
@@ -162,7 +164,7 @@
 	# correct), but we use ghc-pkg from stage2 when we generate our control file.
 	# Maybe we should consider using ghc-pkg from binary-dist-dir instead.
 	# As a work-around for now, regenerate the stage2 package cache.
-	_build/stage1/bin/ghc-pkg recache
+	$(STAGE1_TOOL)ghc-pkg recache
 
 # This rule is a superset of 'override_dh_auto_build-arch'. It builds everything
 # that the '-arch' rule builds, and then docs on top.
@@ -185,7 +187,7 @@
 	# correct), but we use ghc-pkg from stage2 when we generate our control file.
 	# Maybe we should consider using ghc-pkg from binary-dist-dir instead.
 	# As a work-around for now, regenerate the stage2 package cache.
-	_build/stage1/bin/ghc-pkg recache
+	$(STAGE1_TOOL)ghc-pkg recache
 
 
 # --------------------------------------------------------------------
@@ -335,23 +337,23 @@
 	rm -rf debian/testghc
 	mkdir debian/testghc
 	echo 'main = putStrLn "Foo"' > debian/testghc/foo.hs
-	_build/stage1/bin/ghc debian/testghc/foo.hs -o debian/testghc/foo
+	$(STAGE1_TOOL)ghc debian/testghc/foo.hs -o debian/testghc/foo
 	[ "$$(debian/testghc/foo)" = "Foo" ]
 	rm debian/testghc/*
 	echo 'main = putStrLn "Foo"' > debian/testghc/foo.hs
-	_build/stage1/bin/ghc debian/testghc/foo.hs -o debian/testghc/foo -O2
+	$(STAGE1_TOOL)ghc debian/testghc/foo.hs -o debian/testghc/foo -O2
 	[ "$$(debian/testghc/foo)" = "Foo" ]
 	rm debian/testghc/*
 	# Test runghc
 	echo 'main = putStrLn "Foo"' > debian/testghc/foo.hs
-	[ "$$(_build/stage1/bin/runghc debian/testghc/foo.hs)" = "Foo" ]
+	[ "$$($(STAGE1_TOOL)runghc debian/testghc/foo.hs)" = "Foo" ]
 	rm debian/testghc/*
 	# Output information about GHC
 	@printf "====BEGIN GHC INFO OUTPUT====\n"
-	_build/stage1/bin/ghc --info
+	$(STAGE1_TOOL)ghc --info
 	@printf "====END GHC INFO OUTPUT====\n"
 	@printf "====BEGIN GHC-PKG OUTPUT====\n"
-	_build/stage1/bin/ghc-pkg list
+	$(STAGE1_TOOL)ghc-pkg list
 	@printf "====END GHC-PKG OUTPUT====\n"
 endif
 


More information about the Pkg-haskell-maintainers mailing list