+ installSignalHandlers
+
+ argv <- getArgs
+ let (minusB_args, argv') = partition (prefixMatch "-B") argv
+ top_dir <- initSysTools minusB_args
+
+ -- Process all the other arguments, and get the source files
+ non_static <- processStaticFlags argv'
+ mode <- readIORef v_GhcMode
+
+ -- -O and --interactive are not a good combination
+ -- ditto with any kind of way selection
+ orig_ways <- readIORef v_Ways
+ when (notNull orig_ways && isInterpretiveMode mode) $
+ do throwDyn (UsageError
+ "--interactive can't be used with -prof, -ticky, -unreg or -smp.")
+
+ -- Find the build tag, and re-process the build-specific options.
+ -- Also add in flags for unregisterised compilation, if
+ -- GhcUnregisterised=YES.
+ way_opts <- findBuildTag
+ let unreg_opts | cGhcUnregisterised == "YES" = unregFlags
+ | otherwise = []
+ extra_non_static <- processStaticFlags (unreg_opts ++ way_opts)
+
+ -- Give the static flags to hsc
+ static_opts <- buildStaticHscOpts
+ writeIORef v_Static_hsc_opts static_opts
+
+ -- build the default DynFlags (these may be adjusted on a per
+ -- module basis by OPTIONS pragmas and settings in the interpreter).
+
+ stg_todo <- buildStgToDo
+
+ -- set the "global" HscTarget. The HscTarget can be further adjusted on a module
+ -- by module basis, using only the -fvia-C and -fasm flags. If the global
+ -- HscTarget is not HscC or HscAsm, -fvia-C and -fasm have no effect.
+ let dflags0 = defaultDynFlags
+ let lang = case mode of
+ DoInteractive -> HscInterpreted
+ DoEval _ -> HscInterpreted
+ _other -> hscTarget dflags0
+
+ let dflags1 = dflags0{ stgToDo = stg_todo,
+ hscTarget = lang,
+ -- leave out hscOutName for now
+ hscOutName = panic "Main.main:hscOutName not set",
+ verbosity = case mode of
+ DoEval _ -> 0
+ _other -> 1
+ }
+
+ -- The rest of the arguments are "dynamic"
+ -- Leftover ones are presumably files
+ (dflags2, fileish_args) <- processDynamicFlags
+ (extra_non_static ++ non_static) dflags1
+
+ -- make sure we clean up after ourselves