Stdlib crates dependencies and direct usage

I wonder what happens if I mix usage of HashMap from stdlib and HashMap from hashbrown. Let's suppose hashbrown has the same version as stdlib dependency and as direct dependency to my program. What happens with my program, two hashbrown would be linked or one?

If two, can LTO remove duplicate function with different names (on Linux with LLVM linker) ?

Note that basically every crates-io std dep has a special dep-of-std cfg that changes a minor bit of how it compiles to handle peculiarities of being built as part of std. As such, the crate will have a deliberately different crate disambiguation hash than anything you use from crates-io and potentially even some code changes (e.g. hashbrown inlines more aggressively by default from crates-io than as part of std).


LLVM's MergeFunctions can remove duplicate functions even if they come from completely different, independent sources! But as with any optimization, there's no guarantee about this happening.


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.