-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[BUG]: Compilation failure with GCC 10.2 on pybind11 2.13.0 (typing.h, line 209) #5201
Comments
I assume it's trying to deduce something which means it's failing on a usage of it (and we test on GCC 10.2.1), so it's probably a regression for some usage. Do you know where this template is being used in your code? |
Hi @henryiii , Thanks for your reply. I can reproduce using the simple example from the docs: #include "pybind11/pybind11.h"
int add(int i, int j) {
return i + j;
}
PYBIND11_MODULE(example, m) {
m.doc() = "pybind11 example plugin"; // optional module docstring
m.def("add", &add, "A function that adds two numbers");
} and compile with the command: // $CXX point our GCC 10.2 bin
$CXX -O3 -Wall -shared -std=c++20 -fPIC $(python3 -m pybind11 --includes) example.cpp -o example.cpython-39m-x86_64-linux-gnu.so It gives a bit more message this case (maybe because I didn't use
BTW, we have another CI that run in macOS with Apple-clang and that seems OK to compile. |
After a few more tries. the error seems only happen when I enable // $CXX point our GCC 10.2 bin
$CXX -O3 -Wall -shared -std=c++17 -fPIC $(python3 -m pybind11 --includes) example.cpp -o example.cpython-39m-x86_64-linux-gnu.so |
We might be missing a c++20 test on this compiler. |
It seems very likely to me that you're stumbling over a bug in that old GCC release. We're testing with C++20 using a variety of more modern C++ compilers (clang, gcc, msvc). A simple, pragmatic workaround would be to add to the ifdef here: pybind11/include/pybind11/typing.h Line 225 in 57287b5
... && !defined(...conditions for GCC 10...)
@InvincibleRMC for awareness (and ideas). |
Oops, sorry, I just realized I mixed up clang 10 vs gcc 10 in my mind: we actually do have gcc 10 testing, e.g. here: https://github.com/pybind/pybind11/actions/runs/9687720852/job/26732870800 It should be super easy to add gcc 10 C++20 testing along with the ifdef workaround. (Unless we're stumbling over other (presumed) bugs in the compiler.) |
Thanks very much for your quick response. I forked a repo on my side and tried different version of gcc: https://github.com/zhqrbitee/pybind11/actions/runs/9692860216/job/26747094324. I short, GCC 9, GCC 10.1, 10.2 have this issue with c++20. GCC 10.3 (and above) seems to have fixed it. |
@rwgk Do you want me to implement the suggest changes or are you on it? |
It'd be helpful if you could send the PR. Thanks! |
This is to make `zxing-cpp` build again. The root cause is an issue in `pybind11`, see: * https://github.com/pybind/pybind11/releases/tag/v2.13.1 * pybind/pybind11#5201 * pybind/pybind11#5205 * zxing-cpp/zxing-cpp#803
Required prerequisites
What version (or hash if on master) of pybind11 are you using?
2.13.0
Problem description
Environment:
Compiler: GCC 10.2
C++ Language Dialect: C++20 (std=c++20)
Error Message:
It seems the error just comes from including pybind11 headers and it comes after upgrading to 2.13.
I see it tries to use the macro
__cpp_nontype_template_parameter_class
to enable some template codes. However not sure why the macro check is success, but GCC 10.2 fails to compile the codes.Reproducible example code
No response
Is this a regression? Put the last known working version here if it is.
2.12.0
The text was updated successfully, but these errors were encountered: