diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs
index b2f182a7d77b4765915e600747180bcd98f8b11c..3d34bdbcac676ce1a989b0bfce153aa7e77a7a7a 100644
--- a/compiler/main/DriverPipeline.hs
+++ b/compiler/main/DriverPipeline.hs
@@ -140,9 +140,10 @@ compileOne' m_tc_result mHscMessage
        mod_graph   = hsc_mod_graph hsc_env0
        needsTH     = any (xopt Opt_TemplateHaskell . ms_hspp_opts) mod_graph
        isDynWay    = any (== WayDyn) (ways dflags0)
+       isProfWay   = any (== WayProf) (ways dflags0)
    -- #8180 - when using TemplateHaskell, switch on -dynamic-too so
    -- the linker can correctly load the object files.
-   let dflags1 = if needsTH && dynamicGhc && not isDynWay
+   let dflags1 = if needsTH && dynamicGhc && not isDynWay && not isProfWay
                   then gopt_set dflags0 Opt_BuildDynamicToo
                   else dflags0