-
Notifications
You must be signed in to change notification settings - Fork 49
Bad assembly with SimpleArray caster #283
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
Comments
It's probably time to move forward with this issue. @tigercosmos could you please revisit it? |
sure, I will find some time to look at this. |
@yungyuc do you have any suggestions or hints? |
I didn't study the problem myself. This seems to be a challenging one involving the interaction between pybind11, modmesh, and the compiler. At the time being, the workaround is to increase the optimization level for debug build. The workaround itself is a concern because the increased optimization level may reduce the details of the debug build. I think the main focus is to remove the debug-with-optimization workaround. It matters less why the modmesh code leads to the issue. It is OK to change the modmesh C++ code as long as the workaround can be removed. |
Uh oh!
There was an error while loading. Please reload this page.
In the SimpleArrayCaster.hpp file, a custom caster for SimpleArray was defined to cast from SimpleArrayPlex to SimpleArray. By default, the debug build uses the -O0 flag and the binary is incorrect. The compiler ignores the custom caster and opts for the generic caster instead. Setting the optimization level to -O1 or higher leads to a correct binary and the custom caster works correctly.
This anomaly was identified on Windows (tested with MSVC 2022) and macOS (tested with LLVM 15 and GCC 13 toolchains). Notably, Ubuntu 22.04 with GCC 11 did not exhibit this issue.
The issue was initially observed in PR#266, and a concise investigation report is available here.
As a temporary solution, a workaround involves adding a flag, DEBUG_BUILD_OPTIMIZATION_ONE, in CMake to ensure successful CI passes on Windows and macOS by applying -O1 for the debug build. By default, this flag should be set to OFF to reproduce the issue. Developers are advised to apply this CMake flag to ensure correct behavior in their local environments, aligning with CI expectations.
The text was updated successfully, but these errors were encountered: