Skip to content

Commit

Permalink
[cmake] gcc.cmake: Enable C++ assertions and debug mode, when buildin…
Browse files Browse the repository at this point in the history
…g for Debug.

Assertions are enabled for libstdc++ (gcc) and libc++ (llvm/clang).
Debug mode is enabled for libstdc++ only.

libc++'s hardened mode is also enabled.

libstdc++'s debug mode has already helped find a few bugs:
- GLenumStrings.cpp: sRGB PVRTC v1 was in the wrong place.
- AmiiboData.cpp: Searching for character variants was incorrect.

Not enabled for Release builds, since the assertions cause the program
to crash with SIGABRT.
  • Loading branch information
GerbilSoft committed Nov 17, 2024
1 parent 0c618f4 commit 1bd8048
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cmake/platform/gcc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,11 @@ SET(RP_CXX_FLAGS_RELEASE "-O2 -DNDEBUG ${CFLAGS_VECTORIZE}")
SET(RP_C_FLAGS_RELWITHDEBINFO "-O2 -ggdb -DNDEBUG ${CFLAGS_VECTORIZE}")
SET(RP_CXX_FLAGS_RELWITHDEBINFO "-O2 -ggdb -DNDEBUG ${CFLAGS_VECTORIZE}")

# Enable C++ assertions. (libstdc++ / libc++)
# Also enable C++ debug mode. (libstdc++ only)
# TODO: Only enable GLIBCXX for libstdc++, and LIBCPP for libc++.
SET(RP_CXX_FLAGS_DEBUG "${RP_CXX_FLAGS_DEBUG} -D_GLIBCXX_ASSERTIONS -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -D_LIBCPP_ENABLE_ASSERTIONS -D_LIBCPP_ENABLE_HARDENED_MODE")

# Unset temporary variables.
UNSET(CFLAG_OPTIMIZE_DEBUG)

Expand Down

0 comments on commit 1bd8048

Please sign in to comment.