Skip to content
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

Export libc++ exceptions #5390

Merged
merged 4 commits into from
Oct 12, 2024
Merged

Export libc++ exceptions #5390

merged 4 commits into from
Oct 12, 2024

Conversation

cyyever
Copy link
Contributor

@cyyever cyyever commented Sep 30, 2024

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

@cyyever cyyever marked this pull request as draft September 30, 2024 04:01
@cyyever cyyever force-pushed the libcpp_exception branch 3 times, most recently from 7e27da3 to e92dd74 Compare September 30, 2024 05:08
@cyyever cyyever marked this pull request as ready for review September 30, 2024 05:09
@cyyever cyyever marked this pull request as draft September 30, 2024 05:14
@cyyever cyyever force-pushed the libcpp_exception branch 5 times, most recently from 8e3fa6e to 549c343 Compare September 30, 2024 09:26
@rwgk
Copy link
Collaborator

rwgk commented Oct 8, 2024

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
Copy link
Contributor Author

cyyever commented Oct 10, 2024

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

@cyyever cyyever marked this pull request as ready for review October 10, 2024 02:23
@rwgk
Copy link
Collaborator

rwgk commented Oct 10, 2024

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
Copy link
Contributor Author

cyyever commented Oct 10, 2024

@rwgk Removed

include/pybind11/detail/common.h Outdated Show resolved Hide resolved
include/pybind11/detail/common.h Show resolved Hide resolved
Copy link
Collaborator

@rwgk rwgk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for discovering and fixing this bug!

@rwgk rwgk merged commit 077e49f into pybind:master Oct 12, 2024
80 checks passed
@github-actions github-actions bot added the needs changelog Possibly needs a changelog entry label Oct 12, 2024
@cyyever cyyever deleted the libcpp_exception branch October 13, 2024 02:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs changelog Possibly needs a changelog entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants