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

gh-122584: Import mimalloc headers in a C++ context #122587

Merged
merged 1 commit into from
Aug 15, 2024

Conversation

mdboom
Copy link
Contributor

@mdboom mdboom commented Aug 1, 2024

The vendored mimalloc headers are designed to be used in a C++ context if imported from C++. Therefore, we should switch the context back to C++ when using a C++ compiler here. This seems like the most future-proof fix, because otherwise we would need to be careful what context we import pycore_mimalloc.h from.

@colesbury
Copy link
Contributor

colesbury commented Aug 1, 2024

This seems like an okay workaround , but I think the underlying problems is that we really shouldn't be including headers under an extern "C". I've raised this issue before:

It can (and has) caused problems with system headers too.

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice workaround.

I tried modifying the 123 header files in Include/internal/ to move #include outside extern "C" { ... }. It's a lot of work, it will be hard to maintain in the future, I don't think that it's worth it.

@cdce8p
Copy link
Contributor

cdce8p commented Aug 12, 2024

What's the status here? This would also resolve one of the remaining issues with making mypyc compatible with 3.13. Would be great if it could be included in 3.13.0rc2. #121489 (comment)

@mdboom mdboom merged commit 1dad23e into python:main Aug 15, 2024
40 checks passed
@miss-islington-app
Copy link

Thanks @mdboom for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Aug 15, 2024
@bedevere-app
Copy link

bedevere-app bot commented Aug 15, 2024

GH-123035 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Aug 15, 2024
hauntsaninja pushed a commit that referenced this pull request Aug 16, 2024
#123035)

gh-122584: Import mimalloc headers in a C++ context (GH-122587)
(cherry picked from commit 1dad23e)

Co-authored-by: Michael Droettboom <[email protected]>
blhsing pushed a commit to blhsing/cpython that referenced this pull request Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants