ghc-toolchain- Utility for managing GHC target toolchains
Safe HaskellNone




data Program Source #




addFlagIfNew :: String -> Program -> Program Source #

Prepends a flag to a program's flags if the flag is not in the existing flags.

Running programs

readProgram :: Program -> [String] -> M (ExitCode, String, String) Source #

Runs a program with a list of arguments and returns the exit code and the stdout and stderr output

readProgramStdout :: Program -> [String] -> M String Source #

Runs a program with a list of arguments and returns the stdout output, ignoring the exit code.

Finding Programs

data ProgOpt Source #

Program specifier from the command-line.



programFromOpt Source #


:: ProgOpt 
-> FilePath

Program path to default to

-> [String]

Program flags to default to

-> Program 

Make a Program from user specified program options (ProgOpt), defaulting to the given path and flags if unspecified in the ProgOpt.

findProgram Source #


:: String 
-> ProgOpt

path provided by user

-> [FilePath]

candidate names

-> M Program 

Tries to find the user specified program by path or tries to look for one in the given list of candidates.

If the ProgOpt program flags are unspecified the program will have an empty list of flags.

Compiler programs

compile Source #


:: FilePath

input extension

-> [String]

extra flags

-> Lens compiler Program 
-> compiler 
-> FilePath

output path

-> String


-> M () 

Compile a program with a given compiler.

The compiler must * Take the program path as a positional argument * Accept -o to specify output path

supportsTarget Source #


:: Lens compiler Program 
-> (compiler -> M ())

Action to check if compiler with --target flag works

-> String

The LLVM target to use if cc supports --target

-> compiler

The compiler to check --target support for

-> M compiler

Return compiler with --target flag if supported

Does compiler program support the --target=triple option? If so, we should pass it whenever possible to avoid ambiguity and potential compile-time errors (e.g. see #20162).