clash-lang / clash-compiler

Haskell to VHDL/Verilog/SystemVerilog compiler
https://clash-lang.org/
Other
1.42k stars 151 forks source link

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

Open gergoerdi opened 2 months ago

gergoerdi commented 2 months ago

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.

leonschoorl commented 2 months ago

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.