diff --git a/CMakeLists.txt b/CMakeLists.txt index 22453e5af6..569aae3975 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -158,11 +158,16 @@ endif() # add autotools definitions that were maybe used! add_definitions("-DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_FCNTL_H=1 -DHAVE_ARPA_INET_H=1 -DHAVE_SYS_TIME_H=1 -DHAVE_SYS_SOCKET_H=1 -DHAVE_STRERROR=1 -DHAVE_SOCKET=1 -DHAVE_MEMSET=1 -DHAVE_GETTIMEOFDAY=1 -DHAVE_STDLIB_H=1 -DHAVE_MALLOC=1 -DHAVE_LIBSCTP") -set(commonOpts "-pipe -fPIC -Wall -fno-strict-aliasing") +# we need -rdynamic to incorporate all symbols in shared objects, see man page +set(commonOpts "-pipe -fPIC -Wall -fno-strict-aliasing -rdynamic") # GNU C/C++ Compiler might throw many warnings without packed-bitfield-compat, see man page -# also, we need -rdynamic to incorporate all symbols in shared objects, again, see man page if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - set(commonOpts "${commonOpts} -Wno-packed-bitfield-compat -rdynamic") + set(commonOpts "${commonOpts} -Wno-packed-bitfield-compat") +endif() +# clang: suppress complaints about unused command line argument (-rdynamic only +# used during linking) +if(CMAKE_C_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + set(commonOpts "${commonOpts} -Wno-unused-command-line-argument") endif() set(CMAKE_C_FLAGS diff --git a/cmake_targets/build_oai b/cmake_targets/build_oai index bb61d356f4..c59017b5ac 100755 --- a/cmake_targets/build_oai +++ b/cmake_targets/build_oai @@ -418,8 +418,6 @@ function main() { CMAKE_CMD="$CMAKE_CMD -DSANITIZE_UNDEFINED=True" 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 2 CMAKE_CMD="$CMAKE_CMD -DSANITIZE_MEMORY=ON -DSANITIZE_ADDRESS=OFF -DSANITIZE_UNDEFINED=OFF" shift;; --trace-asn1c-enc-dec) diff --git a/cmake_targets/tools/memsan.patch b/cmake_targets/tools/memsan.patch deleted file mode 100644 index a8b8e9f992..0000000000 --- a/cmake_targets/tools/memsan.patch +++ /dev/null @@ -1,53 +0,0 @@ -commit bf7f0c4f0f1bfce586667b50050640b67a7a747a -Author: Robert Schmidt -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 - #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) - { diff --git a/common/config/libconfig/config_libconfig.c b/common/config/libconfig/config_libconfig.c index c5cdd1972f..b0c3c2c6cf 100644 --- a/common/config/libconfig/config_libconfig.c +++ b/common/config/libconfig/config_libconfig.c @@ -322,19 +322,16 @@ int config_libconfig_set(configmodule_interface_t *cfg, paramdef_t *cfgoptions, int config_libconfig_get(configmodule_interface_t *cfg, paramdef_t *cfgoptions, int numoptions, char *prefix) { config_setting_t *setting; - char *str; - int i,u; - long long int llu; - double dbl; - int rst; - int status=0; - int notfound; - int defval; - int fatalerror=0; - int numdefvals=0; + char *str = NULL; + int u = 0; + long long int llu = 0; + double dbl = 0.0f; + int status = 0; + int fatalerror = 0; + int numdefvals = 0; char cfgpath[512]; /* 512 should be enough for the sprintf below */ - for(i=0; ipixel_length; if (this->autoscroll) { - tnext = time_add(this->latest_time, - (struct timespec){tv_sec:0,tv_nsec:1}); + tnext = time_add(this->latest_time, (struct timespec){.tv_sec = 0, .tv_nsec = 1}); tstart = time_sub(tnext, nano_to_time(pixel_length * width)); this->start_time = tstart; } else { diff --git a/common/utils/T/tracer/view/time.c b/common/utils/T/tracer/view/time.c index 287e7b1c7b..18fc02e4d7 100644 --- a/common/utils/T/tracer/view/time.c +++ b/common/utils/T/tracer/view/time.c @@ -122,8 +122,7 @@ static void *time_thread(void *_this) pixel_length = this->pixel_length; if (this->autoscroll) { - tnext = time_add(this->latest_time, - (struct timespec){tv_sec:0,tv_nsec:1}); + tnext = time_add(this->latest_time, (struct timespec){.tv_sec = 0, .tv_nsec = 1}); tstart = time_sub(tnext, nano_to_time(pixel_length * width)); this->start_time = tstart; } else { diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c index 335510953f..f411e0c6be 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c @@ -391,8 +391,8 @@ void build_polar_tables(t_nrPolar_params *polarParams) { // this code packs the one bit per byte of G_N into a packed bits G_N_tab for (int i = 0; i < polarParams->N; i++) { for (int j = 0; j < polarParams->N; j += 64) { - const simde__m256i tmp1 = simde_mm256_cmpgt_epi8(*(simde__m256i *)&polarParams->G_N[i][j], zeros); - const simde__m256i tmp2 = simde_mm256_cmpgt_epi8(*(simde__m256i *)&polarParams->G_N[i][j + 32], zeros); + const simde__m256i tmp1 = simde_mm256_cmpgt_epi8(simde_mm256_loadu_si256((simde__m256i *)&polarParams->G_N[i][j]), zeros); + const simde__m256i tmp2 = simde_mm256_cmpgt_epi8(simde_mm256_loadu_si256((simde__m256i *)&polarParams->G_N[i][j + 32]), zeros); // cast directly to uint64_t from int32_t propagates the sign bit (in gcc) const uint32_t part1 = simde_mm256_movemask_epi8(tmp1); const uint32_t part2 = simde_mm256_movemask_epi8(tmp2); diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index 725e3a9919..c688b20e21 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -184,8 +184,9 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB) AssertFatal(pdsch_dmrs[slot][symb]!=NULL, "NR init: pdsch_dmrs for slot %d symbol %d - malloc failed\n", slot, symb); for (int q=0; qbuf[sock]; - ptr->circularBuf = malloc(sampleToByte(CirSize, 1)); + ptr->circularBuf = calloc(1, sampleToByte(CirSize, 1)); if (ptr->circularBuf == NULL) { LOG_E(HW, "malloc(%lu) failed\n", sampleToByte(CirSize, 1)); return -1;