Runnig a compiler plugin over ALL code

Tillmann Vogt tillk.vogt at googlemail.com
Wed Feb 9 11:16:22 UTC 2022


Hi,

I am running a compiler plugin over hundreds of libraries to extract 
statistical data. I use the plugin like it is done here:

https://github.com/coot/ghc-tags-plugin

So I just have to add a cabal.project.local to a library with:


ignore-project: False

package test
     ghc-options: -package-db=/home/till/.cabal/store/ghc-8.10.7/package.db
                  -plugin-package=ghc-core-graph
                  -fplugin=GhcPlugins.Optimind

But unfortunately the plugin only runs over code that is used in the 
main function or that is used in other functions.

Example:

main = putStrLn (show (f 0))

f x = sin x

g = h + i

Then the compiler plugin only runs over f, h, i   but not not g (unused 
top level functions).

Can the plugin be forced to run over all code?

-Tillmann



More information about the ghc-devs mailing list