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

perf tools: Improve setting of gcc debug option

Correct debugging experience is given by passing -Og to compiler.

Do it in a way that supports older compilers

Signed-off-by: Martin Liska <mliska@suse.cz>
Acked-by: Ingo Molnar <mingo@kernel.org>
Link: http://lkml.kernel.org/r/5564393C.1090104@suse.cz
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Martin Liska and committed by
Arnaldo Carvalho de Melo
e8b7ea43 5bcaaca3

+21
+2
tools/perf/config/Makefile
··· 130 130 131 131 ifeq ($(DEBUG),0) 132 132 CFLAGS += -O6 133 + else 134 + CFLAGS += $(call cc-option,-Og,-O0) 133 135 endif 134 136 135 137 ifdef PARSER_DEBUG
+19
tools/perf/config/utilities.mak
··· 177 177 endef 178 178 _ge_attempt = $(if $(get-executable),$(get-executable),$(call _gea_err,$(2))) 179 179 _gea_err = $(if $(1),$(error Please set '$(1)' appropriately)) 180 + 181 + # try-run 182 + # Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise) 183 + # Exit code chooses option. "$$TMP" is can be used as temporary file and 184 + # is automatically cleaned up. 185 + try-run = $(shell set -e; \ 186 + TMP="$(TMPOUT).$$$$.tmp"; \ 187 + TMPO="$(TMPOUT).$$$$.o"; \ 188 + if ($(1)) >/dev/null 2>&1; \ 189 + then echo "$(2)"; \ 190 + else echo "$(3)"; \ 191 + fi; \ 192 + rm -f "$$TMP" "$$TMPO") 193 + 194 + # cc-option 195 + # Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586) 196 + 197 + cc-option = $(call try-run,\ 198 + $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2))