Skip to content

cargo check uplifts dylibs to artifact-dir when proc-macro depends on dylib #16305

@ranger-ross

Description

@ranger-ross

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.

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.

host: self.host || dep_for_host,

This causes Cargo to uplift the shared object by mistake in fn uplift_to()

if unit.mode != CompileMode::Build || file_type.flavor == FileFlavor::Rmeta {
return None;
}

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-layoutArea: target output directory layout, naming, and organizationC-bugCategory: bugCommand-checkS-needs-team-inputStatus: Needs input from team on whether/how to proceed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions