Skip to content

Guard cxxabi.h include with __has_include for clang-cl - #6145

Open
aidaodedjl wants to merge 1 commit into
pybind:masterfrom
aidaodedjl:fix/cxxabi-has-include-guard
Open

Guard cxxabi.h include with __has_include for clang-cl#6145
aidaodedjl wants to merge 1 commit into
pybind:masterfrom
aidaodedjl:fix/cxxabi-has-include-guard

Conversation

@aidaodedjl

Copy link
Copy Markdown

Description

clang-cl on Windows defines __GNUG__ but does not ship <cxxabi.h>, so detail/typeid.h fails with fatal error: 'cxxabi.h' file not found.

This introduces PYBIND11_HAS_CXXABI_H as suggested by @henryiii in #6129: defined only when <cxxabi.h> is actually available, using __has_include with a fallback for toolchains without it (pybind11 still supports C++11, where __has_include is not guaranteed). The macro guards both the #include <cxxabi.h> and the abi::__cxa_demangle call site in clean_type_id — guarding the include alone would leave the call undeclared.

Suggested changelog entry

Guard the <cxxabi.h> include with __has_include so that toolchains defining __GNUG__ without the header (e.g. clang-cl) can compile detail/typeid.h.

Fixes #6129

Verification

clang-cl on Windows defines __GNUG__ but does not ship <cxxabi.h>,
making detail/typeid.h fail to compile. Introduce PYBIND11_HAS_CXXABI_H,
defined only when <cxxabi.h> is actually available (__has_include with
a fallback for compilers without it, including C++11), and use it to
guard both the include and the abi::__cxa_demangle call site.

Fixes pybind#6129
@aidaodedjl

Copy link
Copy Markdown
Author

The macOS PyPy job aborted in PyPy's own _pypy_generic_alias builtin (SystemError: Bad internal call!) while pytest was collecting — stack is entirely inside pluggy/PyPy, no pybind11 frames. The Ubuntu PyPy job with the same change passed, and on macOS the new macro evaluates true so clean_type_id takes the identical code path as before this change. Looks like a PyPy flake; could someone with rights re-run that job?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: detail\typeid.h(16,14): fatal error : 'cxxabi.h' file not found

2 participants