needsTemplateHaskellOrQQ is not very precise
The idea of the
needsTemplateHaskellOrQQ query is to check if any of the modules in a module graph need Template Haskell then enable -dynamic-too if necessary. This is quite imprecise though as it will enable -dynamic-too for all modules in the module graph even if only one module uses template haskell, with multiple home units, this is obviously even worse.
With -fno-code we already have similar logic to enable code generation just for the modules which are dependeded on my TemplateHaskell modules so we should use that instead to also decide whether to enable
-dynamic-too rather than using this big hammer.