From patchwork Sun Aug 13 19:08:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christopher Li X-Patchwork-Id: 9898005 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8B99260351 for ; Sun, 13 Aug 2017 19:08:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7CC782841D for ; Sun, 13 Aug 2017 19:08:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7166D2858A; Sun, 13 Aug 2017 19:08:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E9D872841D for ; Sun, 13 Aug 2017 19:08:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751141AbdHMTIk (ORCPT ); Sun, 13 Aug 2017 15:08:40 -0400 Received: from mail-yw0-f194.google.com ([209.85.161.194]:33260 "EHLO mail-yw0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751057AbdHMTIj (ORCPT ); Sun, 13 Aug 2017 15:08:39 -0400 Received: by mail-yw0-f194.google.com with SMTP id u207so5088132ywc.0 for ; Sun, 13 Aug 2017 12:08:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:from:date:message-id:subject:to:cc; bh=Yg+rzmt63PqxQKvWPBG3GD+93JcwCP7S+BKz6uho3XU=; b=S30AT2dtX4+Za6PGeQ8A5YhO5t6xm9nYP3djWLJhq3vyREP8UP2Fmm8PO6zKk3jK9b 0LLH5dOMq4uZi+QHr1w+4b/t8ANvy7nWx6FFnjZcTx37YCDagmZz/BC6HJlpEal+GQRn pS/XyOUA8ChxumeBS4NJAHoL+rgNO3IWzfGFdaNHCA9yYOqJE6/7lT8t/bzLOMl3lJ+0 gk3ZdUkpkXMEScY2JHImfnUY1KvDHY0stFAjwYAtgNIZTtGYhpu01xqzMJyHqN8L8piZ Qsf73NAg/wkSUCfAfFMXc698S0P4FFGu1dtVlmNXUhggKNHr5OHQvkkzpiCU0R2oJxxN vB+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:from:date:message-id:subject :to:cc; bh=Yg+rzmt63PqxQKvWPBG3GD+93JcwCP7S+BKz6uho3XU=; b=MMaVv74ZY6i4UKxSViXmwtNbh/1c7oz3Xdw5DFOyFMRM/yyhS8RRj3nkoNoB58JuHb 3wttk5ecPLykr3NSsieAqERTDgr98qtjLUAnqYo0Z0tToejnt+9dAioNz0AesP9T75CS j2ep15KBaAgA/JzKWEUOj+0zQ2M9xfDW6cfZp2gzBb6YjQfTgN3AQmsayCqGIhS/LsHW XSwUkTxULYnDPeip0SQ7DAa5SitPtiRmvU9N6DVEI1VBt4rarZ8rIb15YrY5N/BgXJB/ XQhMVA4GREEGX4SATwmz0SXBe52IwnAxKaN16tRswLfZEVZDl7QFSKokqku4Pjfy9cPv ItnA== X-Gm-Message-State: AHYfb5j1SWqlu79Yx6TKoBDpYo7Y3HnRW8Ji9Ozh2tHxhwQKKVUSR9hh bDuVoC6ifehj3XPdVauO8J+Gh5OtzTFh X-Received: by 10.129.183.20 with SMTP id v20mr18560142ywh.377.1502651318991; Sun, 13 Aug 2017 12:08:38 -0700 (PDT) MIME-Version: 1.0 Received: by 10.129.68.39 with HTTP; Sun, 13 Aug 2017 12:08:38 -0700 (PDT) From: Christopher Li Date: Sun, 13 Aug 2017 15:08:38 -0400 X-Google-Sender-Auth: yzpSEx8JyCJEzuMRmfq7DttesD8 Message-ID: Subject: [PATCH 1/4] Makefile: adding debug version of sparse To: Linux-Sparse Cc: Luc Van Oostenryck Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The debug version has the -DSPARSE_DEBUG enabled. It is intended to include more verification in the debug version. For now the debug version remain the same as the release version. Because the debug version has different compile flags, all *.o file need to be recompile under the debug flag. These debug version object file is stored in debug/ directory. -dbg is the finial debug version of the program . Full compile time is doubled because every thing needs to compile twice. One for release version. One for debug version. Signed-off-by: Christopher Li --- Makefile | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) $(warning Your system does not have gtk3/gtk2, disabling test-inspect) @@ -165,8 +168,13 @@ SED_PC_CMD = 's|@version@|$(VERSION)|g; \ # Allow users to override build settings without dirtying their trees -include local.mk +DBG_PROGRAMS := $(addprefix debug/, $(addsuffix -dbg, $(PROGRAMS))) +DBG_LIB_FILE := $(addprefix debug/, $(LIB_FILE)) +DBG_LIB_OBJS := $(addprefix debug/, $(LIB_OBJS)) +DBG_SLIB_FILE := $(addprefix debug/, $(SLIB_FILE)) +DBG_LIBS := $(addprefix debug/, $(LIBS)) -all: $(PROGRAMS) sparse.pc +all: $(PROGRAMS) $(DBG_PROGRAMS) sparse.pc all-installable: $(INST_PROGRAMS) $(LIBS) $(LIB_H) sparse.pc @@ -189,14 +197,24 @@ sparse.pc: sparse.pc.in compile_EXTRA_DEPS = compile-i386.o $(foreach p,$(PROGRAMS),$(eval $(p): $($(p)_EXTRA_DEPS) $(LIBS))) +$(foreach p,$(PROGRAMS),$(eval debug/$(p)-dbg: $(addprefix debug/, $($(p)_EXTRA_DEPS)) $(DBG_LIBS))) + + $(PROGRAMS): % : %.o $(QUIET_LINK)$(LD) $(LDFLAGS) -o $@ $^ $($@_EXTRA_OBJS) +$(DBG_PROGRAMS): debug/%-dbg : debug/%.o + $(eval EXTRA := $($(@F:-dbg=)_EXTRA_OBJS)) + $(QUIET_LINK)$(LD) $(LDFLAGS) -o $@ $^ $(EXTRA) $(LIB_FILE): $(LIB_OBJS) $(QUIET_AR)$(AR) rcs $@ $(LIB_OBJS) +$(DBG_LIB_FILE): $(DBG_LIB_OBJS) + $(QUIET_AR)$(AR) rcs $@ $(DBG_LIB_OBJS) $(SLIB_FILE): $(LIB_OBJS) $(QUIET_LINK)$(CC) $(LDFLAGS) -Wl,-soname,$@ -shared -o $@ $(LIB_OBJS) +$(DBG_SLIB_FILE): $(DBG_LIB_OBJS) + $(QUIET_LINK)$(CC) $(LDFLAGS) -Wl,-soname,$@ -shared -o $@ $(DBG_LIB_OBJS) DEP_FILES := $(wildcard .*.o.d) @@ -204,21 +222,31 @@ ifneq ($(DEP_FILES),) include $(DEP_FILES) endif -c2xml.o c2xml.sc: CFLAGS += $(LIBXML_CFLAGS) +c2xml.o c2xml.sc debug/c2xml.o debug/c2xml.sc: CFLAGS += $(LIBXML_CFLAGS) -pre-process.sc: CHECKER_FLAGS += -Wno-vla +pre-process.sc debug/pre-process.sc: CHECKER_FLAGS += -Wno-vla +debug: + @mkdir debug + +debug/%.o: %.c $(LIB_H) | debug + $(QUIET_CC)$(CC) -o $@ -c $(DBG_CFLAGS) $< %.o: %.c $(LIB_H) $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $< +debug/%.sc: %.c sparse + $(QUIET_CHECK) $(CHECKER) $(CHECKER_FLAGS) -c $(DBG_CFLAGS) $< %.sc: %.c sparse $(QUIET_CHECK) $(CHECKER) $(CHECKER_FLAGS) -c $(ALL_CFLAGS) $< -ALL_OBJS := $(LIB_OBJS) $(foreach p,$(PROGRAMS),$(p).o $($(p)_EXTRA_DEPS)) +ALL_OBJS := $(LIB_OBJS) $(DBG_LIB_OBJS) \ + $(foreach p,$(PROGRAMS),$(p).o debug/$(p).o $($(p)_EXTRA_DEPS) debug/$($(p)_EXTRA_DEPS)) + selfcheck: $(ALL_OBJS:.o=.sc) clean: clean-check + rm -rf debug rm -f *.[oa] .*.d *.so $(PROGRAMS) $(SLIB_FILE) pre-process.h sparse.pc dist: diff --git a/Makefile b/Makefile index 48e1f50..6660220 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,7 @@ OS = linux CC = gcc CFLAGS = -O2 -finline-functions -fno-strict-aliasing -g CFLAGS += -Wall -Wwrite-strings +DBG_CFLAGS = $(ALL_CFLAGS) -DSPARSE_DEBUG LDFLAGS += -g LD = gcc AR = ar @@ -83,7 +84,9 @@ PROGRAMS += test-inspect INST_PROGRAMS += test-inspect test-inspect_EXTRA_DEPS := ast-model.o ast-view.o ast-inspect.o test-inspect_OBJS := test-inspect.o $(test-inspect_EXTRA_DEPS) -$(test-inspect_OBJS) $(test-inspect_OBJS:.o=.sc): CFLAGS += $(GTK_CFLAGS) + +$(test-inspect_OBJS) $(test-inspect_OBJS:.o=.sc) \ +$(addprefix debug/, $(test-inspect_OBJS) $(test-inspect_OBJS:.o=.sc)) : CFLAGS += $(GTK_CFLAGS) test-inspect_EXTRA_OBJS := $(GTK_LIBS) else