Skip to content

build/cargo: touching unrelated file triggers unnecessary re-link #6640

@BenWiederhake

Description

@BenWiederhake

There seems to be a problem in our incremental build system. I discovered this when comparing uutils against GNU coreutils in a semi-automated way, and my script wrote to some new, unrelated files, because surely that won't impact uutils, right?

Turns out, cargo re-links the coreutils binary whenever a new file pops up:

$ cargo +stable build --all-features
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.14s
$ cargo +stable build --all-features
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.14s
$ cargo +stable build --all-features
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.17s
$ cargo +stable build --all-features
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.14s
$ touch completely_unrelated
$ cargo +stable build --all-features # ?!
   Compiling coreutils v0.0.27 (/home/user/workspace/coreutils-rs)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 2.74s
$ cargo +stable build --all-features
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.14s
$ cargo +stable build --all-features
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.14s
$ cargo +stable build --all-features
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.17s

Notice the extra 2.6 seconds in the middle? that makes everything quite slow. I'm not sure where the bug lives, or even whether it's uutil's fault at all (and perhaps a missed optimization in cargo?), but let's start here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedrustPull requests that update Rust code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions