diff --git a/CMakeLists.txt b/CMakeLists.txt index 7764f3c50..2262fa370 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -498,8 +498,12 @@ if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang") endif () if (ENABLE_ASAN) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-omit-frame-pointer") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer") + # Note: When using ASAN, we need to ensure the use of RPATH instead of RUNPATH via "-Wl,--disable-new-dtags" + # While RPATH is default, some systems (e.g. Ubuntu 18.04 and 20.04) use RUNPATH by default, which is non-transitive. + # Since ASAN intercepts dlopen(), by which it replaces the dynamic string token "$ORIGIN" to its own location, + # the RF plugins won't be found by "libsrsran_rf.so" when using ASAN + RUNPATH in the top-level executable. + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-omit-frame-pointer -Wl,--disable-new-dtags") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer -Wl,--disable-new-dtags") endif (ENABLE_ASAN) if (ENABLE_TSAN)