From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753762AbbE0QwA (ORCPT ); Wed, 27 May 2015 12:52:00 -0400 Received: from terminus.zytor.com ([198.137.202.10]:39116 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751587AbbE0Qv6 (ORCPT ); Wed, 27 May 2015 12:51:58 -0400 Date: Wed, 27 May 2015 09:51:45 -0700 From: tip-bot for Martin Liska Message-ID: Cc: mingo@kernel.org, mliska@suse.cz, acme@redhat.com, linux-kernel@vger.kernel.org, hpa@zytor.com, tglx@linutronix.de Reply-To: mingo@kernel.org, mliska@suse.cz, acme@redhat.com, linux-kernel@vger.kernel.org, hpa@zytor.com, tglx@linutronix.de In-Reply-To: <5564393C.1090104@suse.cz> References: <5564393C.1090104@suse.cz> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf tools: Improve setting of gcc debug option Git-Commit-ID: e8b7ea4356fdd3c4de5478f3418eb84f8dce2b61 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: e8b7ea4356fdd3c4de5478f3418eb84f8dce2b61 Gitweb: http://git.kernel.org/tip/e8b7ea4356fdd3c4de5478f3418eb84f8dce2b61 Author: Martin Liska AuthorDate: Tue, 26 May 2015 12:23:24 -0300 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 27 May 2015 12:21:45 -0300 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 Acked-by: Ingo Molnar Link: http://lkml.kernel.org/r/5564393C.1090104@suse.cz Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/config/Makefile | 2 ++ tools/perf/config/utilities.mak | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index e3b3724..317001c 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -130,6 +130,8 @@ endif ifeq ($(DEBUG),0) CFLAGS += -O6 +else + CFLAGS += $(call cc-option,-Og,-O0) endif ifdef PARSER_DEBUG diff --git a/tools/perf/config/utilities.mak b/tools/perf/config/utilities.mak index c16ce83..0ebef09 100644 --- a/tools/perf/config/utilities.mak +++ b/tools/perf/config/utilities.mak @@ -177,3 +177,22 @@ $(if $($(1)),$(call _ge_attempt,$($(1)),$(1)),$(call _ge_attempt,$(2))) endef _ge_attempt = $(if $(get-executable),$(get-executable),$(call _gea_err,$(2))) _gea_err = $(if $(1),$(error Please set '$(1)' appropriately)) + +# try-run +# Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise) +# Exit code chooses option. "$$TMP" is can be used as temporary file and +# is automatically cleaned up. +try-run = $(shell set -e; \ + TMP="$(TMPOUT).$$$$.tmp"; \ + TMPO="$(TMPOUT).$$$$.o"; \ + if ($(1)) >/dev/null 2>&1; \ + then echo "$(2)"; \ + else echo "$(3)"; \ + fi; \ + rm -f "$$TMP" "$$TMPO") + +# cc-option +# Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586) + +cc-option = $(call try-run,\ + $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2))