Provide build_oai/cmake option to build with memory sanitizer
This commit is contained in:
@@ -253,6 +253,12 @@ if (SANITIZE_UNDEFINED)
|
|||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined -fno-sanitize-recover=all")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined -fno-sanitize-recover=all")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
add_boolean_option(SANITIZE_MEMORY False "enable the memory sanitizer (MSan, requires clang, incompatible with ASan/UBSan)" ON)
|
||||||
|
if(SANITIZE_MEMORY)
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer -fsanitize-recover=memory")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer -fsanitize-recover=memory")
|
||||||
|
endif()
|
||||||
|
|
||||||
add_definitions("-DASN_DISABLE_OER_SUPPORT -DHAVE_CONFIG_H -DHAVE_CONFIG_H_")
|
add_definitions("-DASN_DISABLE_OER_SUPPORT -DHAVE_CONFIG_H -DHAVE_CONFIG_H_")
|
||||||
|
|
||||||
#########################
|
#########################
|
||||||
|
|||||||
@@ -167,6 +167,10 @@ Options:
|
|||||||
Enable the address sanitizer on all targets
|
Enable the address sanitizer on all targets
|
||||||
--sanitize-undefined | -fsanitize=undefined
|
--sanitize-undefined | -fsanitize=undefined
|
||||||
Enable the undefined behavior sanitizer on all targets
|
Enable the undefined behavior sanitizer on all targets
|
||||||
|
--sanitize-memory | -fsanitize=memory
|
||||||
|
Enable the memory sanitizer on all targets. Requires clang, and is
|
||||||
|
incompatible with ASan/UBSan. To build, issue:
|
||||||
|
CC=/usr/bin/clang CXX=/usr/bin/clang++ ./build_oai ... --sanitize-memory
|
||||||
-h | --help
|
-h | --help
|
||||||
Print this help"
|
Print this help"
|
||||||
}
|
}
|
||||||
@@ -413,6 +417,11 @@ function main() {
|
|||||||
--sanitize-undefined | -fundefined=address)
|
--sanitize-undefined | -fundefined=address)
|
||||||
CMAKE_CMD="$CMAKE_CMD -DSANITIZE_UNDEFINED=True"
|
CMAKE_CMD="$CMAKE_CMD -DSANITIZE_UNDEFINED=True"
|
||||||
shift;;
|
shift;;
|
||||||
|
--sanitize-memory | -fsanitize=memory)
|
||||||
|
echo_warning "Note: memory sanitizer\n* requires clang (tested: v17)\n* is incompatible with address/undefined behavior sanitizer\n* requires cmake_targets/tools/memsan.patch"
|
||||||
|
sleep 5
|
||||||
|
CMAKE_CMD="$CMAKE_CMD -DSANITIZE_MEMORY=ON -DSANITIZE_ADDRESS=OFF -DSANITIZE_UNDEFINED=OFF"
|
||||||
|
shift;;
|
||||||
-h | --help)
|
-h | --help)
|
||||||
print_help
|
print_help
|
||||||
exit 1;;
|
exit 1;;
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
commit bf7f0c4f0f1bfce586667b50050640b67a7a747a
|
||||||
|
Author: Robert Schmidt <robert.schmidt@openairinterface.org>
|
||||||
|
Date: Wed Jun 7 18:24:50 2023 +0200
|
||||||
|
|
||||||
|
Fix dlopen() linker errors in dfts, ldpc, ldpc_parityCheck, and params_libconfig
|
||||||
|
|
||||||
|
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||||
|
index c29105d503..3b9e7d1246 100644
|
||||||
|
--- a/CMakeLists.txt
|
||||||
|
+++ b/CMakeLists.txt
|
||||||
|
@@ -508,7 +508,7 @@ add_library(CONFIG_LIB
|
||||||
|
)
|
||||||
|
target_link_libraries(CONFIG_LIB PRIVATE dl UTIL)
|
||||||
|
add_library(params_libconfig MODULE ${CONFIG_ROOTDIR}/libconfig/config_libconfig.c)
|
||||||
|
-target_link_libraries(params_libconfig config)
|
||||||
|
+target_link_libraries(params_libconfig config CONFIG_LIB minimal_lib)
|
||||||
|
# shared library loader
|
||||||
|
set (SHLIB_LOADER_SOURCES
|
||||||
|
${OPENAIR_DIR}/common/utils/load_module_shlib.c
|
||||||
|
@@ -1018,16 +1018,19 @@ if (ENABLE_LDPC_CUDA)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
-add_library(ldpc MODULE ${PHY_LDPC_OPTIM8SEGMULTI_SRC} )
|
||||||
|
+add_library(ldpc MODULE ${PHY_LDPC_OPTIM8SEGMULTI_SRC} ${OPENAIR1_DIR}/PHY/CODING/crc_byte.c)
|
||||||
|
target_link_libraries(ldpc PRIVATE ldpc_gen_HEADERS)
|
||||||
|
+target_link_libraries(ldpc PRIVATE UTIL)
|
||||||
|
|
||||||
|
add_library(ldpc_parityCheck MODULE ${PHY_LDPC_OPTIM8SEGMULTI_SRC} )
|
||||||
|
target_compile_definitions(ldpc_parityCheck PUBLIC NR_LDPC_ENABLE_PARITY_CHECK)
|
||||||
|
target_link_libraries(ldpc_parityCheck PRIVATE ldpc_gen_HEADERS)
|
||||||
|
+target_link_libraries(ldpc_parityCheck PRIVATE UTIL minimal_lib)
|
||||||
|
|
||||||
|
add_library(coding MODULE ${PHY_TURBOSRC} )
|
||||||
|
|
||||||
|
add_library(dfts MODULE ${OPENAIR1_DIR}/PHY/TOOLS/oai_dfts.c )
|
||||||
|
+target_link_libraries(dfts PRIVATE minimal_lib)
|
||||||
|
|
||||||
|
|
||||||
|
set(PHY_SRC_COMMON
|
||||||
|
diff --git a/common/utils/minimal_stub.c b/common/utils/minimal_stub.c
|
||||||
|
index be9c1b399d..7ad0df4d56 100644
|
||||||
|
--- a/common/utils/minimal_stub.c
|
||||||
|
+++ b/common/utils/minimal_stub.c
|
||||||
|
@@ -1,6 +1,8 @@
|
||||||
|
+#include <stdlib.h>
|
||||||
|
#ifndef T_TRACER
|
||||||
|
int T_stdout;
|
||||||
|
#endif
|
||||||
|
+int oai_exit = 0;
|
||||||
|
|
||||||
|
void exit_function(const char *file, const char *function, const int line, const char *s, const int assert)
|
||||||
|
{
|
||||||
Reference in New Issue
Block a user