Skip to content

Enabling LTO causes spurious rebuilds #8750

@xobs

Description

@xobs

Problem
With LTO set to thin or fat, doing a cargo build --target riscv32imac-unknown-none-elf followed by cargo run followed by cargo build --target riscv32imac-unknown-none-elf causes Cargo to rebuild some packages even when nothing has changed.

Setting lto="off" prevents this behavior.

Steps

  1. Ensure you have the riscv32imac-unknown-none-elf toolchain
  2. Clone the xous-core repository
  3. Build an example such as shell
  4. Run a program
  5. Rebuild shell

This series of steps should demonstrate the problem:

rustup target add riscv32imac-unknown-none-elf
git clone https://github.com/betrusted-io/xous-core.git
cd xous-core
git checkout 6cb1aad93ca908bb394b9e7c13274b9f55d5aa8b
cargo build --release --target riscv32imac-unknown-none-elf -p shell
cargo run --release -p tools --bin copy-object
cargo build --release --target riscv32imac-unknown-none-elf -p shell # This will cause a partial rebuild
cargo run --release -p tools --bin copy-object # This will also cause a partial rebuild

Notes

If you modify Cargo.toml to remove lto="thin", or change it to lto="off", then the issue goes away.

Output of cargo version: cargo 1.46.0 (149022b 2020-07-17)

This may be due to the fact that cargo run and cargo build are targeting different architectures.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions