Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DAOS-15799 build: Add libsanitize #14485

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions site_scons/prereq_tools/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2016-2023 Intel Corporation
# Copyright 2016-2024 Intel Corporation
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -443,7 +443,9 @@ def __init__(self, env, opts):
opts.Add('USE_INSTALLED', 'Comma separated list of preinstalled dependencies', 'none')
opts.Add(('MPI_PKG', 'Specifies name of pkg-config to load for MPI', None))
opts.Add(BoolVariable('FIRMWARE_MGMT', 'Build in device firmware management.', 0))
opts.Add(BoolVariable('STACK_MMAP', 'Allocate ABT ULTs stacks with mmap()', 0))
opts.Add(BoolVariable('STACK_MMAP', 'Allocate ABT ULTs stacks with mmap()', 1))
opts.Add(BoolVariable('ADDRESS_SANITIZER',
'Instrument C code with the Address Sanitizer library', 1))
opts.Add(EnumVariable('BUILD_TYPE', "Set the build type", 'release',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would SANITIZER=<address|thread|...> be more economical? Or, even COMPILER_FEAT=<asan|tsan|...>, but I'm not sure if that's going too far.

['dev', 'debug', 'release'], ignorecase=1))
opts.Add(EnumVariable('TARGET_TYPE', "Set the prerequisite type", 'default',
Expand Down
22 changes: 22 additions & 0 deletions site_scons/site_tools/compiler_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ def _base_setup(env):
'-Wall',
'-fpic'])

if env["ADDRESS_SANITIZER"] == 1:
print('Enabling Address Sanitizer')
# Enable Address Sanitizer, a fast memory error detector.
env.Prepend(LINKFLAGS=['-fsanitize=address'])
env.Prepend(CCFLAGS=['-fsanitize=address'])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also '-fno-omit-frame-pointer' in CCFLAGS for better reports.

I found that I had to change -Wframe-larger-than=4096 to a larger value (8192 worked for me), due to the redzones added by asan.


env.AppendIfSupported(CCFLAGS=DESIRED_FLAGS)

if build_type == 'debug':
Expand Down Expand Up @@ -160,10 +166,26 @@ def _append_if_supported(env, **kwargs):
config.Finish()


def _check_func(env, func_name):
"""Check if a function is usable"""
denv = env.Clone()
if denv["ADDRESS_SANITIZER"] == 1:
# NOTE Remove address sanitizer to not scramble the test output
denv["LINKFLAGS"].remove('-fsanitize=address')
denv["CCFLAGS"].remove('-fsanitize=address')

config = Configure(denv)
res = config.CheckFunc(func_name)
config.Finish()

return res


def generate(env):
"""Add daos specific method to environment"""
env.AddMethod(_base_setup, 'compiler_setup')
env.AddMethod(_append_if_supported, "AppendIfSupported")
env.AddMethod(_check_func, "CheckFunc")


def exists(_env):
Expand Down
4 changes: 1 addition & 3 deletions src/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,10 @@ def scons():
base_env_mpi.AppendUnique(CPPPATH=[Dir('include')])

if not env.GetOption('clean') and not env.GetOption('help'):
conf = env.Clone().Configure()
# Detect if we have explicit_bzero
if not conf.CheckFunc('explicit_bzero'):
if not env.CheckFunc('explicit_bzero'):
env.Append(CCFLAGS=['-DNEED_EXPLICIT_BZERO'])
base_env.Append(CCFLAGS=['-DNEED_EXPLICIT_BZERO'])
conf.Finish()

for header in HEADERS:
header_file = os.path.join('include', header)
Expand Down
2 changes: 1 addition & 1 deletion src/client/dfs/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def configure_lustre(denv):
print("No installed Lustre version detected")
else:
print("Installed Lustre version detected")
if not conf.CheckFunc('llapi_unlink_foreign'):
if not denv.CheckFunc('llapi_unlink_foreign'):
print("Lustre version is not compatible")
else:
print("Lustre version is compatible")
Expand Down
3 changes: 2 additions & 1 deletion src/control/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ def get_build_flags(benv):
"""Return string of build flags"""
if is_release_build(benv):
return '-buildmode=pie'
# enable race detector for non-release builds
if benv["ADDRESS_SANITIZER"] == 1:
return '-asan'
return '-race'


Expand Down
8 changes: 4 additions & 4 deletions utils/ansible/ftest/templates/daos-make.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,10 @@ run $CLUSH_EXE $CLUSH_OPTS -l root -w $CLIENTS_LIST chmod 755 /usr/bin/dfuse
info "Updating dynamic linker configuration"
{% if "daos_clients" in groups and groups["daos_clients"] | length > 0 %}
run $CLUSH_EXE $CLUSH_OPTS -l root -w $SERVERS_LIST -w $CLIENTS_LIST rm -f /etc/ld.so.cache
run $CLUSH_EXE $CLUSH_OPTS -l root -w $SERVERS_LIST -w $CLIENTS_LIST ldconfig
run $CLUSH_EXE $CLUSH_OPTS -l root -w $SERVERS_LIST -w $CLIENTS_LIST ldconfig $DAOS_INSTALL_DIR/lib64 $DAOS_INSTALL_DIR/lib64/daos_srv
{% else %}
run $CLUSH_EXE $CLUSH_OPTS -l root -w $SERVERS_LIST rm -f /etc/ld.so.cache
run $CLUSH_EXE $CLUSH_OPTS -l root -w $SERVERS_LIST ldconfig
run $CLUSH_EXE $CLUSH_OPTS -l root -w $SERVERS_LIST ldconfig $DAOS_INSTALL_DIR/lib64 $DAOS_INSTALL_DIR/lib64/daos_srv
{% endif %}

if [[ $MPICH_PATH ]] ; then
Expand Down Expand Up @@ -542,8 +542,8 @@ fi
info "Updating dynamic linker configuration"
{% if "daos_clients" in groups and groups["daos_clients"] | length > 0 %}
run $CLUSH_EXE $CLUSH_OPTS -l root -w $SERVERS_LIST -w $CLIENTS_LIST rm -f /etc/ld.so.cache
run $CLUSH_EXE $CLUSH_OPTS -l root -w $SERVERS_LIST -w $CLIENTS_LIST ldconfig
run $CLUSH_EXE $CLUSH_OPTS -l root -w $SERVERS_LIST -w $CLIENTS_LIST ldconfig $DAOS_INSTALL_DIR/lib64 $DAOS_INSTALL_DIR/lib64/daos_srv
{% else %}
run $CLUSH_EXE $CLUSH_OPTS -l root -w $SERVERS_LIST rm -f /etc/ld.so.cache
run $CLUSH_EXE $CLUSH_OPTS -l root -w $SERVERS_LIST ldconfig
run $CLUSH_EXE $CLUSH_OPTS -l root -w $SERVERS_LIST ldconfig $DAOS_INSTALL_DIR/lib64 $DAOS_INSTALL_DIR/lib64/daos_srv
{% endif %}
13 changes: 12 additions & 1 deletion utils/rpms/daos.spec
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

Name: daos
Version: 2.4.2
Release: 4%{?relval}%{?dist}
Release: 5%{?relval}%{?dist}
Summary: DAOS Storage Engine

License: BSD-2-Clause-Patent
Expand Down Expand Up @@ -114,6 +114,14 @@ BuildRequires: libuct-devel
BuildRequires: ucx-devel
%endif

# Needed for support tasks
%if (0%{?rhel} >= 8)
BuildRequires: libasan
%endif
%if (0%{?suse_version} > 0)
BuildRequires: libasan8
%endif

Requires: openssl
# This should only be temporary until we can get a stable upstream release
# of mercury, at which time the autoprov shared library version should
Expand Down Expand Up @@ -555,6 +563,9 @@ getent passwd daos_agent >/dev/null || useradd -s /sbin/nologin -r -g daos_agent
# No files in a shim package

%changelog
* Fri May 31 2024 Cedric Koch-Hofer <cedric.koch-hofer@intel.com> 2.4.2-5
- Support release candidate for 2.4.2

* Mon Mar 04 2024 Phillip Henderson <phillip.henderson@intel.com> 2.4.2-4
- Third release candidate for 2.4.2

Expand Down
1 change: 1 addition & 0 deletions utils/scripts/install-el8.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ dnf --nodocs install \
java-1.8.0-openjdk \
json-c-devel \
libaio-devel \
libasan \
libcmocka-devel \
libevent-devel \
libiscsi-devel \
Expand Down
1 change: 1 addition & 0 deletions utils/scripts/install-el9.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ dnf --nodocs install \
java-1.8.0-openjdk \
json-c-devel \
libaio-devel \
libasan \
libcmocka-devel \
libevent-devel \
libipmctl-devel \
Expand Down
1 change: 1 addition & 0 deletions utils/scripts/install-leap15.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ dnf --nodocs install \
hwloc-devel \
java-1_8_0-openjdk-devel \
libaio-devel \
libasan8 \
libcmocka-devel \
libcapstone-devel \
libevent-devel \
Expand Down
1 change: 1 addition & 0 deletions utils/scripts/install-ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ apt-get install \
golang-go \
kmod \
libaio-dev \
libasan8 \
libboost-dev \
libcapstone-dev \
libcmocka-dev \
Expand Down
4 changes: 4 additions & 0 deletions utils/sl/fake_scons/SCons/Script/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,10 @@ def require(self, env, *kw, headers_only=False):
"""Fake require"""
return

def CheckFunc(self, func_name):
"""Fake CheckFunc"""
return


class Variables():
"""Fake variables"""
Expand Down
Loading