Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

libsubcmd: Make _FORTIFY_SOURCE defines dependent on the feature

Unconditionally defining _FORTIFY_SOURCE can break tools that don't work
with it, such as memory sanitizers:

https://github.com/google/sanitizers/wiki/AddressSanitizer#faq

Fixes: 4b6ab94eabe4 ("perf subcmd: Create subcmd library")
Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lore.kernel.org/lkml/20190925195924.152834-1-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
4b0b2b09 da05b5ea

+7 -1
+7 -1
tools/lib/subcmd/Makefile
··· 20 20 LIBFILE = $(OUTPUT)libsubcmd.a 21 21 22 22 CFLAGS := $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) 23 - CFLAGS += -ggdb3 -Wall -Wextra -std=gnu99 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC 23 + CFLAGS += -ggdb3 -Wall -Wextra -std=gnu99 -fPIC 24 + 25 + ifeq ($(DEBUG),0) 26 + ifeq ($(feature-fortify-source), 1) 27 + CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 28 + endif 29 + endif 24 30 25 31 ifeq ($(CC_NO_CLANG), 0) 26 32 CFLAGS += -O3