Repository navigation
Description
Problem
The driver can overwrite its own input while reporting success. Equivalent path spellings can truncate an IR file during a pass-through emit, and an explicit object output can replace Wave source with ELF bytes.
Starting points: src/cli.rs.
Reproduction
Tested at 6257ba3eb4b9f1ab6c247a920c6e0c4b5d699331 on Linux amd64 with LLVM 21.1.8 and a compiler built from that checkout. Build it with LLVM_SYS_211_PREFIX=/usr/lib64/llvm21 cargo build --locked --jobs 2.
Run only on these disposable files from the repository root:
python3 - <<'PYREPRO'
from pathlib import Path
import subprocess, tempfile
compiler = Path('target/debug/wavec').resolve()
with tempfile.TemporaryDirectory() as d:
p = Path(d)
ir = p / 'identity.ll'
ir.write_text('define i32 @main() { ret i32 0 }\n')
r = subprocess.run([str(compiler), 'build', 'identity.ll', '--emit=ir', '--out-dir', '.'], cwd=p)
print('IR:', r.returncode, ir.stat().st_size)
src = p / 'source.wave'
src.write_text('fun main() -> i32 { return 0; }\n')
r = subprocess.run([str(compiler), 'build', str(src), '--emit=obj', '-o', str(src)], cwd=p)
print('Wave:', r.returncode, src.read_bytes()[:4].hex())
PYREPROObserved: IR: 0 0 and Wave: 0 7f454c46. Both commands report success while destroying their input contents.
Scope
Validate input/output file identity before any writes. Preserve pass-through emits as safe no-ops when appropriate, and reject destructive source/output collisions. Check all planned artifacts, not only the final executable.
Difficulty: medium.
Completion criteria
- Preserve input bytes for relative/absolute aliases,
.components, symlinks and supported hard links. - Reject destructive collisions with an actionable CLI error before compilation or copying.
- Keep ordinary separate outputs and safe identity emits working on supported hosts.
Activity
Stabilize compiler inputs, target ABIs, and freestanding runtimes (#798)