- ghc_mode <- getGhcMode
- real_exports <-
- case () of
- () | explicit_mod
- -> return exports
- | ghc_mode == Interactive
- -> return Nothing
- | otherwise
- -> do mainName <- lookupGlobalOccRn main_RDR_Unqual
- return (Just ([noLoc (IEVar main_RDR_Unqual)]))
- -- ToDo: the 'noLoc' here is unhelpful if 'main' turns
- -- out to be out of scope
-
- (exp_spec, avails) <- exports_from_avail real_exports rdr_env imports this_mod
-
- return (exp_spec, nubAvails avails) -- Combine families
+ ; dflags <- getDOpts
+ ; let real_exports
+ | explicit_mod = exports
+ | ghcLink dflags == LinkInMemory = Nothing
+ | otherwise = Just ([noLoc (IEVar main_RDR_Unqual)])
+ -- ToDo: the 'noLoc' here is unhelpful if 'main'
+ -- turns out to be out of scope
+
+ ; (rn_exports, avails) <- exports_from_avail real_exports rdr_env imports this_mod
+ ; let final_avails = nubAvails avails -- Combine families
+
+ ; return (tcg_env { tcg_exports = final_avails,
+ tcg_rn_exports = case tcg_rn_exports tcg_env of
+ Nothing -> Nothing
+ Just _ -> rn_exports,
+ tcg_dus = tcg_dus tcg_env `plusDU`
+ usesOnly (availsToNameSet final_avails) }) }
+