# Zig Build: Run Step with no output but should only run if input changes

**URL:** <https://ziggit.dev/t/zig-build-run-step-with-no-output-but-should-only-run-if-input-changes/2090>\
**Category:** Help\
**Tags:** build-system\
**Created:** [October 31, 2023, 5:01pm UTC](https://ziggit.dev/t/zig-build-run-step-with-no-output-but-should-only-run-if-input-changes/2090 "2023-10-31T17:01:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![xerous](https://ziggit.dev/letter_avatar_proxy/v4/letter/x/f14d63/32.png) [@xerous](https://ziggit.dev/u/xerous)\
**Post date:** [October 31, 2023, 5:01pm UTC](https://ziggit.dev/t/zig-build-run-step-with-no-output-but-should-only-run-if-input-changes/2090/1 "2023-10-31T17:01:18Z")

</div>

I’m looking to run `size` on an ELF file only when it gets recompiled.

So far I’ve got

```zig
const elf: *Step.Compile;
// ...
const size_cmd = b.addSystemCommand(&.{"size"});
size_cmd.addArtifactArg(elf);

```

Of course Zig Build wants to see an output arg to determine that it doesn’t have side-effects and when the output needs to be regenerated.

The usual make/ninja hack of generating a dummy output file with psuedocode:

```zig
_ = size_cmd.addPrefixedOutputFileArg(" && touch ", "SIZED");

```

Technically doesn’t work because it’s not executing as a shell. I think I’d have to write a custom executable to interface between the Run Step, what it thinks its arguments are, the actual system command I want to run just once, and a dummy output for stale-checking.

Any ideas on how to idiomatically handle this use-case? I have a few other uses for this pattern of post-processing: scp binary to server when it changes, program MCU when firmware recompiles, etc.

---

<div class="post-metadata">

**Author:** ![xerous](https://ziggit.dev/letter_avatar_proxy/v4/letter/x/f14d63/32.png) [@xerous](https://ziggit.dev/u/xerous)\
**Post date:** [October 31, 2023, 6:07pm UTC](https://ziggit.dev/t/zig-build-run-step-with-no-output-but-should-only-run-if-input-changes/2090/2 "2023-10-31T18:07:51Z")

</div>

I’m observing that zig build makes heavy use of output caching. So adding an output file would likely not work eitehr as the dummy output may get cached and fail to trigger a post-processing run even after source-code changes (change source to older git commit whose binary has already been cached).

---

<div class="post-metadata">

**Author:** ![LucasSantos91](https://ziggit.dev/user_avatar/ziggit.dev/lucassantos91/32/440_2.png) [@LucasSantos91](https://ziggit.dev/u/LucasSantos91)\
**Post date:** [November 1, 2023, 10:39am UTC](https://ziggit.dev/t/zig-build-run-step-with-no-output-but-should-only-run-if-input-changes/2090/3 "2023-11-01T10:39:31Z")

</div>

I think you just need to set `size_cmd.has_side_effects = false;`.

---

<div class="post-metadata">

**Author:** ![kristoff](https://ziggit.dev/user_avatar/ziggit.dev/kristoff/32/9_2.png) [@kristoff](https://ziggit.dev/u/kristoff)\
**Post date:** [November 1, 2023, 11:15am UTC](https://ziggit.dev/t/zig-build-run-step-with-no-output-but-should-only-run-if-input-changes/2090/4 "2023-11-01T11:15:33Z")

</div>

my first guess would be that your size\_cmp task is not being run because nothing else depends on it, but I would need to see more of the build script to say that for sure
