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