LMMS / LMMS/lmms

MSVC RelWithDebInfo configuration uses mixture of debug and release libraries

Open
#5,683 4 comments 0 reactions 0 assignees View on GitHub
bug cmake master branch windows
Dominant language
C++
Stars
10.4k
Forks
1.3k
Avg merge
2d 13h
Merged PRs (30d)
7

Description

### Bug Summary

When building with MSVC using the `RelWithDebInfo` configuration, a mixture of debug and release libraries is used.

#### Steps to reproduce

Build the `master` branch with MSVC using `RelWithDebInfo` configuration, or download an MSVC build from CI, since that's the configuration we use there.

#### Expected behavior

All libraries used should belong to the same configuration (preferably `Release`).

#### Actual behavior

LMMS uses the debug CRT, and debug Qt libraries, but release versions of the libraries from vcpkg.

#### Affected LMMS versions

MSVC `RelWithDebInfo` builds of `master` branch.

#### Further information

This leads to crashes when, e.g., trying to load samples. LMMS and Qt use the debug CRT to open files, but pass these file handles to libsndfile, which is using the release CRT. This causes a crash when the release CRT is asked to read a file using a handle it doesn't recognise.

This could be addressed by setting the [`CMAKE_MAP_IMPORTED_CONFIG_RELWITHDEBINFO`](https://cmake.org/cmake/help/latest/variable/CMAKE_MAP_IMPORTED_CONFIG_CONFIG.html) variable to `RelWithDebInfo Release`, to instruct CMake to use `Release` libraries for the `RelWithDebInfo` configuration if `RelWithDebInfo` versions don't exist, instead of `Debug` libraries. This won't work for SDL2 however - we have a custom [`FindSDL2.cmake`](https://github.com/LMMS/lmms/blob/0196f31509f52b1ccbf2eb8edd6f0a117f752bf6/cmake/modules/FindSDL2.cmake) module, which takes precedence over SDL2's own `SDL2Config.cmake` script, and doesn't know how to find vcpkg's SDL2 debug build.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing an MSVC RelWithDebInfo build of the master branch or inspecting the MSVC CI build. Read CMAKE_MAP_IMPORTED_CONFIG_RELWITHDEBINFO and cmake/modules/FindSDL2.cmake, paying attention to how CMake and vcpkg select library configurations. Done means LMMS, Qt, SDL2, and other libraries use compatible configurations and sample loading no longer crashes.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.