Ashish Sangwan has uploaded this change for review.

View Change

From 2.8 onwards, ASAN not working for libganesha_nfsd

Currently getting this warning when I enabled address sanitizer:
CMake Warning at cmake/modules/sanitize-helpers.cmake:161 (message):
AddressSanitizer disabled for target ganesha_nfsd because there is no
sanitizer available for target sources.
Call Stack (most recent call first):
cmake/modules/FindASan.cmake:58 (sanitizer_add_flags)

The reason is because the library libganesha_nfsd is made up entirely
of object libraries without any source files of its own and hence
the cmake script sanitizer_add_flags rejects enabling sanitizer for it.
Current patch removes creating of FsalCore as Object library and instead
directly add the c files as sources of target ganesha_nfsd. This is inline
to what is suggessted in the cmake documentation:
"Some native build systems (such as Xcode) may not like targets that have only
object files, so consider adding at least one real source file to any target that
references $<TARGET_OBJECTS:objlib>."
https://cmake.org/cmake/help/v3.12/command/add_library.html

The other change in this patch is that when SANITIZE_ADDRESS is enabled we
should not use --no-undefined as mentioned in the ASAN docs:
Q: When I link my shared library with -fsanitize=address, it fails due to some
undefined ASan symbols (e.g. asan_init_v4)?

A: Most probably you link with -Wl,-z,defs or -Wl,--no-undefined.
These flags don't work with ASan unless you also use -shared-libasan
(which is the default mode for GCC, but not for Clang).
https://github.com/google/sanitizers/wiki/AddressSanitizer

Signed-off-by: ashish.sangwan <ashishsangwan2@gmail.com>
Change-Id: Ibaf837804eed595eaa990b40b1ea5e11a229d571
---
M src/MainNFSD/CMakeLists.txt
1 file changed, 9 insertions(+), 8 deletions(-)

git pull ssh://review.gerrithub.io:29418/ffilz/nfs-ganesha refs/changes/79/492079/1

To view, visit change 492079. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: ffilz/nfs-ganesha
Gerrit-Branch: next
Gerrit-Change-Id: Ibaf837804eed595eaa990b40b1ea5e11a229d571
Gerrit-Change-Number: 492079
Gerrit-PatchSet: 1
Gerrit-Owner: Ashish Sangwan <ashishsangwan2@gmail.com>
Gerrit-MessageType: newchange