clash-lang/clash-compiler

Circuit plugin is not picked up by Clash from the OPTIONS pragma

Opened this issue · 1 comments

See https://github.com/gergoerdi/clash-protocols-issue-93

I have this in src/Main.hs:

{-# OPTIONS -fplugin=Protocols.Plugin #-}

This is picked up by GHC when building simulations via Stack.

But when I run Clash via Clash.Main.defaultMain (see Build.hs in the repo), the plugin is not loaded.

Note that adding "-fplugin=Protocols.Plugin" to the Clash.Main.defaultMain invocation does work.

This a bug in clash.
It seems to ignore specifically the -fplugin flag in OPTIONS/OPTIONS_GHC pragmas.

Example:

{-# OPTIONS -fplugin=MissingPlugin -ddump-ds #-}
module Test2771 where
import Clash.Prelude
topEntity = False

This compiles fine in clash, and you see the effect of the -ddump-ds.
But it should be failing with an error Could not find module ‘MissingPlugin’.

We do some manipulation of the plugin flags, because we make sure the trio ghc-typelits-extra,ghc-typelits-known,ghc-typelits-natnormalise get loaded automatically.
There is likely a bug there, where we override the previous settings, instead of amending them.