pybind11/pybind11
biergaizi da91926295
fix: remove -stdlib=libc++ from setup helpers, not needed on modern Pythons (#4639)
* Inject -stdlib=libc++ on macOS only when it's supported, close #4637.

On macOS, by default, pybind11 currently unconditionally set the compiler
flag "-stdlib=libc++" in Pybind11Extension.__init__(), regardless of which
compiler is used. This flag is required for clang, but is invalid for GCC.
If GCC is used, it causes compilation failures in all Python projects that
use pybind11, with the error message:

    arm64-apple-darwin22-gcc: error: unrecognized command-line option -stdlib=libc++.

This commit uses has_flag() to detect whether "-stdlib=libc++" on macOS,
and injects this flag from build_ext.build_extensions(), rather than
setting it unconditionally.

Signed-off-by: Yifeng Li <tomli@tomli.me>

* revert: just remove flags

---------

Signed-off-by: Yifeng Li <tomli@tomli.me>
Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
2023-05-01 10:14:52 -04:00
..
__init__.py chore: move to Ruff and add rules (#4483) 2023-02-22 06:18:55 -08:00
__main__.py add --version option to pybind11-config (#4526) 2023-02-22 21:59:14 -08:00
_version.py chore: back to work 2023-01-03 14:23:36 -05:00
commands.py chore: move to Ruff and add rules (#4483) 2023-02-22 06:18:55 -08:00
py.typed feat: typing support for helpers (#2588) 2020-10-14 14:08:41 -04:00
setup_helpers.py fix: remove -stdlib=libc++ from setup helpers, not needed on modern Pythons (#4639) 2023-05-01 10:14:52 -04:00