Skip to content

Cannot bootstrap ghc-9.8.2 with ghc-9.8.2 as a bootstrap compiler

Summary

Hi, I maintain the Alpine Linux GHC package 👋 I am currently in the process of upgrading this package from ghc-9.4.8 to ghc-9.8.2. I can already successfully compile GHC 9.8.2 with version 9.4.8. Unfortunately, for our Alpine package, we need to be able to compile GHC 9.8.2 with itself as a bootstrap compiler. I understand that this is not officially supported, but for past versions (with some minor patches here and there), I was always able to make it work.

The current issue, which I am unable to fix by myself, occurs during the compilation of ghc/Main.hs with GHC 9.8.2 (libraries needed by ghc/Main.hs were successfully compiled prior to that). The relevant part of the build log looks as follows:

Command line: /usr/bin/ghc -Wall -Wcompat -fdiagnostics-color=never -hisuf hi -osuf o -hcsuf hc -static -hide-all-packages -no-user-package-db '-package-env -' '-packa
ge-db _build/stage0/inplace/package.conf.d' '-this-unit-id ghc-bin-9.8.2-inplace' '-package-id array-0.5.6.0-inplace' '-package-id base-4.19.1.0-inplace' '-package-id
bytestring-0.12.1.0-inplace' '-package-id containers-0.6.8-inplace' '-package-id directory-1.3.8.1-inplace' '-package-id filepath-1.4.200.1-inplace' '-package-id ghc-9
.8.2-inplace' '-package-id ghc-boot-9.8.2-inplace' '-package-id process-1.6.18.0-inplace' '-package-id transformers-0.6.1.0-inplace' '-package-id unix-2.8.4.0-inplace'
 -i -i/home/buildozer/aports/community/ghc/src/ghc-9.8.2/_build/stage0/ghc/build -i/home/buildozer/aports/community/ghc/src/ghc-9.8.2/_build/stage0/ghc/build/ghc/autog
en -i/home/buildozer/aports/community/ghc/src/ghc-9.8.2/ghc -I_build/stage0/ghc/build -I/home/buildozer/aports/community/ghc/src/ghc-9.8.2/compiler -I/home/buildozer/a
ports/community/ghc/src/ghc-9.8.2/_build/stage0/compiler/build -I/home/buildozer/aports/community/ghc/src/ghc-9.8.2/libraries/process/include -I/home/buildozer/aports/
community/ghc/src/ghc-9.8.2/_build/stage0/libraries/process/build/include -I/home/buildozer/aports/community/ghc/src/ghc-9.8.2/libraries/directory -I/home/buildozer/ap
orts/community/ghc/src/ghc-9.8.2/_build/stage0/libraries/directory/build -I/home/buildozer/aports/community/ghc/src/ghc-9.8.2/libraries/unix/include -I/home/buildozer/
aports/community/ghc/src/ghc-9.8.2/_build/stage0/libraries/unix/build/include -I/home/buildozer/aports/community/ghc/src/ghc-9.8.2/libraries/time/lib/include -I/home/b
uildozer/aports/community/ghc/src/ghc-9.8.2/_build/stage0/libraries/time/build/lib/include -I/home/buildozer/aports/community/ghc/src/ghc-9.8.2/libraries/containers/co
ntainers/include -I/home/buildozer/aports/community/ghc/src/ghc-9.8.2/_build/stage0/libraries/containers/containers/build/include -I/home/buildozer/aports/community/gh
c/src/ghc-9.8.2/libraries/bytestring/include -I/home/buildozer/aports/community/ghc/src/ghc-9.8.2/_build/stage0/libraries/bytestring/build/include -I/usr/lib/ghc-9.8.2
/lib/x86_64-linux-ghc-9.8.2/base-4.19.1.0-inplace/include -I/usr/lib/ghc-9.8.2/lib/x86_64-linux-ghc-9.8.2/ghc-bignum-1.3-inplace/include -I/usr/lib/ghc-9.8.2/lib/x86_6
4-linux-ghc-9.8.2/rts-1.0.2/include -optP-include -optP_build/stage0/ghc/build/ghc/autogen/cabal_macros.h -outputdir _build/stage0/ghc/build -Wall -Wnoncanonical-monad
-instances -Wnoncanonical-monoid-instances -rtsopts=all '-with-rtsopts=-K512M -H -I5 -T' -threaded -XHaskell2010 -XNoImplicitPrelude -XScopedTypeVariables -XBangPatter
ns -optc-Wno-error=inline -c ghc/Main.hs -o _build/stage0/ghc/build/Main.o -O -H64m -O -I_build/stage0/compiler/build
===> Command failed with error code: 1

ghc/Main.hs:18:1: error: [GHC-53693]
    Something is amiss; requested module  ghc-9.8.2:GHC differs from name found in the interface file ghc:GHC (if these names look the same, try again with -dppr-debug
)
   |
18 | import qualified GHC

I confirmed (using --show-iface) that the interfaces files do—in fact—contain the name ghc instead of ghc-9.8.2 and initially assumed this to be caused by an assumption about the bootstrap compiler version somewhere in the GHC source code. However, after asking around on IRC a bit, I was told that this looks like a GHC bug and that it should be reported here.

The full build log (includes some output of the Alpine tooling in the beginning): https://dev.alpinelinux.org/~nmeum/alpine-linux-edge-ghc-9.8.2-log.txt

Steps to reproduce

I believe all that is needed to reproduce this is building ghc-9.8.2 (which at the time of writing is the latest release) with itself (i.e. with ghc-9.8.2 as a bootstrap compiler). This requires a minor patch to adjust some version constraints on libraries bundled by GHC. Apart from the build log, the exact build flags we use in Alpine are documented in the GHC APKBUILD. In case this cannot be reproduced on non-Alpine systems, I can look into preparing an Alpine-based Dockerfile to trigger this.

Expected behavior

A successful build of ghc-9.8.2.

Environment

  • GHC version used: 9.8.2

Optional:

  • Operating System: Alpine Linux Edge
  • System Architecture: x86_64
Edited by Sören Tempel
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information