Conversation
roblabla
force-pushed
the
msvc-allow-overriding-malloc-conf
branch
from
August 12, 2024 13:18
49dd323 to
ebf0b39
Compare
roblabla
force-pushed
the
msvc-allow-overriding-malloc-conf
branch
3 times, most recently
from
August 20, 2024 09:15
d4c2bb8 to
94ccfef
Compare
Previously, the malloc_conf attribute wasn't as "weak" on MSVC as on other toolchain. While it is possible to override it in an OBJ file - in MSVC, every symbol coming from a LIB file can be overriden from an OBJ file - it isn't possible to override it from another lib file. This makes it impossible to override it from Rust, for instance, as it always generates libs and links them together, instead of linking the obj files directly. While the weak attribute is not supported by MSVC, it can be emulated using the /alternatename linker flag. This flag takes two symbols, and aliases the first symbol to the second if it isn't defined during linking. This ensures that the default value provided by jemalloc can be overridden from all contexts, whether the override comes from an obj or a lib, matching the behavior of gcc's weak attribute. This is supported by MSVC link.exe since time immemorial, and by lld-link since 3.7.0.
roblabla
force-pushed
the
msvc-allow-overriding-malloc-conf
branch
from
August 20, 2024 21:09
94ccfef to
fe12022
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently, the
malloc_confattribute isn't "weak" in the same way as on other toolchain. While it is possible to override it in an OBJ file, and the linker will favor the one from the obj file over the symbol from the lib, it isn't possible to override it from another lib file. This makes it impossible to override it from Rust, for instance, as it always generates libs and links them together.While the weak attribute is not supported by MSVC, it can be emulated using the /alternatename linker flag. This flag takes two symbols, and aliases the first symbol to the second if it isn't defined during linking. This ensures that the default value provided by jemalloc can be overridden from all contexts, whether the override comes from an obj or a lib.
This is supported by MSVC link.exe since time immemorial, and by lld-link since 3.7.0.