Skip to content

[BUG]: arm64-apple-darwin22-gcc: error: unrecognized command-line option -stdlib=libc++ #4637

Closed
@biergaizi

Description

@biergaizi

Required prerequisites

What version (or hash if on master) of pybind11 are you using?

git master

Problem description

On macOS, by default, pybind11 currently unconditionally passes the compiler flag -stdlib=libc++ regardless of which compiler is used, as indicated by the source code. This flag is invalid on 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 is not a new problem. Both x86_64 and ARM64 are affected. See How to tell which specific compiler will be invoked for a Python C extension: GCC or Clang? for a similar case from 8 years ago.

Reproducible example code

No response

Is this a regression? Put the last known working version here if it is.

Not a regression

Metadata

Metadata

Assignees

No one assigned

    Labels

    triageNew bug, unverified

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions