tikv / jemallocator

Rust allocator using jemalloc as a backend
Other
364 stars 62 forks source link

build.rs script is missing rerun-if-env-changed indicators #101

Open orlp opened 3 months ago

orlp commented 3 months ago

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.

BusyJay commented 3 months ago

Do you have a reproduce repo?

orlp commented 3 months ago

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.

BusyJay commented 3 months ago

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
orlp commented 3 months ago

Those are not the reproduction steps I mentioned.