pybind / pybind11

Seamless operability between C++11 and Python
https://pybind11.readthedocs.io/
Other
15.82k stars 2.12k forks source link

Export libc++ exceptions #5390

Closed cyyever closed 1 month ago

cyyever commented 1 month ago

Description

Before this PR, exception translation was still failing on libc++. The failure reason is the visibility of exceptions, which was already discovered in #2999 and reverted by #4324. This PR fixes it by detecting libc++ using the _LIBCPP_EXCEPTION macro and setting PYBIND11_EXPORT_EXCEPTION accordingly. The macro definition is moved below other C++ header inclusion to make sure that _LIBCPP_EXCEPTION is defined.

Suggested changelog entry:

``pybind11::builtin_exception`` is now explicitly exported when linked to libc++.
rwgk commented 1 month ago

This seems to fix an xfail in the WASM / Pyodide wheel job:

 ____________________ test_cross_module_exception_translator ____________________
  [XPASS(strict)] See Issue #2847, PR #2999, PR #4324

I'm too rushed to look carefully, but that looks good?

Did you mean to (also) remove or sys.platform.startswith('emscripten')?

cyyever commented 1 month ago

@rwgk I have no emscripten env, but I tested on Apple Silicon and it worked. Therefore I removed the MacOS+CPython case.

rwgk commented 1 month ago

I have no emscripten env, but I tested on Apple Silicon and it worked. Therefore I removed the MacOS+CPython case.

We have the WASM / Pyodide wheel job here in our GitHub Actions.

Could you please remove or sys.platform.startswith('emscripten')? I believe that'll fix the test failures, which would be awesome.

cyyever commented 1 month ago

@rwgk Removed