Error trying to run mini-compile on nix: unknown package: rts
Closed this issue · 7 comments
Hi, I'm trying to use the examples and running into the following error.
[nix-shell:~/ghc-lib/examples/mini-compile]$ cabal v2-run -- mini-compile src/Main.hs
Up to date
mini-compile: <command line>: unknown package: rts
i rather suppose this is a nix issue and not related to this project specifically but honestly, i simply don't know. @cocreature, @aherrmann-da any ideas?
My guess would be that you might need to change the libdir here
ghc-lib/examples/mini-compile/src/Main.hs
Line 72 in 8525690
ghc --print-libdir
shows you on nix but I’m just guessing here.Actually, it does work on the test file. I'd been trying it against src/Main.hs
.
cabal v2-run -- mini-compile test/MiniCompileTest.hs
Still, the error is confusing but does it parse such a file correctly on other systems?
The test file deliberately has no external dependencies. src/Main.hs
does which is why you get this error. I don’t think that works on any system because those tests don’t configure the package databases. You generally cannot assume that you can share package databases between GHC and ghc-lib so unless you want to build a custom compiler (we originally built it for daml), I think you’re much better off using the ghc
API directly instead of using ghc-lib
. ghc-lib-parser
avoids that issue since parsing does not require a package database for dependencies.
I don't understand all of that right now, but I am looking to build a custom compiler - so I guess I'll dig into ghc-lib some more.
In that case, the Daml codebase might be helpful in particular https://github.com/digital-asset/daml/blob/a6da995ecb71004c34c88a4f4211543868cfde15/compiler/damlc/daml-opts/daml-opts/DA/Daml/Options.hs#L459 and the build steps for setting up our own equivalent of ghc-prim and base in https://github.com/digital-asset/daml/blob/main/compiler/damlc/pkg-db/util.bzl but be warned that this is a fairly involved process.
suggest close @dylant-da @garyverhaegen-da @akrmn @samuel-williams-da