1# SPDX-License-Identifier: GPL-2.0-or-later 2 3CFLAGS += $(KHDR_INCLUDES) 4CFLAGS += -Wall -O2 -g $(TOOLS_INCLUDES) 5TEST_GEN_PROGS := openat2_test resolve_test rename_attack_test emptypath_test 6 7LOCAL_HDRS += helpers.h 8 9include ../../lib.mk 10 11# gcc requires -static-libasan in order to ensure that Address Sanitizer's 12# library is the first one loaded. However, clang already statically links the 13# Address Sanitizer if -fsanitize is specified. Therefore, simply omit 14# -static-libasan for clang builds. 15SANITIZER_CFLAGS := -fsanitize=address -fsanitize=undefined 16ifeq ($(LLVM),) 17 SANITIZER_CFLAGS += -static-libasan 18endif 19 20# Build without the sanitizers when the toolchain cannot link them. 21ifeq ($(shell echo 'int main(void) { return 0; }' | $(CC) $(CFLAGS) \ 22 $(SANITIZER_CFLAGS) $(LDFLAGS) -x c - -o /dev/null >/dev/null 2>&1 && \ 23 echo y),y) 24CFLAGS += $(SANITIZER_CFLAGS) 25endif 26