tikv / jemallocator

Rust allocator using jemalloc as a backend
Other
332 stars 52 forks source link

Allow per-target `JEMALLOC_OVERRIDE` env #90

Open Torrekie opened 2 weeks ago

Torrekie commented 2 weeks ago

While cross-compiling, setting JEMALLOC_OVERRIDE could cause failures due to incompatibilities between build and host platforms.

A better solution would be something like openssl-sys/build/find_normal.rs#L14 which has implementation at openssl-sys/build/main.rs#L41, which allows env definitions as a form of <TARGET_TRIPLE>_ENV (e.g. AARCH64_APPLE_DARWIN_MYENV

BusyJay commented 2 weeks ago

Can you explain more on what "failures" you met?

Torrekie commented 2 weeks ago

this can failure when cross compiling a binary incompatible scene like from Darwin to Linux while they uses completely different executable formats. As there is only one JEMALLOC_OVERRIDE can be defined, the linker will eventually complains about unsupported binary format

BusyJay commented 2 weeks ago

I don't get it. You should cross compile for one target at a time, right? So why not just specify the correct JEMALLOC_OVERRIDE for each compile?

Torrekie commented 2 weeks ago

rustc itself is using jemalllc-sys, while it compiles build and host toolchain at same time when host specified in config.toml, defining env per target is necessary because it was not able to compile host toolchain without compiling a build toolchain (even with rust compilers specified). I think that's why openssl-sys supported per target env, since it was also vendored by official rustc source

BusyJay commented 2 weeks ago

I see. Would you like to send a PR?