Alfredo, I've confirmed that I can use the stage1 compiler and it doesn't panic.
It occurs to me that I might be able to *compile* my code with the stage1 compiler while using the bootstrap compiler and Haskell Language Server. I'll give that a shot. Norman > Hi Norman, > > in addition to what Ben already said: is there any particular reason you > wanted to use the stage0 compiler? I have written a small program against > HEAD which used the GHC API fairly recently, and I have simply used the > `stage1` compiler. An excerpt from my little code snippet: > > ``` > -- This is just the output of '_build/stage1/bin/ghc --print-libdir' > myGhcLibDir :: FilePath > myGhcLibDir = "./_build/stage1/lib" > > playground :: FilePath -> IO () > playground fn = do > res <- runGhc (Just myGhcLibDir) $ do > ... > ``` > > As you can see that's exactly what you are doing, modulo the fact I was > using the `stage1` (where _build is the default directory for Hadrian > builds). > > Hope this helps in some way! > > A. > > > > > On Fri, 24 Sept 2021 at 03:37, Ben Gamari <b...@smart-cactus.org> wrote: > > > Norman Ramsey <n...@cs.tufts.edu> writes: > > > > > I'm writing client code against the GHC API in HEAD (version 9.3), > > > using 9.0.1 as my bootstrap compiler. To make it possible to build > > > this code, I've set up cabal using > > > > > > cabal v1-configure \ > > > --package-db clear \ > > > --package-db $STAGE0/lib/package.conf.d/ # stage0 libraries > > > > > > In my Haskell code I'm invoking `runGhc (Just thelibdir)` where > > > > > > thelibir = "/home/nr/asterius/ghc/_build/stage0/lib" > > > > > > which is my `$STAGE0/lib`. > > > > > > Unfortunuately, when I launch my app, `setSessionDynFlags` panics. > > > The output, along with some diagnostic information about some dflags > > > that seemed relevant, looks like this: > > > > > > libdir = /home/nr/asterius/ghc/_build/stage0/lib > > > includePaths = IncludeSpecs {includePathsQuote = [], > > includePathsGlobal = [], includePathsQuoteImplicit = []} > > > libraryPaths = [] > > > packageDBFlags = [] > > > packageEnv = Nothing > > > panic! (the 'impossible' happened) > > > GHC version 9.3.20210918: > > > GHC couldn't find the RTS constants (#define HS_CONSTANTS ") > > in /home/nr/.ghcup/ghc/9.0.1/lib/ghc-9.0.1/include/DerivedConstants.h: the > > RTS package you are trying to use is perhaps for another GHC version(e.g. > > you are using the wrong package database) or the package database is > > broken. > > > > > > CallStack (from HasCallStack): > > > error, called at > > _build/stage0/compiler/build/GHC/Platform/Constants.hs:143:20 in > > ghc:GHC.Platform.Constants > > > > > > Please report this as a GHC bug: > > https://www.haskell.org/ghc/reportabug > > > > > > I'm a little suprprised that my app is hunting for 9.3 information in > > > the tree that belongs to the bootstrap compiler. > > > > > I suspect that the stages are getting mixed up here. Would it be > > possible to post a full reproducer? I'd be happy to investigate further, > > but without being able to reproduce locally it's a bit hard to say > > anything useful. My recollection is that we look for DerivedConstants.h > > in the usual include paths, so there are many ways in which things could > > go wrong. > > > > Cheers, > > > > - Ben > > _______________________________________________ > > ghc-devs mailing list > > ghc-devs@haskell.org > > http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs > > > _______________________________________________ ghc-devs mailing list ghc-devs@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs