News for hackers. Stuff that matters.
Re:Dioxus 0.6 – Crossplatform apps with Rust by IshKebab on Thursday December 12, 2024 @02:41AM (#42397090)
I also had an issue where Rust was recompiling dependencies unnecessarily. It turned out to be because rust-analyzer has one more level of `Bash` than VSCode's integrated terminal. My `.bashrc` was loading something unconditionally which meant if you nested bash sessions the PKG_CONFIG_PATH changed (duplicate entries).

I had OpenSSL as a dependency, and if `PKG_CONFIG_PATH` changes it rebuilds it (this is correct), which means if you make an edit to a file and save it, rust-analyzer would blow away the cache, then you build it on the command line and it blows it away again.

To test:

1. If you quit VSCode and do an incremental build is it still slow? 2. Try `CARGO_LOG=cargo::core::compiler::fingerprint=info cargo build` (took me a while to find that; there is a bug open to make it less stupidly hard to find).

That will print a load of info about why Cargo is rebuilding stuff. Note that it isn't really in a sensible order - the first message isn't necessarily the cause. The message about the environment variable changing was somewhere in the middle for me, so read the whole log.

Re:Dioxus 0.6 – Crossplatform apps with Rust by davidatbu on Thursday December 12, 2024 @07:31AM (#42398608)
Thanks for that very helpful tip! According to the output of that, no unnecessary recompilation is taking place.

I actually figured out the issue! It turns out, I had unquestioningly transplanted the following from the blog post in discussion, and that is the cause of all my issues:

    [profile.dev]
    opt-level = 1

    [profile.dev.package."*"]
    opt-level = 3
Removing that seems to give me an order (or two) of magnitude reduction in compile times.

(Worth noting: it was passing RUSTFLAGS=-Ztime-passes that made me look here because, apparently, `llvm_passes` was taking the majority of the time).