Skip to content
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

fix new/delete overrides #959

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

Noxybot
Copy link

@Noxybot Noxybot commented Nov 6, 2024

apparently, even if MI_USE_CXX is OFF, mimalloc still provides mangled definitions of new/delete operators. It causes inability to statically link mimaloc in our scenario, since we want to have our own overrides of new/delete functions.

apparently, even if MI_USE_CXX is OFF, mimalloc still provides mangled definitions of new/delete operators. It causes inability to statically link mimaloc in our scenario, since we want to have our own overrides of new/delete functions.
@res2k
Copy link
Contributor

res2k commented Nov 6, 2024

Uh, but wouldn't this change disable C++ new/delete overrides entirely when not compiling as C++?

The way MI_USE_CXX is described, and the fact that there are explicitly mangled symbols, suggests that "compiles as pure C, but provides C++ overrides" is a quite deliberately chosen scenario, and that those overrides are not supposed to be available only when MI_USE_CXX is enabled.
For one, I believe that, usually, C malloc/free and C++ new/delete are backed by the same allocator; so doing the same for overrides is probably the safe options.
And secondly, but more importantly, simply disabling the code when MI_USE_CXX is off will break any users that rely on the "built with C, overrides C++" behavior.

In other words: disabling the C++ overrides probably warrants a separate build option/preprocessor macro to check.

@Noxybot
Copy link
Author

Noxybot commented Nov 6, 2024

Uh, but wouldn't this change disable C++ new/delete overrides entirely when not compiling as C++?

Yes. But it was my anticipation from an option called MI_USE_CXX being set to OFF.

Why would we ever want to override global new/delete in C only code? It's C-only code, so those new/delete are not from C standard library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants