-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
BUG: C23 Compiler Flags Ignored or Obscured During NumPy Build via Meson Backend #28953
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
Comments
I don't have context about the meson build details you're raising, but I'm confused by this statement. Can you elaborate about what packages you're referring to and what specific issues they're dealing with? |
> why there is instability across most C based Python packages right now
that are hesitating to move to 3.13
I don't have context about the meson build details you're raising, but
I'm confused by this statement. Can you elaborate about what packages
you're referring to and what specific issues they're dealing with?
Hi there! That's a little bit of an assumption on my part on where
migration schedules are for packages. To my knowledge, in 3.13 underlying
access to underlying C data types has changed, in addition, Any Python
packages using GCC 14+ or derivative compilers may unknowingly default to
C23 and successfully build without a warning to use
"-fzero-init-padding-bits=union" which can lead to incorrect memory
padding. This would be more common of an issue in things like ndarray,
dtype, UFuncs, or objects utilizing Numpy memory.
…On Wed, May 14, 2025, 10:57 AM Nathan Goldbaum ***@***.***> wrote:
*ngoldbaum* left a comment (numpy/numpy#28953)
<#28953 (comment)>
why there is instability across most C based Python packages right now
that are hesitating to move to 3.13
I don't have context about the meson build details you're raising, but I'm
confused by this statement. Can you elaborate about what packages you're
referring to and what specific issues they're dealing with?
—
Reply to this email directly, view it on GitHub
<#28953 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALDZM3SBNNYATUNCZ5BIV2326NKUDAVCNFSM6AAAAAB5CC4YMKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDQOBQGU3DEMBUGY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Please look in the generated The rest of this issue is unfortunately a bit incoherent, there is essentially nothing that's correct about your assumptions or assertions. Do you have an actual problem, or if not what is your goal in opening it? If you see an ABI issue with NumPy, please provide a reproducible example. You can set |
Thanks for the quick follow-up.
To clarify, the concern isn’t about a specific runtime failure but about
compiler trust transparency — specifically, the absence of verifiable
propagation for critical C23 flags in vendored Meson environments, which
could impact ABI consistency.
NumPy 1.26.4 appears to have used GCC 14.2 at release. Shortly after, GCC
15.1 introduced a notable change to union initialization in C23:
{0} initializers for unions no longer clear the entire union. They only
zero the first member. To zero padding as well, use {} (C23/C++) or
-fzero-init-padding-bits=unions.
Reference: https://gcc.gnu.org/gcc-15/changes.html
If Meson (especially vendored) allows C23 defaults to activate without
enforcing that flag, builds compiled with GCC 15.1+ could inherit subtle
ABI shifts — particularly around padding or memory safety assumptions.
Python 3.13 already required changes in how low-level C types are accessed
due to similar shifts.
I fully understand the suggestion to inspect build.ninja or use meson
introspect. But that reinforces the issue: users can’t confirm flag
propagation without deep artifact inspection. There is no default assurance
or documentation path here — and that’s the gap.
...Python 3.13 already required changes in how low-level C types are
accessed due to similar shifts.
As additional context, Microsoft’s Visual Studio 2022 v17.14 — released the
same week — included compiler updates directly addressing C++23/C23
stability. This reinforces the point that ABI behavior and memory layout
are *active concerns* across compilers and build systems.
Reference:
https://learn.microsoft.com/en-us/visualstudio/releases/2022/release-notes#c-desktop-development
The goal is to highlight a class of emergent ABI risks caused by:
-
C23 behavior changes
-
Silent compiler defaults
-
Lack of transparent enforcement in abstracted build systems like Meson
If NumPy or downstream packages adopt C23 or expect future compatibility,
surfacing this flag — or formally documenting its position — could prevent
avoidable regressions.
Let me know if a reproducible example or sanitized C23 test build with
pointer offsets would be more appropriate for this thread. I'm happy to
provide it — the intent is to improve long-term resilience.
Best,BryteLite
…On Thu, May 15, 2025 at 3:22 AM Ralf Gommers ***@***.***> wrote:
*rgommers* left a comment (numpy/numpy#28953)
<#28953 (comment)>
This snippet confirms that flags are valid — but there is no indication
they are used #downstream. If meson.setup() is internally overridden, or
the build is controlled by #vendored modules, the standard user can neither
verify nor intervene at that layer.
#There is no mention of '-fzero-init-padding-bits=unions' anywhere.
Please look in the generated build.ninja file in the build directory,
which contains the exact compiler invocations. You can also use meson
introspect in the build directory (e.g. meson introspect --targets -i >
targets.json).
The rest of this issue is unfortunately a bit incoherent, there is
essentially nothing that's correct about your assumptions or assertions. Do
you have an actual problem, or if not what is your goal in opening it?
If you see an ABI issue with NumPy, please provide a reproducible example.
You can set CFLAGS with the flags you want and then invoke a build of
numpy, followed by an install of the built wheel and a test command that
shows the ABI is broken.
—
Reply to this email directly, view it on GitHub
<#28953 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALDZM3XUJWIT5EZCM6WHNPL26Q6EPAVCNFSM6AAAAAB5CC4YMKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDQOBSHAZDKMJYGE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
The NumPy referenced version would be 2.2.5. My apologies for the mix up.
Thank you,
BryteLite
|
Yes please. A runnable example demonstrating what you’re talking about makes this discussion much more |
There is no gap here, CLAGS gets honored always and if not it's a high-prio bug. If you want passed flags to show up more prominently in the build log, pass them as CLI flags to the build/install command. Example:
This is just how Meson works, and its logging is better designed than pretty much any other build system. This has nothing to do with the specific C23 flag or with whether we vendor Meson or not. |
Also note that we explicitly use |
That’s helpful. Thanks for confirming NumPy currently uses -std=c17 in its builds. That does explain why the new C23 union behavior isn't showing up in CI or release builds today. The motivation behind this issue is to raise visibility into what happens when that assumption no longer holds. For example: Because NumPy’s build behavior relies on this flag, I’d suggest it may be worth documenting -std=c17 as a critical reproducibility invariant — or testing for its override in CI as compilers evolve. I’ll still provide the union padding test case if helpful for reference, since it's a concrete illustration of what’s changing beneath the surface. |
C23 is the default as of the just-released GCC 15.1 |
No we won't do that, since this is still a pretty bogus report. The default ABI does not change by compiling with Please feel free to post the example you were talking about, but in the meantime I'll close this issue as invalid because there are way too many things here that don't add up while they may look concerning to the casual reader. |
Uh oh!
There was an error while loading. Please reload this page.
Describe the issue:
Reference Commit: 258cd5d5836a6660f1122cec274f0a947c1d0459
This appears to be an admission that the build process relies on runtime behavior (e.g., subprocess calls via INTROSPECT_COMMAND) that standard Python packaging tools cannot detect. In effect, the build relies on hidden logic that the packaging and introspection layers were never designed to see. While understandable as a workaround for Python’s static import model, it introduces a significant concern:
In the current configuration — especially when using Meson — it is unclear whether critical compiler flags (such as -std=c23 or -fzero-init-padding-bits=unions) are being surfaced, passed through, or suppressed. These flags are essential under GCC 14+ and Clang to ensure compatibility with new C23 behavior and to prevent undefined memory layout (especially in union initializations). However, due to the vendor-controlled and partially opaque nature of the current Meson integration, there is no transparent point of confirmation that these flags are honored, even when provided.
As a result, it's possible to build NumPy in a configuration where the build succeeds, but does so under an unstable or incorrect ABI. This fragility is compounded by the lack of flag propagation visibility and the decision to vendor the Meson build tool, which may itself be pinned to behavior that suppresses user-defined injection points like CFLAGS or native-file overrides.
This is being raised not as a blocker, but as a signal: as the toolchain landscape evolves (Python 3.13, GCC 14, C23), these silent assumptions about compiler behavior and flag pass-through may become a primary cause of subtle platform drift, memory bugs, or reproducibility failures.
Reproduce the code example:
Error message:
Python and NumPy Versions:
Build environment: Python 3.13.3 + NumPy 2.2.5 source clone (main branch, built from
pip install .
inside venv)Runtime Environment:
No response
Context for the issue:
It should be prioritized because the effects could imply why there is instability across most C based Python packages right now that are hesitating to move to 3.13
The text was updated successfully, but these errors were encountered: