I am currently working in a workspace.
I added the -Zalways-encode-mir=yes
flag to the workspace via RUSTC_WORKSPACE_WRAPPER
The relevant cargo tree is as follows:
You can see that itertools
exists as a dependency of declare_
crate and as a dependency of the upper layer.
I now have some logic that needs to use itertools' mir, so I used the flag -Zalways-encode-mir=yes
But during the run, I found that the compilation command can be viewed in the form of cargo check --verbose
You can see that rustc compiled itertools
Running `/Users/.rustup/toolchains/nightly-2024-10-09-aarch64-apple-darwin/bin/rustc --crate-name itertools --edition=2018 /Users/.cargo/registry/src/index.crates.io-6f17d22bba15001f/itertools-0.12.1/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=251 --crate-type lib --emit=dep-info,metadata -C embed-bitcode=no -C debuginfo=2 -C split-debuginfo=unpacked --cfg 'feature="default"' --cfg 'feature="use_alloc"' --cfg 'feature="use_std"' --check-cfg 'cfg(docsrs)' --check-cfg 'cfg(feature, values("default", "use_alloc", "use_std"))' -C metadata=5d8738f53085f3e1 -C extra-filename=-5d8738f53085f3e1 --out-dir /Users/target/debug/deps -L dependency=/Users/target/debug/deps --extern either=/Users/target/debug/deps/libeither-f89113870db70678.rmeta --cap-lints allow -Zunstable-options -Zbinary-dep-depinfo -Z binary-dep-depinfo`
When compiling declare_ crate later, itertool's rlib is linked through extern and itertool's mir can be used. I want to ask why this is the case.
Running `/Users/.cargo/bin/driver /Users/rustup/toolchains/nightly-2024-10-09-aarch64-apple-darwin/bin/rustc --crate-name declare_ --edition=2021 declare_/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=251 --crate-type proc-macro --emit=dep-info,link -C prefer-dynamic -C embed-bitcode=no --warn=unexpected_cfgs --check-cfg 'cfg(linter)' --check-cfg 'cfg(docsrs)' --check-cfg 'cfg(feature, values("deny-warnings"))' -C metadata=ab9f8dbc86dd30c0 -C extra-filename=-ab9f8dbc86dd30c0 --out-dir /Users/target/debug/deps -C incremental=/Users/target/debug/incremental -L dependency=/Users/target/debug/deps --extern itertools=/Users/target/debug/deps/libitertools-f84262d9b5f18b81.rlib --extern quote=/Users/target/debug/deps/libquote-93aeff96ca748c11.rlib --extern syn=/Users/target/debug/deps/libsyn-7ac2b17260a27328.rlib --extern proc_macro -Zunstable-options -Zbinary-dep-depinfo -Z binary-dep-depinfo`
I have two guesses:
1、Since declare_crate added -Zalways-encode-mir=yes, itertools was recompiled, but --verbose was not reflected
2、rustc will automatically package mir when processing