Output executable is not updated after changing build mode
### Description

When recompile code with changing build mode without changing code 3 times, third rebuild doesn't update the executable file.
Example code to see build mode.
testbuild.nim:
```nim
when defined(release):
  echo "This is release build"
elif defined(danger):
  echo "This is danger build"
else:
  echo "This is debug build"
```

### Nim Version

Nim Compiler Version 2.1.9 [Linux: amd64]
Compiled at 2024-08-24
Copyright (c) 2006-2024 by Andreas Rumpf

git hash: 4ef06a5cc56f6ef32b8ac1e7c11592597406486a
active boot switches: -d:release

### Current Output

```text
$ nim c -r -d:release testbuild.nim
...
This is release build
$ nim c -r -d:debug testbuild.nim
...
This is debug build
$ nim c -r -d:release testbuild.nim
...
This is debug build
```


### Expected Output

```text
$ nim c -r -d:release testbuild.nim
...
This is release build
$ nim c -r -d:debug testbuild.nim
...
This is debug build
$ nim c -r -d:release testbuild.nim
...
This is release build
```


### Possible Solution

Save output executable in the cache directory?

### Additional Information

_No response_