-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
Spinning a new issue out of #16297
Issue
The root issue here is that when a bin crate depends on a proc-macro crate which depends on a dylib crate.
In this scenario, the proc-macro crate is compiled in CompileMode::Build since we need to execute the proc-macro bin.
cargo/src/cargo/core/compiler/unit_dependencies.rs
Lines 819 to 823 in 23f5b2b
| CompileMode::Check { .. } | CompileMode::Doc { .. } | CompileMode::Docscrape => { | |
| if target.for_host() { | |
| // Plugin and proc macro targets should be compiled like | |
| // normal. | |
| CompileMode::Build |
This causes the dylib crate to "inherit" the CompileMode::Build mode.
cargo/src/cargo/core/profiles.rs
Line 1192 in 23f5b2b
| host: self.host || dep_for_host, |
This causes Cargo to uplift the shared object by mistake in fn uplift_to()
cargo/src/cargo/core/compiler/build_runner/compilation_files.rs
Lines 428 to 430 in 23f5b2b
| if unit.mode != CompileMode::Build || file_type.flavor == FileFlavor::Rmeta { | |
| return None; | |
| } |
cargo/src/cargo/core/compiler/build_runner/compilation_files.rs
Lines 446 to 451 in 23f5b2b
| if !unit.target.is_bin() | |
| && !unit.target.is_custom_build() | |
| && file_type.crate_type != Some(CrateType::Dylib) | |
| && !self.roots.contains(unit) | |
| { | |
| return None; |
Expected Behavior
Cargo should not uplift any artifacts to the artifact-dir when running cargo check