def ghc_cc_program_args(cc):
    """Returns the -pgm* flags required to override cc.

    Args:
      cc: string, path to the C compiler (cc_wrapper).

    Returns:
      list of string, GHC arguments.
    """
    args = [
        # GHC uses C compiler for assemly, linking and preprocessing as well.
        "-pgma",
        cc,
        "-pgmc",
        cc,
        "-pgml",
        cc,
        # Setting -pgm* flags explicitly has the unfortunate side effect
        # of resetting any program flags in the GHC settings file. So we
        # restore them here. See
        # https://ghc.haskell.org/trac/ghc/ticket/7929.
        #
        # Since GHC 8.8 the semantics of `-optP` have changed and these flags
        # are now also forwarded to `cc` via `-Xpreprocessor`, which breaks the
        # default flags `-E -undef -traditional`. GHC happens to word split the
        # argument to `-pgmP` which allows to pass these flags to `gcc` itself
        # as the preprocessor. See
        # https://gitlab.haskell.org/ghc/ghc/issues/17185#note_261599.
        "-pgmP",
        cc + " -E -undef -traditional",
        "-optc-fno-stack-protector",
    ]
    return args