How does cargo handle files?


How does cargo manage file paths? I have my own compiler and I do RUSTC=rlsl cargo build but cargo doesn’t pass me the file paths.

This is what it passes

rlsl - --crate-name ___ --print=file-names --target x86_64-unknown-linux-gnu --crate-type bin --crate-type rlib

but it misses


And why does it pass a single - directly after rlsl? If I do cargo build -vv it passes much more to rustc

rustc --crate-name rlsl_test src/ --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=c65831a2ec34ef7c -C extra-filename=-c65831a2ec34ef7c --out-dir /home/maik/projects/rlsl_test/target/debug/deps -L dependency=/home/maik/projects/rlsl_test/target/debug/deps

Why is that?


Cargo calls rustc multiple times. Before building any crates, it calls it with one or more --print arguments, to learn things like which prefix and suffix rustc uses for libraries. Cargo passes "-" to tell rustc to read source code from stdin instead of from a file. After this, it will call rustc again to build the actual source code.