Remove explicit LOGURU_STACKTRACES setting#273
Open
myd7349 wants to merge 1 commit into
Open
Conversation
The previous code set LOGURU_STACKTRACES=$<BOOL:${LSL_DEBUGLOG}> for
loguru.cpp, which caused compilation failures on platforms that do not
support GNU libc backtrace (e.g. Windows with Ninja generator in Debug
mode, Linux musl libc, Android).
loguru already has sensible built-in defaults for LOGURU_STACKTRACES:
it defaults to 0 on Windows and 1 when __GLIBC__ is defined. Removing
the explicit setting lets loguru handle platform detection correctly and
avoids build errors on unsupported platforms.
Contributor
Author
|
In earlier versions, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The current loguru stacktrace configuration in liblsl can cause compilation failures on certain platforms. The relevant code is shown below.
cmake/ProjectOptions.cmake
cmake/Dependencies.cmake
thirdparty/loguru/loguru.cpp
As shown above,
LOGURU_STACKTRACESdepends on the GNU libcbacktracefacility and is therefore not supported on all platforms, notably:Because
LSL_DEBUGLOGdefaults toONfor Debug builds when using a single-config generator, this forcesLOGURU_STACKTRACESto be enabled and causes compilation errors on the platforms listed above.To illustrate with Windows: when using the default Visual Studio generator (a multi-config generator),
CMAKE_BUILD_TYPEis not set toDebug, so the problem does not surface. However, when using the Ninja generator (a single-config generator), the issue is triggered:https://github.com/SharpLSL/liblsl-ci-build/tree/loguru-stacktraces
https://github.com/SharpLSL/liblsl-ci-build/actions/runs/24925417393/job/72994456551
A straightforward workaround would be to skip the setting on Windows:
However, this still does not address Linux musl libc or Android.
Testing showed that simply removing the
set_source_files_propertiescall works well: loguru's built-in platform detection is already sensible — it defaultsLOGURU_STACKTRACESto 0 on Windows and to 1when
__GLIBC__is defined.It is also worth noting that loguru only prints a stack trace when
LOG_F(FATAL, ...)is called, and liblsl does not currently log anything at the FATAL level.Given the above, there are several possible approaches:
Option 1: Always disable stacktraces (since liblsl never logs at FATAL level)
Option 2: Explicitly disable stacktraces when
LSL_DEBUGLOGis OFFOption 3: Remove the explicit
LOGURU_STACKTRACESsetting and letloguru decide
This PR uses Option 3. Other suggestions are welcome.