Skip to content

Commit

Permalink
Fix memory debugging.
Browse files Browse the repository at this point in the history
* Disables WebRTC (build fails)
* Recommends disabling optimization
* Recommends enabling debugging
* Remove forced optimization from plugins
  • Loading branch information
daleglass committed Nov 5, 2023
1 parent 720c026 commit bb1331c
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 6 deletions.
15 changes: 15 additions & 0 deletions cmake/macros/MemoryDebugger.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,25 @@ if ("$ENV{OVERTE_MEMORY_DEBUGGING}")
message(FATAL_ERROR "Thread debugging and memory debugging can't be enabled at the same time." )
endif()

if (OVERTE_OPTIMIZE)
message(WARNING "You should consider building without optimization by passing -DOVERTE_OPTIMIZE=false to CMake")
endif()
if (NOT CMAKE_BUILD_TYPE MATCHES "Debug")
message(WARNING "You should consider building with debugging enabled by passing -DCMAKE_BUILD_TYPE=Debug to CMake. Current type is ${CMAKE_BUILD_TYPE}")
endif()


SET( OVERTE_MEMORY_DEBUGGING true )
SET ( DISABLE_WEBRTC true )
endif ()

if ( OVERTE_MEMORY_DEBUGGING)
# WebRTC doesn't work with memory debugging enabled, it fails to link:
# /usr/bin/ld: ../../libraries/networking/libnetworking.so: undefined reference to `typeinfo for rtc::Thread'
# /usr/bin/ld: ../../libraries/networking/libnetworking.so: undefined reference to `typeinfo for webrtc::SessionDescriptionInterface'
# /usr/bin/ld: ../../libraries/networking/libnetworking.so: undefined reference to `typeinfo for webrtc::IceCandidateInterface'
add_compile_definitions(DISABLE_WEBRTC)

if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer -fsanitize=undefined -fsanitize=address -fsanitize-recover=address")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined -fsanitize=address -fsanitize-recover=address")
Expand Down
6 changes: 5 additions & 1 deletion libraries/audio-client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ include_hifi_library_headers(script-engine)

if (ANDROID)
else ()
target_webrtc()
if (NOT DISABLE_WEBRTC )
target_webrtc()
else()
message(WARNING "WebRTC is supported on this platform but has been disabled for this build (likely memory debugging)")
endif()
endif ()

# append audio includes to our list of includes to bubble
Expand Down
6 changes: 5 additions & 1 deletion libraries/networking/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ add_crashpad()
target_breakpad()

if (WIN32 OR (UNIX AND NOT APPLE))
target_webrtc()
if (NOT DISABLE_WEBRTC )
target_webrtc()
else()
message(WARNING "WebRTC is supported on this platform but has been disabled for this build (likely memory debugging)")
endif()
endif ()

if (WIN32)
Expand Down
8 changes: 5 additions & 3 deletions libraries/shared/src/shared/WebRTC.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@
// # define WEBRTC_POSIX 1
// # define WEBRTC_LEGACY 1
#elif defined(Q_OS_LINUX) && defined(Q_PROCESSOR_X86_64)
# define WEBRTC_AUDIO 1
# define WEBRTC_POSIX 1
# define WEBRTC_DATA_CHANNELS 1
# ifndef DISABLE_WEBRTC
# define WEBRTC_AUDIO 1
# define WEBRTC_POSIX 1
# define WEBRTC_DATA_CHANNELS 1
# endif
#elif defined(Q_OS_LINUX) && defined(Q_PROCESSOR_ARM)
// WebRTC is basically impossible to build on aarch64 Linux.
// I am looking at https://gitlab.freedesktop.org/pulseaudio/webrtc-audio-processing for an alternative.
Expand Down
2 changes: 1 addition & 1 deletion plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# add the plugin directories
file(GLOB PLUGIN_SUBDIRS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/*")
list(REMOVE_ITEM PLUGIN_SUBDIRS "CMakeFiles")
set(CMAKE_BUILD_TYPE "Release")

# client-side plugins
if (NOT SERVER_ONLY AND NOT ANDROID)
if (NOT CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
Expand Down

0 comments on commit bb1331c

Please sign in to comment.