# marmot run (/docs/commands/run)

<!-- Generated by scripts/gen.mjs from `marmot run --help` and scripts/commands.mjs. Do not edit by hand. -->

Build the program in a temporary directory and run it with the arguments that follow the package or the .go files. Its exit status is marmot's.

```text title="Usage"
marmot run package|files... [arguments] [flags]
```

## Examples [#examples]

```sh
marmot run main.go
marmot run ./cmd/app -port 8080
```

The program is built in a temporary directory with the same flags as `marmot build`, then
run with the arguments that follow the package or the files. Build errors are shown the same
way as for `marmot build`.

A panic in the program is reported in the same three modes as build errors: on a terminal the
report lists the program's frames with their source lines and folds library frames; in JSON
mode it is one `panic` object (code [M0020](/docs/diagnostics/codes/m0020)). See
[Runtime errors](/docs/diagnostics#runtime-errors).

## Flags [#flags]

Flags take one dash or two: `-release` and `--release` are the same.

| Flag | Meaning |
| --- | --- |
| `-O string` | optimization level: 0, 1, 2, 3, s, z (default 2, 3 with -release) |
| `-allocs` | report the allocation sites of the main module: heap or stack, and why (rebuilds without the object cache) |
| `-allocs-all` | like -allocs, for every package |
| `-color string` | color in human output: auto, always or never (NO_COLOR turns auto off) (default "auto") |
| `-dialect string` | MLIR dialect level: llvm or go (default: go with -release, llvm otherwise; $MARMOT_DIALECT overrides) |
| `-emit string` | output kind: mlir, llvm, obj, exe (default "exe") |
| `-gc string` | garbage collector: precise or none (default "precise") |
| `-json` | machine readable output: JSON Lines on stderr (also $MARMOT_OUTPUT=json, and the default under coding agents) |
| `-nocache` | do not use the object cache |
| `-o string` | output file |
| `-pgo string` | profile guided optimization with this indexed profile (llvm-profdata merge -o FILE *.profraw) |
| `-pgo-gen` | build an instrumented binary that writes marmot-<id>.profraw next to itself |
| `-release` | release build: whole program optimization, -O3, all specializations (default from $MARMOT_RELEASE=1) |
| `-s` | omit the pc table (tracebacks without file:line) |
| `-tags string` | comma separated build tags |
| `-target string` | target triple (default: host) |
| `-trace string` | traceback detail of -release builds: full keeps the inlined frames of each call site apart (as dev builds do) |
| `-v` | print progress and timing |
| `-work` | print and keep the temporary work directory |
| `-x` | print the commands run |

## Full help [#full-help]

```text title="marmot run --help"
Build the program in a temporary directory and run it with the arguments that follow the package or the .go files. Its exit status is marmot's.

Usage:
  marmot run package|files... [arguments] [flags]

Examples:
marmot run main.go
marmot run ./cmd/app -port 8080

Flags:
      --O string         optimization level: 0, 1, 2, 3, s, z (default 2, 3 with -release)
      --allocs           report the allocation sites of the main module: heap or stack, and why (rebuilds without the object cache)
      --allocs-all       like -allocs, for every package
      --color string     color in human output: auto, always or never (NO_COLOR turns auto off) (default "auto")
      --dialect string   MLIR dialect level: llvm or go (default: go with -release, llvm otherwise; $MARMOT_DIALECT overrides)
      --emit string      output kind: mlir, llvm, obj, exe (default "exe")
      --gc string        garbage collector: precise or none (default "precise")
  -h, --help             help for run
      --json             machine readable output: JSON Lines on stderr (also $MARMOT_OUTPUT=json, and the default under coding agents)
      --nocache          do not use the object cache
      --o string         output file
      --pgo string       profile guided optimization with this indexed profile (llvm-profdata merge -o FILE *.profraw)
      --pgo-gen          build an instrumented binary that writes marmot-<id>.profraw next to itself
      --release          release build: whole program optimization, -O3, all specializations (default from $MARMOT_RELEASE=1)
      --s                omit the pc table (tracebacks without file:line)
      --tags string      comma separated build tags
      --target string    target triple (default: host)
      --trace string     traceback detail of -release builds: full keeps the inlined frames of each call site apart (as dev builds do)
      --v                print progress and timing
      --work             print and keep the temporary work directory
      --x                print the commands run
```