diff --git a/ghc/compiler/basicTypes/Module.lhs b/ghc/compiler/basicTypes/Module.lhs
index ead105af48e81805b883ea4a7eb170b1710b43af..38a36091cb7a505b42b530a8bc42f7c05b7fb248 100644
--- a/ghc/compiler/basicTypes/Module.lhs
+++ b/ghc/compiler/basicTypes/Module.lhs
@@ -194,8 +194,14 @@ mkModule = Module
 mkVanillaModule :: ModuleName -> Module
 mkVanillaModule name = Module name UserMod dell
  where
-  dell | opt_Static || opt_CompilingPrelude = NotDll
-       | otherwise		 	    = Dll
+  main_mod = mkSrcModuleFS SLIT("Main")
+
+   -- Main can never be in a DLL - need this
+   -- special case in order to correctly
+   -- compile PrelMain
+  dell | opt_Static || opt_CompilingPrelude || 
+         name == main_mod = NotDll
+       | otherwise	  = Dll
 
 
 mkThisModule :: ModuleName -> Module	-- The module being comiled