purpleprotocol / mimalloc_rust

A Rust wrapper over Microsoft's MiMalloc memory allocator
MIT License
506 stars 42 forks source link

This crate depends on libc, but doesn't declare that dependency #85

Closed petrochenkov closed 1 year ago

petrochenkov commented 1 year ago

It refers to atexit in particular.

Unless some other crate pulls libc accidentally you get a linking error like this when using this crate.

[INFO] [stdout]   = note: /usr/bin/ld: /opt/rustwide/target/debug/deps/liblibmimalloc_sys-1551225da21123ef.rlib(static.o): in function `mi_process_load':
[INFO] [stdout]           /opt/rustwide/cargo-home/registry/src/github.com-1ecc6299db9ec823/libmimalloc-sys-0.1.26/c_src/mimalloc/src/init.c:533: undefined reference to `atexit'
[INFO] [stdout]           collect2: error: ld returned 1 exit status

This was found when testing some linking order changes in rustc in https://github.com/rust-lang/rust/pull/102832#issuecomment-1279772306 (build failure - https://crater-reports.s3.amazonaws.com/pr-102832-1/try%230c94de7c1a8f4b82b92d562847c35f513f520c7a/reg/mimalloc-0.1.30/log.txt).

thomcc commented 1 year ago

Plausibly cc should link libc in when compiling C code (as it does for c++'s stdlib when compiling c++), but I suppose that might break some use cases.

Either way, a patch would probably be welcome here.