Whenever you change the target, also make sure to set ghcLink to
something sensible.

HscNothing can be used to avoid generating any output, however, note
that:

This will not run the desugaring step, thus no warnings generated in
this step will be output. In particular, this includes warnings related
to pattern matching. You can run the desugarer manually using
GHC.desugarModule.

If a program uses Template Haskell the typechecker may try to run code
from an imported module. This will fail if no code has been generated
for this module. You can use GHC.needsTemplateHaskell to detect
whether this might be the case and choose to either switch to a
different target or avoid typechecking such modules. (The latter may
preferable for security reasons.)

The GhcMode tells us whether we're doing multi-module
compilation (controlled via the GHC API) or one-shot
(single-module) compilation. This makes a difference primarily to
the Finder: in one-shot mode we look for interface files for
imported modules, but in multi-module mode we look for source files
in order to check whether they need to be recompiled.

When invoking external tools as part of the compilation pipeline, we
pass these a sequence of options on the command-line. Rather than
just using a list of Strings, we use a type that allows us to distinguish
between filepaths and 'other stuff'. The reason for this is that
this type gives us a handle on transforming filenames, and filenames only,
to whatever format they're expected to be on a particular platform.

Parsing DynFlags

Parse dynamic flags from a list of command line arguments. Returns the
the parsed DynFlags, the left-over arguments, and a list of warnings.
Throws a UsageError if errors occurred during parsing (such as unknown
flags or missing arguments).