Content-Length: 350110 | pFad | http://github.com/numpy/numpy/issues/28953

C9 BUG: C23 Compiler Flags Ignored or Obscured During NumPy Build via Meson Backend · Issue #28953 · numpy/numpy · GitHub
Skip to content

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

Closed
BryteLite opened this issue May 14, 2025 · 12 comments
Closed

Comments

@BryteLite
Copy link

BryteLite commented May 14, 2025

Describe the issue:

Reference Commit: 258cd5d5836a6660f1122cec274f0a947c1d0459

Python packagers want to be minimal and only copy the things
that they can see being used. They are blind to many things.

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:

#meson.build

cc = meson.get_compiler('c')
message('Compiler: ' + cc.get_id())
flags = ['-std=c23', '-fzero-init-padding-bits=unions']
supported = cc.get_supported_arguments(flags)
message('Supported flags: ' + ' '.join(supported))

#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.

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

@ngoldbaum
Copy link
Member

ngoldbaum commented May 14, 2025

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?

@BryteLite
Copy link
Author

BryteLite commented May 14, 2025 via email

@rgommers
Copy link
Member

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.

@BryteLite
Copy link
Author

BryteLite commented May 16, 2025 via email

@BryteLite
Copy link
Author

BryteLite commented May 16, 2025 via email

@ngoldbaum
Copy link
Member

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.

Yes please. A runnable example demonstrating what you’re talking about makes this discussion much more
concrete.

@rgommers
Copy link
Member

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.

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:

$ pip install . -v -Csetup-args=-Dc_args="-std=c23 -fzero-init-padding-bits=unions"
...
    User defined options
      Native files: /home/rgommers/code/numpy/.mesonpy-k6dwt_s7/meson-python-native-file.ini
      b_ndebug    : if-release
      b_vscrt     : md
      buildtype   : release
      c_args      : -std=c23 -fzero-init-padding-bits=unions

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.

@rgommers
Copy link
Member

If NumPy or downstream packages adopt C23 or expect future compatibility,

Also note that we explicitly use -std=c17, so the only way C23 gets used is if it's explicitly done by the user who is building from source. At which point they are responsible for the impact of their CFLAGS choices, on ABI or otherwise.

@BryteLite
Copy link
Author

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:
When C23 becomes the default in future GCC releases, when downstream repackagers or source builders omit explicit c_std flags, when vendored Meson builds fail to inherit or override updated compiler defaults.

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.

@h-vetinari
Copy link
Contributor

When C23 becomes the default in future GCC releases

C23 is the default as of the just-released GCC 15.1

@rgommers
Copy link
Member

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.

No we won't do that, since this is still a pretty bogus report. The default ABI does not change by compiling with -std=c23, it additionally requires a flag like -fzero-init-padding-bits=unions apparently (which I've never seen used in the wild, and we certainly don't use).

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.

@rgommers rgommers closed this as not planned Won't fix, can't repro, duplicate, stale May 17, 2025
@eli-schwartz
Copy link

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

No branches or pull requests

5 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/numpy/numpy/issues/28953

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy