mk/fio: link shared sanitizers for clang builds
By default, clang uses static sanitizer libraries, which means that the executable needs to have them linked in. Since we don't control how the fio binary is compiled, we need to use the shared libraries. This patch fixes ubsan, but there are still some issues with clang's address sanitizer. It seems as if the address sanitizer ignored some/all of the suppression rules, but in the interest of fixing the ubsan build, this will be fixed by a separate patch at a later time. Fixes #2367 Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com> Change-Id: I416a410214826b4ef8c25eeeef95272ef1742d7e Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11662 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Community-CI: Mellanox Build Bot Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Dong Yi <dongx.yi@intel.com> Reviewed-by: Jun Wen <junx.wen@intel.com>
This commit is contained in:
parent
24d34ac75c
commit
06fdd44c5d
@ -48,6 +48,17 @@ CFLAGS += -Wno-error
|
||||
endif
|
||||
LDFLAGS += -shared -rdynamic -Wl,-z,nodelete
|
||||
|
||||
# By default, clang uses static sanitizer libraries, which means that the executable needs to have
|
||||
# them linked in. Since we don't control how the fio binary is compiled, we need to use the shared
|
||||
# libraries.
|
||||
ifeq ($(CC_TYPE),clang)
|
||||
ifneq ($(filter y,$(CONFIG_ASAN) $(CONFIG_UBSAN)),)
|
||||
LDFLAGS += -shared-libsan
|
||||
# clang's sanitizers aren't in ld's search path by default, so we need to add it manually
|
||||
LDFLAGS += -Wl,-rpath=$(shell $(CC) -print-resource-dir)/lib
|
||||
endif
|
||||
endif
|
||||
|
||||
CLEAN_FILES = $(FIO_PLUGIN)
|
||||
|
||||
all : $(FIO_PLUGIN)
|
||||
|
@ -1173,13 +1173,20 @@ EOL
|
||||
function fio_plugin() {
|
||||
# Setup fio binary cmd line
|
||||
local fio_dir=$CONFIG_FIO_SOURCE_DIR
|
||||
# gcc and clang uses different sanitizer libraries
|
||||
local sanitizers=(libasan libclang_rt.asan)
|
||||
local plugin=$1
|
||||
shift
|
||||
|
||||
# Preload AddressSanitizer library to fio if fio_plugin was compiled with it
|
||||
local asan_lib
|
||||
asan_lib=$(ldd $plugin | grep libasan | awk '{print $3}')
|
||||
local asan_lib=
|
||||
for sanitizer in "${sanitizers[@]}"; do
|
||||
asan_lib=$(ldd $plugin | grep $sanitizer | awk '{print $3}')
|
||||
if [[ -n "$asan_lib" ]]; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# Preload the sanitizer library to fio if fio_plugin was compiled with it
|
||||
LD_PRELOAD="$asan_lib $plugin" "$fio_dir"/fio "$@"
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user