Repository navigation
Conversation
Owner
|
I just pushed a gitit.cabal change that means we only support ghc >= 9.6. That should simplify things. |
gitit now requires ghc >= 9.6, so the conditional code for older GHC versions is no longer needed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
|
This is confirmed to work on CachyOS binaries with GHC 9.6.7: claferwiki plugin works in it (built as a dynamic library and cabal installed). During the build, gitit loads the plugin (Loading plugin 'Network.Gitit.Plugin.ClaferWiki'... then Finished loading plugins.), and a Clafer code block sent to /_preview comes back rendered by claferwiki. Works on Ubuntu (static linking) as before. Ready to be merged. |
Owner
|
I removed almost all the CPP from gitit. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Supersedes #582.
This is a port of PR #582 on top of the current
master. On Arch/CachyOS, all Haskell packages are dynamic-only. Users can conveniently just installpacman -S gititbut this version does not allow them loading plugins.Tested on CachyOS, GHC 9.6.7, and claferwiki plugin compiled dynamically and installed into system.
Here's an explanation by Claude
How the gitit plugin-loading fix works
Background: build modes and the in-process loader
GHC can compile Haskell code in different build modes (GHC calls them "ways"). The two that matter here are the static mode, which produces
.hiinterface files and.o/.aobjects, and the dynamic mode, which produces.dyn_hiand.dyn_o/.so. The files of each mode only work with that mode.gitit loads a plugin by starting a GHC session inside its own process. It runs
runGhc, sets the compiler flags, and then compiles and links the plugin module into the running program. The code that's loaded has to match how gitit itself was linked: a dynamically linked gitit can only load dynamic code.On Arch/CachyOS everything is dynamic. The system Haskell packages ship only
.dyn_hiand.sofiles, and yourcabal.config(-dynamic,library-vanilla: False) builds dynamic-only too.Why loading failed
gitit's original code does:
dflags <- getSessionDynFlags setSessionDynFlags dflagsThat gives the session GHC's default flags, which caused two problems:
.hifiles, which don't exist, so you got "Could not find modulePrelude… There are files missing in thebase-4.18.3.0package".ghcprogram readsGHC_ENVIRONMENTand~/.ghc/<arch>-<ver>/environments/defaultinparseDynamicFlags, which only it calls.setSessionDynFlagsdoesn't read them. So packages added withcabal install --libare invisible, and you got "Could not find moduleNetwork.Gitit.Plugin.ClaferWiki".Why the PR wasn't enough
PR #582 sets
Opt_BuildDynamicToo(-dynamic-too). That flag makes GHC write dynamic output alongside the static output when it compiles, but the static mode stays primary. GHC still reads.hifiles and still expects static dependencies, so on a dynamic-only system it fails the same way. It might help when a plugin is compiled from a source file, but here the plugin is an installed package, and your first run of the PR-only build still failed onPrelude.The fix: three changes in
loadPlugin, used on GHC ≥ 9.4interpretPackageEnvreads the environment file the wayghcdoes. It honoursGHC_ENVIRONMENT, or finds the default environment, and adds its package databases andpackage-identries to the session. That's what letscabal install --lib allmake plugins loadable.Expose
gitit. An environment file exposes only the packages it lists. Once (1) is in place, gitit itself becomes hidden, which caused your last error: "member of the hidden packagegitit-0.16.0.2". Every plugin importsNetwork.Gitit.Interface, so gitit now always adds the equivalent of-package gititto the session.Dynamic mode when the host is dynamic.
hostIsDynamicasks the running runtime whether gitit itself is dynamically linked. If it is, the session switches its target mode toWayDyn, the equivalent of-dynamic. GHC then looks for.dyn_hifiles and links.sofiles, which can be loaded into the running program.On GHC versions older than 9.4 the code is unchanged, because several of these APIs moved or changed signature in earlier releases (to be exact,
interpretPackageEnvchanged since GHC 9.2 andhostIsDynamicis only available on GHC >= 9.2) .Also, the original PR #582 did not completely solve the issue on fully dynamic systems like Arch/CachyOS, so that fix is not ported here for GHCs <= 9.2.