Add -plugin-package-db for cross-compilation plugin support#172
Open
angerman wants to merge 3 commits intostable-ghc-9.14from
Open
Add -plugin-package-db for cross-compilation plugin support#172angerman wants to merge 3 commits intostable-ghc-9.14from
angerman wants to merge 3 commits intostable-ghc-9.14from
Conversation
05e1a0c to
7968d7c
Compare
When cross-compiling (host != target), plugins are built for the host
platform but GHC's UnitState contains target packages. Loading target
libraries into GHC's host process fails.
This adds a -plugin-package-db flag that points GHC at host-side
package databases. When specified, a separate UnitState is built from
these databases for plugin loading, while TH/bytecode continues to
use the target UnitState via the external interpreter.
Architecture:
No -plugin-package-db:
plugins use InternalInterp + existing target UnitState (unchanged)
With -plugin-package-db:
plugins use InternalInterp + host plugin UnitState (from host DBs)
TH/GHCi uses ExternalInterp + target UnitState (unchanged)
Changes:
- DynFlags: add pluginPackageDBFlags field
- Session: parse -plugin-package-db and -clear-plugin-package-dbs flags
- Unit/State: add initPluginUnitConfig using hostPlatformArchOS
- Driver/Env: add hscSetCurrentUnitState helper
- Runtime/Loader: extend withPluginInterp to swap UnitState when
plugin DBs are configured; replace checkExternalInterpreter with
withPluginInterp (creates local InternalInterp for plugin loading
alongside ExternalInterp for TH, see #14335)
T14335 previously tested that plugins + -fexternal-interpreter produced an error. With the new dual-interpreter architecture, plugins load via InternalInterp while TH uses the external interpreter, so this combination now succeeds. Change compile_fail → compile and remove the .stderr file.
The plugin now runs successfully with -fexternal-interpreter, producing its normal output (plugin passes queried, options, pass run). Add the expected stderr to match.
f838dbf to
e1ab30b
Compare
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.
Summary
-plugin-package-dband-clear-plugin-package-dbsflags so GHC can point at host-side package databases for plugin resolution during cross-compilation-plugin-package-dbis specified, builds a separateUnitStatefrom host package DBs usinghostPlatformArchOS, so plugins load host libraries while TH/bytecode continues using the targetUnitStatevia the external interpretercheckExternalInterpreter(which errored on-fexternal-interpreter+ plugins) withwithPluginInterp, which creates a localInternalInterpfor plugin loading alongside the external interpreter (#14335)Architecture
Files changed
compiler/GHC/Driver/DynFlags.hspluginPackageDBFlagsfield + recompilation checkcompiler/GHC/Driver/Session.hs-plugin-package-db,-clear-plugin-package-dbscompiler/GHC/Unit/State.hsinitPluginUnitConfig(host platform, plugin DBs)compiler/GHC/Driver/Env.hshscSetCurrentUnitStatehelpercompiler/GHC/Runtime/Loader.hswithPluginInterpto swap in hostUnitStateTest plan
-plugin-package-dbspecified)-fexternal-interpreter+ plugins (native): plugins load viaInternalInterp, TH via iserv — no regression-plugin-package-db /path/to/host/db: plugins resolve from host DB, load host libraries-fplugin-library: still works (independent path)