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

Fix Windows cmake debug build #976

Merged

Conversation

acolwell
Copy link
Collaborator

@acolwell acolwell commented Jul 2, 2024

Thanks for submitting a pull request! Please provide enough information so that others can review your pull request. Additionally, make sure you've done all of these things:

PR Description

What type of PR is this? (Check one of the boxes below)

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Improvement (non-breaking change which does not add functionality nor fixes a bug but improves Natron in some way)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • My change requires a change to the documentation
    • I have updated the documentation accordingly

What does this pull request do?

Fixing Windows debug builds built with cmake.

  • Fixed several issues caused by Shiboken's cmake helper and added the -O flag to fix link errors and match the qmake build.
  • Fixed an assert that was firing in debug builds because Qt's GL context was active in cases where the code assumed it would not be. The assert was removed and code was added to capture and restore Qt's GL context so that our own GL context code doesn't accidentally violate some assumption Qt might be making about its GL context being active.

Have you tested your changes (if applicable)? If so, how?

Yes. I've verified that everything still builds and runs. I've tested a debug build with a few projects and have not observed any issues or asserts. I also ran Natron-Tests with the debug build and all the tests that passed with the 2.5.0 build also pass with this build.

acolwell added 2 commits July 2, 2024 11:09
- Force Shiboken to use detected python libraries instead of
  using its own library detection logic.
- Specify -O compiler option for debug builds like the qmake build.
- Remove unconditional NDEBUG define added by the Shiboken cmake
  helper so that asserts work correctly on debug builds.
This fixes asserts in debug builds where Qt's GL context is set when
a ScopedGLContext is created. This can happen when we have a project
open and the user tries to open another project. When the event
callback is dispatched, the Qt GL context is still set. The fix
justs removes the assert and adds logic to save and restore any
existing GL context that is set.

if(WIN32)
# Debug builds need minimal optimizations to avoid excessive link times and link errors related to Eigen.
add_compile_options(-O)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This option is set in the qmake builds used to build the installer. That is where I got the idea to do this.

Copy link
Member

Choose a reason for hiding this comment

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

Is it only useful on WIN32?

Copy link
Collaborator Author

@acolwell acolwell Jul 8, 2024

Choose a reason for hiding this comment

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

It doesn't appear to be required on Linux. The Eigen linking errors I'm seeing on Windows do not appear to occur on Linux. I'm not entirely sure why. My guess is that Windows is not inlining the Eigen code for some reason but Linux is.

Copy link
Contributor

Choose a reason for hiding this comment

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

There are no linking issues on Linux with CMake.


if(IS_DEBUG_BUILD AND WIN32)
# Remove NDEBUG from Shiboken2 INTERFACE_COMPILE_DEFINITIONS so it is not inherited in debug builds.
get_property(ShibokenInterfaceDefs TARGET Shiboken2::libshiboken PROPERTY INTERFACE_COMPILE_DEFINITIONS)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is needed because /mingw64/lib/cmake/Shiboken2-5.15.13/Shiboken2Targets.cmake has code that unconditionally sets NDEBUG. :(

@acolwell acolwell requested a review from rodlie July 2, 2024 21:36
Copy link
Member

@devernay devernay left a comment

Choose a reason for hiding this comment

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

LGTM

@acolwell acolwell merged commit 2d14d4e into NatronGitHub:RB-2.5 Jul 8, 2024
3 checks passed
@acolwell acolwell deleted the fix_windows_cmake_debug_build branch July 8, 2024 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants