Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cargo recompiling all dependencies when building for aarch64-apple-ios-sim #11553

Open
K-dizzled opened this issue Jan 8, 2023 · 5 comments
Open
Labels
C-bug Category: bug S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request.

Comments

@K-dizzled
Copy link

Problem

If you try to make a cargo build --target aarch64-apple-ios-sim or cargo build --target aarch64-apple-ios, then make a subtle change in the code, then rebuild it, cargo recompiles all the dependencies from scratch as you were doing cargo clean.

Steps

No response

Possible Solution(s)

No response

Notes

No response

Version

No response

@K-dizzled K-dizzled added the C-bug Category: bug label Jan 8, 2023
@weihanglo
Copy link
Member

I am sorry to hear you bumping into this.

However, due to lack of a minimal set of steps to reproduce, and not providing any version and environment information, it's hard to examinate and proceed. There is an FAQ section for checking how a recompile happened. It might be helpful.

@weihanglo weihanglo added the S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request. label Jan 8, 2023
@K-dizzled
Copy link
Author

I am sorry to hear you bumping into this.

However, due to lack of a minimal set of steps to reproduce, and not providing any version and environment information, it's hard to examinate and proceed. There is an FAQ section for checking how a recompile happened. It might be helpful.

I am sorry for a poor problem description. At first I was mistaking about the problem origin and about what was happening. Now I have a minimal reproducible example:
Taken the simplest cargo project with at least one dependency, if you:

  1. Build it using cargo build --target aarch64-apple-ios-sim
  2. Make cargo check
  3. Build it again using cargo build --target aarch64-apple-ios-sim

Cargo will recompile all the dependencies even tho nothing has changed.

Versions:

  • cargo 1.66.0

@weihanglo
Copy link
Member

Sorry. I had a hard time reproducing. Here are the logs from me.

click to expand
$ cargo +stable build --target aarch64-apple-ios-sim -v
    Updating crates.io index
   Compiling libc v0.2.139
   Compiling cfg-if v1.0.0
   Compiling ppv-lite86 v0.2.17
     Running `rustc --crate-name build_script_build /home/user/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/libc-0.2.139/build.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C metadata=84386ee5c872ee15 -C extra-filename=-84386ee5c872ee15 --out-dir /home/user/cargo-bug-min-repr-example/target/debug/build/libc-84386ee5c872ee15 -L dependency=/home/user/cargo-bug-min-repr-example/target/debug/deps --cap-lints allow`
     Running `rustc --crate-name cfg_if --edition=2018 /home/user/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/cfg-if-1.0.0/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C metadata=032a5d4f76cf6059 -C extra-filename=-032a5d4f76cf6059 --out-dir /home/user/cargo-bug-min-repr-example/target/aarch64-apple-ios-sim/debug/deps --target aarch64-apple-ios-sim -L dependency=/home/user/cargo-bug-min-repr-example/target/aarch64-apple-ios-sim/debug/deps -L dependency=/home/user/cargo-bug-min-repr-example/target/debug/deps --cap-lints allow`
     Running `rustc --crate-name ppv_lite86 --edition=2018 /home/user/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/ppv-lite86-0.2.17/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 --cfg 'feature="simd"' --cfg 'feature="std"' -C metadata=0ca58dd0a1af9b31 -C extra-filename=-0ca58dd0a1af9b31 --out-dir /home/user/cargo-bug-min-repr-example/target/aarch64-apple-ios-sim/debug/deps --target aarch64-apple-ios-sim -L dependency=/home/user/cargo-bug-min-repr-example/target/aarch64-apple-ios-sim/debug/deps -L dependency=/home/user/cargo-bug-min-repr-example/target/debug/deps --cap-lints allow`
     Running `/home/user/cargo-bug-min-repr-example/target/debug/build/libc-84386ee5c872ee15/build-script-build`
     Running `rustc --crate-name libc /home/user/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/libc-0.2.139/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C metadata=0016f68fe78a65bf -C extra-filename=-0016f68fe78a65bf --out-dir /home/user/cargo-bug-min-repr-example/target/aarch64-apple-ios-sim/debug/deps --target aarch64-apple-ios-sim -L dependency=/home/user/cargo-bug-min-repr-example/target/aarch64-apple-ios-sim/debug/deps -L dependency=/home/user/cargo-bug-min-repr-example/target/debug/deps --cap-lints allow --cfg freebsd11 --cfg libc_priv_mod_use --cfg libc_union --cfg libc_const_size_of --cfg libc_align --cfg libc_int128 --cfg libc_core_cvoid --cfg libc_packedN --cfg libc_cfg_target_vendor --cfg libc_non_exhaustive --cfg libc_ptr_addr_of --cfg libc_underscore_const_names --cfg libc_const_extern_fn`
   Compiling getrandom v0.2.8
     Running `rustc --crate-name getrandom --edition=2018 /home/user/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/getrandom-0.2.8/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 --cfg 'feature="std"' -C metadata=9089169fb8c5ac01 -C extra-filename=-9089169fb8c5ac01 --out-dir /home/user/cargo-bug-min-repr-example/target/aarch64-apple-ios-sim/debug/deps --target aarch64-apple-ios-sim -L dependency=/home/user/cargo-bug-min-repr-example/target/aarch64-apple-ios-sim/debug/deps -L dependency=/home/user/cargo-bug-min-repr-example/target/debug/deps --extern cfg_if=/home/user/cargo-bug-min-repr-example/target/aarch64-apple-ios-sim/debug/deps/libcfg_if-032a5d4f76cf6059.rmeta --extern libc=/home/user/cargo-bug-min-repr-example/target/aarch64-apple-ios-sim/debug/deps/liblibc-0016f68fe78a65bf.rmeta --cap-lints allow`
   Compiling rand_core v0.6.4
     Running `rustc --crate-name rand_core --edition=2018 /home/user/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/rand_core-0.6.4/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 --cfg 'feature="alloc"' --cfg 'feature="getrandom"' --cfg 'feature="std"' -C metadata=dcde00aaec906106 -C extra-filename=-dcde00aaec906106 --out-dir /home/user/cargo-bug-min-repr-example/target/aarch64-apple-ios-sim/debug/deps --target aarch64-apple-ios-sim -L dependency=/home/user/cargo-bug-min-repr-example/target/aarch64-apple-ios-sim/debug/deps -L dependency=/home/user/cargo-bug-min-repr-example/target/debug/deps --extern getrandom=/home/user/cargo-bug-min-repr-example/target/aarch64-apple-i
os-sim/debug/deps/libgetrandom-9089169fb8c5ac01.rmeta --cap-lints allow`
   Compiling rand_chacha v0.3.1
     Running `rustc --crate-name rand_chacha --edition=2018 /home/user/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/rand_chacha-0.3.1/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 --cfg 'feature="std"' -C metadata=c9606b8cc7b4277c -C extra-filename=-c9606b8cc7b4277c --out-dir /home/user/cargo-bug-min-repr-example/target/aarch64-apple-ios-sim/debug/deps --target aarch64-apple-ios-sim -L dependency=/home/user/cargo-bug-min-repr-example/target/aarch64-apple-ios-sim/debug/deps -L dependency=/home/user/cargo-bug-min-repr-example/target/debug/deps --extern ppv_lite86=/home/user/cargo-bug-min-repr-example/target/aarch64-apple-ios-sim/debug/deps/libppv_lite86-0ca58dd0a1af9b31.rmeta --extern rand_core=/home/user/cargo-bug-min-repr-example/target/aarch64-apple-ios-sim/debug/deps/librand_core-dcde00aaec906106.rmeta --cap-lints allow`
   Compiling rand v0.8.5
     Running `rustc --crate-name rand --edition=2018 /home/user/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/rand-0.8.5/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 --cfg 'feature="alloc"' --cfg 'feature="default"' --cfg 'feature="getrandom"' --cfg 'feature="libc"' --cfg 'feature="rand_chacha"' --cfg 'feature="std"' --cfg 'feature="std_rng"' -C metadata=af96ba8195ea34a8 -C extra-filename=-af96ba8195ea34a8 --out-dir /home/user/cargo-bug-min-repr-example/target/aarch64-apple-ios-sim/debug/deps --target aarch64-apple-ios-sim -L dependency=/home/user/cargo-bug-min-repr-example/target/aarch64-apple-ios-sim/debug/deps -L dependency=/home/user/cargo-bug-min-repr-example/target/debug/deps --extern libc=/home/user/cargo-bug-min-repr-example/target/aarch64-apple-ios-sim/debug/deps/liblibc-0016f68fe78a65bf.rmeta --extern rand_chacha=/home/user/cargo-bug-min-repr-example/target/aarch64-apple-ios-sim/debug/deps/librand_chacha-c9606b8cc7b4277c.rmeta --extern rand_core=/home/user/cargo-bug-min-repr-example/target/aarch64-apple-ios-sim/debug/deps/librand_core-dcde00aaec906106.rmeta --cap-lints allow`
   Compiling mre-bug-ios v0.1.0 (/home/user/cargo-bug-min-repr-example)
     Running `rustc --crate-name mre_bug_ios --edition=2021 src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C metadata=823d07d57f364768 -C extra-filename=-823d07d57f364768 --out-dir /home/user/cargo-bug-min-repr-example/target/aarch64-apple-ios-sim/debug/deps --target aarch64-apple-ios-sim -C incremental=/home/user/cargo-bug-min-repr-example/target/aarch64-apple-ios-sim/debug/incremental -L dependency=/home/user/cargo-bug-min-repr-example/target/aarch64-apple-ios-sim/debug/deps -L dependency=/home/user/cargo-bug-min-repr-example/target/debug/deps --extern rand=/home/user/cargo-bug-min-repr-example/target/aarch64-apple-ios-sim/debug/deps/librand-af96ba8195ea34a8.rlib`
    Finished dev [unoptimized + debuginfo] target(s) in 4.18s
$ cargo +stable check
   Compiling libc v0.2.139
    Checking cfg-if v1.0.0
    Checking ppv-lite86 v0.2.17
    Checking getrandom v0.2.8
    Checking rand_core v0.6.4
    Checking rand_chacha v0.3.1
    Checking rand v0.8.5
    Checking mre-bug-ios v0.1.0 (/home/user/cargo-bug-min-repr-example)
    Finished dev [unoptimized + debuginfo] target(s) in 0.96s
$ cargo +stable build --target aarch64-apple-ios-sim -v
       Fresh cfg-if v1.0.0
       Fresh ppv-lite86 v0.2.17
       Fresh libc v0.2.139
       Fresh getrandom v0.2.8
       Fresh rand_core v0.6.4
       Fresh rand_chacha v0.3.1
       Fresh rand v0.8.5
       Fresh mre-bug-ios v0.1.0 (/home/user/cargo-bug-min-repr-example)
    Finished dev [unoptimized + debuginfo] target(s) in 0.06s
Do you have anything special on your filesystem? Cargo generally depends on filesystem mtime to track changes. That is, if your filesystem does something on mtime (docker and some CI reset that), it won't work as expected. I kindly recommend following this guide to dig out the potential root cause. And with --verbose flag would be better. In combination, it may look like:

CARGO_LOG=cargo::core::compiler::fingerprint=info cargo build --target aarch64-apple-ios-sim

BTW, the cargo check in the middle should have nothing to do with the recompile, as they outputs artifacts to different directories. If it did affect, I'll be surprised 🤯.

@weihanglo
Copy link
Member

You could also try the current nightly Cargo with --verbose flag, which just introduces a brand new more readable rebuild detection messages by #11407 (comment) (thanks to @dnbln's effort!).

@K-dizzled
Copy link
Author

That's interesting, thank you for the ideas, I will try to investigate what's happening out there. There is nothing special about my filesystem. The logs during the second build tell that the build_script_build mtime changed and tho the libs shall be recompiled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request.
Projects
None yet
Development

No branches or pull requests

2 participants