-
Notifications
You must be signed in to change notification settings - Fork 432
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set up default allocator_library and global_allocator_library #2172
Set up default allocator_library and global_allocator_library #2172
Conversation
This makes things Just Work out of the box, while still giving people hooks to customise these if they need. In particular, this means we can centrally manage and update our default definition of these symbols, rather than require people to vendor them and keep their copies up to date as new versions of Rust come out. We provide this as a best-effort tool which we hope will be useful to people, and will attempt to maintain the C++ code included here, but make not guarantees about its universality or correctness. If you need more specific behaviours, you should set your own `allocator_library` and `global_allocator_library` attributes on your toolchains.
cc @keith as the original author of this code (thanks so much for putting it together and upstreaming it, by the way!), @UebelAndre as the most recent person to edit it. I don't know if there are major hazards from doing this, and would be interested to hear any - the two obvious ones that jump out are that this interface may not be stable (particularly across Rust versions) so we may struggle to maintain it, and that if people are using custom allocators it may not work (but they can suppy their own implementations in this case). (Also, supporting Windows seems hard, and I'm very happy to just punt on it for now) |
If I remember, previously the main point against that was that folks may need to have slightly different definitions based on their concrete combination of platform, C/C++ and rust available. I can see a lot of potential of having some defaults that "just work" for most users most of the time, however. This seems to fall just in this grey area. |
IIRC the reason why we didn't do this back when we initially added support for invoking the linker directly was because it is not officially supported. I'm fine with this PR, with one nit - I believe in the current form we always pass the |
I'm not sure about this... AFAICT, |
The allocator library is used both with |
thanks for doing this! this is what I was hoping for originally, can't remember why we didn't but there was some conversation about that in #1238 (comment) |
This makes C++ depending on Rust Just Work out of the box, while still giving people
hooks to customise these if they need.
In particular, this means we can centrally manage and update our default
definition of these symbols, rather than require people to vendor them
and keep their copies up to date as new versions of Rust come out.
We provide this as a best-effort tool which we hope will be useful to
people, and will attempt to maintain the C++ code included here, but
make not guarantees about its universality or correctness. If you need
more specific behaviours, you should set your own
allocator_library
and
global_allocator_library
attributes on your toolchains.