build.rs script is missing rerun-if-env-changed indicators
The build.rs script for jemallocator should output cargo::rerun-if-env-changed=VAR for each variable that its behavior depends on. One example where this currently goes wrong is if you specify environment variables in the [env] section of .cargo/config.toml and then change them.
Do you have a reproduce repo?
Sure, just use jemalloc in an otherwise empty new binary crate Then add .cargo/config.toml with
[env]
JEMALLOC_SYS_WITH_MALLOC_CONF = "stats_print:false"
and cargo build the crate. Now edit `.cargo/config.toml to
[env]
JEMALLOC_SYS_WITH_MALLOC_CONF = "stats_print:true"
Now jemalloc should be re-built and stats printed when you do cargo run, but it doesn't.
Perhaps it's an issue about your setup or cargo itself, I can see jemalloc-sys does respect environment variable changes:
> env JEMALLOC_SYS_WITH_MALLOC_CONF="stats_print:false" cargo build
Compiling tikv-jemalloc-sys v0.6.0+5.3.0-1-ge13ca993e8ccb9ba9847cc330696e02839f328f7
Finished `dev` profile [unoptimized + debuginfo] target(s) in 29.56s
> env JEMALLOC_SYS_WITH_MALLOC_CONF="stats_print:true" cargo build
Compiling tikv-jemalloc-sys v0.6.0+5.3.0-1-ge13ca993e8ccb9ba9847cc330696e02839f328f7
Finished `dev` profile [unoptimized + debuginfo] target(s) in 29.68s
> env JEMALLOC_SYS_WITH_MALLOC_CONF="stats_print:true" cargo build
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.01s
Those are not the reproduction steps I mentioned.