Uh oh!
There was an error while loading. Please reload this page.
add_module: include as SYSTEM - #1416
Conversation
49430be to
fca9f53Compare5fe757a to
22a609eCompareax3l
commented
Jun 21, 2018
@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 |
chuckatkins
commented
Jun 21, 2018
It looks like the intent of this is to purposely break ABI compatibility between the python debug and release libraries for modules and extensions. |
ax3l
commented
Jun 21, 2018
That's what I found from googling as well, but I did not see the flag. Let's try it! |
chuckatkins
commented
Jun 21, 2018
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
4dfb492CompareYay, works! Thanks, Chuck! |
4dfb492 to
117bf8cCompareax3l
commented
Jun 21, 2018
@jagerman fix ready for reliable linking to python debug libs and addresses two issues with strict(er) warning flags in downstream projects |
2722f1f to
6ab7d54Comparewjakob
commented
Jun 24, 2018
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 |
chuckatkins
commented
Jun 25, 2018
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 |
ax3l
commented
Jun 25, 2018
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
79fb21aCompare@wjakob does this work? The patch now keeps the default includes and allows to include with |
jagerman
commented
Jun 25, 2018
It isn't disabled on the whole translation unit, but merely within the pybind headers (via a |
ax3l
commented
Jun 25, 2018
Thank you for the info, that's right! Since |
ax3l
commented
Aug 8, 2018
ax3l
commented
Aug 29, 2018
@wjakob added your review comments, kept the default and made it optional |
wjakob
commented
Aug 29, 2018
Looks good, thank you! |
pybind11 headers passed via the
pybind11_add_moduleCMake function can now be included asSYSTEMincludes (-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_DEBUGdefine is necessary when linking against a debug build (ref): #1438