-
Notifications
You must be signed in to change notification settings - Fork 2.2k
add_module: include as SYSTEM #1416
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
Conversation
49430be
to
fca9f53
Compare
5fe757a
to
22a609e
Compare
@chuckatkins any thoughts on this one? It's unfortunate the debug build has some weird symbol issue... |
So, this is a weird one. There's a good detailed explanation of this happening with boost::python here https://stackoverflow.com/questions/39161202/how-to-work-around-missing-pymodule-create2-in-amd64-win-python35-d-lib . The short answer is, that's what the python debug library does. It's by design. From looking in the headers, I believe you need to add |
It looks like the intent of this is to purposely break ABI compatibility between the python debug and release libraries for modules and extensions. |
That's what I found from googling as well, but I did not see the flag. Let's try it! |
It's probably best suited to be added in pybind11_add_module via target_compile_definitions(Foo PRIVATE Py_DEBUG) when using a debug libpython. |
f430379
to
4dfb492
Compare
Yay, works! Thanks, Chuck! |
4dfb492
to
117bf8c
Compare
@jagerman fix ready for reliable linking to python debug libs and addresses two issues with strict(er) warning flags in downstream projects |
2722f1f
to
6ab7d54
Compare
Hm, I'm not so excited about this patch. "-Isystem" is meant for standard system include directories, which is probably not true in many cases. If you take a look at the current header files, you will see that they already turn off a bunch of warnings before including the Python header files, and it would be fine to add more of them if needed. It's not pretty, but this at least ensures that there is some consistency across build systems (CMake is just one of many build systems that can be used with pybind11.). A side note: this PR also contains a change to deal with Debug python libraries. This is not related to the change about warnings and would be great to have as a separate PR. |
Thanks for taking a look! As far as I am aware, Maybe @chuckatkins can comment on that, but I think this is common practice, properly modularizes compiler flags and testing (e.g. no noise from dependencies) and has no downsides (e.g. it falls back to
I respectfully disagree with that approach. I think for example, that adding more
yes it does contain an additional fix that turned up and I will provide it again in a separate PR: #1438 |
People do it but it's definitely not common practice. Well established behavior is to not use [NO_EXTRAS] [SYSTEM] [THIN_LTO] source1 [source2 ...]) This would align with the syntax for |
Sounds perfect to me, will adopt accordingly! |
pybind11 headers passed via the `pybind11_add_module` CMake function can now be included as `SYSTEM` includes (`-isystem`). This allows to set stricter (or experimental) warnings in calling projects that might throw otherwise in headers a user of pybind11 can not influence.
6ab7d54
to
79fb21a
Compare
@wjakob does this work? The patch now keeps the default includes and allows to include with |
It isn't disabled on the whole translation unit, but merely within the pybind headers (via a |
Thank you for the info, that's right! Since |
@wjakob added your review comments, kept the default and made it optional |
Looks good, thank you! |
pybind11 headers passed via the
pybind11_add_module
CMake function can now be included asSYSTEM
includes (-isystem
).This allows to set stricter (or experimental) warnings in calling projects that might throw otherwise in headers a user of pybind11 can not influence. Examples are
-Wpedantic
#1417 and-Wshadow
#1267.Additionally, this change uncovered that builds against a python debug library were unreliable. Setting the
Py_DEBUG
define is necessary when linking against a debug build (ref): #1438