Search code examples
haskellbuildcabal

Errors while building `ghc` : `alex`, `happy` are missing / fatal error in GHC module, with version bounds in `process`


Today, I upgraded my repo to GHC 9.2.4. As part of it, cabal tried to build hspec-2.9.7, which requires ghc library. So, it builds ghc-9.2.4, and there was a problem.

First, it says:

Error: cabal-3.8.1.0: The program 'alex' is required but it could not be
found

so I did cabal install alex and retry.

Then, it says:

Error: cabal-3.8.1.0: The program 'happy' is required but it could not be
found

Something was fishy, but anyway I did cabal install happy and proceeded. Note that I never needed to install either alex or happy before when building hspec.

The next build gave off tons of errors like:

GHC/Builtin/Names.hs:2073:2: error:
     fatal error: primop-vector-uniques.hs-incl: No such file or directory
     2073 | 
          |  ^                              
     |
2073 | 
     |  ^
compilation terminated.

GHC/Builtin/PrimOps.hs:67:2: error:
     fatal error: primop-data-decl.hs-incl: No such file or directory
       67 | 
          |  ^                         
   |
67 | 
   |  ^
compilation terminated.
(...continues like this)

After hours of debug later, I found some clue: version bounds on process package (process >= 1.6.14) is causing the problem. Apparently, default ghc cannot be used with other versions of process.

Now I am wondering why

  1. ghc package cannot be built manually
  2. ghc package requires the specific version of boot libraries

Why is it so picky to deal with?


Solution

  • Reported in https://github.com/haskell/cabal/issues/8489 , resolved by associated PR - now it provides better error messages.

    Basically, the crux of the problem is that ghc package is non-upgradable. It depends on process package, so you need specific process package version as well if you depend on ghc.