[asterisk-commits] kpfleming: branch 1.4 r157859 - in /branches/1.4: ./ channels/ channels/misdn...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Nov 19 15:34:48 CST 2008


Author: kpfleming
Date: Wed Nov 19 15:34:47 2008
New Revision: 157859

URL: http://svn.digium.com/view/asterisk?view=rev&rev=157859
Log:
the gcc optimizer frequently finds broken code (use of uninitalized variables, unreachable code, etc.), which is good. however, developers usually compile with the optimizer turned off, because if they need to debug the resulting code, optimized code makes that process very difficult. this means that we get code changes committed that weren't adequately checked over for these sorts of problems.

with this build system change, if (and only if) --enable-dev-mode was used and DONT_OPTIMIZE is turned on, when a source file is compiled it will actually be preprocessed (into a .i or .ii file), then compiled once with optimization (with the result sent to /dev/null) and again without optimization (but only if the first compile succeeded, of course).

while making these changes, i did some cleanup work in Makefile.rules to move commonly-used combinations of flag variables into their own variables, to make the file easier to read and maintain


Modified:
    branches/1.4/Makefile.moddir_rules
    branches/1.4/Makefile.rules
    branches/1.4/channels/   (props changed)
    branches/1.4/channels/misdn/   (props changed)
    branches/1.4/channels/misdn/Makefile
    branches/1.4/codecs/gsm/Makefile
    branches/1.4/codecs/gsm/src/   (props changed)
    branches/1.4/main/db1-ast/Makefile
    branches/1.4/main/db1-ast/btree/   (props changed)
    branches/1.4/main/db1-ast/db/   (props changed)
    branches/1.4/main/db1-ast/hash/   (props changed)
    branches/1.4/main/db1-ast/mpool/   (props changed)
    branches/1.4/main/db1-ast/recno/   (props changed)
    branches/1.4/main/stdtime/   (props changed)
    branches/1.4/main/stdtime/Makefile
    branches/1.4/pbx/Makefile
    branches/1.4/pbx/ael/   (props changed)
    branches/1.4/res/Makefile
    branches/1.4/res/snmp/   (props changed)

Modified: branches/1.4/Makefile.moddir_rules
URL: http://svn.digium.com/view/asterisk/branches/1.4/Makefile.moddir_rules?view=diff&rev=157859&r1=157858&r2=157859
==============================================================================
--- branches/1.4/Makefile.moddir_rules (original)
+++ branches/1.4/Makefile.moddir_rules Wed Nov 19 15:34:47 2008
@@ -64,7 +64,7 @@
 	@for file in $(patsubst %,$(SUBDIR)/%,$(filter-out %.o,$^)); do echo "INPUT (../$${file})" >> $@; done
 
 clean::
-	rm -f *.so *.o *.oo *.s *.i
+	rm -f *.so *.o *.oo *.s *.i *.ii
 	rm -f .*.o.d .*.oo.d
 	rm -f modules.link
 

Modified: branches/1.4/Makefile.rules
URL: http://svn.digium.com/view/asterisk/branches/1.4/Makefile.rules?view=diff&rev=157859&r1=157858&r2=157859
==============================================================================
--- branches/1.4/Makefile.rules (original)
+++ branches/1.4/Makefile.rules Wed Nov 19 15:34:47 2008
@@ -3,7 +3,7 @@
 # 
 # Makefile rules
 #
-# Copyright (C) 2006, Digium, Inc.
+# Copyright (C) 2006-2008, Digium, Inc.
 #
 # Kevin P. Fleming <kpfleming at digium.com>
 #
@@ -19,44 +19,95 @@
 
 .PHONY: dist-clean
 
+# extra cflags to build dependencies. Recursively expanded.
+MAKE_DEPS=-MD -MT $@ -MF .$(subst /,_,$@).d -MP
+
 ifeq ($(NOISY_BUILD),)
-   ECHO_PREFIX=@
-   CMD_PREFIX=@
+    ECHO_PREFIX=@
+    CMD_PREFIX=@
 else
-   ECHO_PREFIX=@\# 
-   CMD_PREFIX=
+    ECHO_PREFIX=@\# 
+    CMD_PREFIX=
 endif
 
+OPTIMIZE?=-O6
+
 ifeq ($(findstring DONT_OPTIMIZE,$(MENUSELECT_CFLAGS)),)
-# More GSM codec optimization
-# Uncomment to enable MMXTM optimizations for x86 architecture CPU's
-# which support MMX instructions.  This should be newer pentiums,
-# ppro's, etc, as well as the AMD K6 and K7.  
-#K6OPT=-DK6OPT
+    # More GSM codec optimization
+    # Uncomment to enable MMXTM optimizations for x86 architecture CPU's
+    # which support MMX instructions.  This should be newer pentiums,
+    # ppro's, etc, as well as the AMD K6 and K7.  
+    #K6OPT=-DK6OPT
 
-OPTIMIZE?=-O6
-ASTCFLAGS+=$(OPTIMIZE)
+    ASTCFLAGS+=$(OPTIMIZE)
 endif
+
+# shortcuts for common combinations of flags; these must be recursively expanded so that
+# per-target settings will be applied
+CC_CFLAGS=$(PTHREAD_CFLAGS) $(ASTCFLAGS)
+CXX_CFLAGS=$(PTHREAD_CFLAGS) $(filter-out -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(AST_DECLARATION_AFTER_STATEMENT),$(ASTCFLAGS))
+CC_LDFLAGS_SO=$(PTHREAD_CFLAGS) $(ASTLDFLAGS) $(SOLINK)
+CXX_LDFLAGS_SO=$(PTHREAD_CFLAGS) $(ASTLDFLAGS) $(SOLINK)
+CC_LIBS=$(PTHREAD_LIBS) $(LIBS)
+CXX_LIBS=$(PTHREAD_LIBS) $(LIBS)
+
+# determine whether to double-compile so that the optimizer can report code path problems
+# this is only done when developer mode and DONT_OPTIMIZE are both enabled
+# in that case, we run the preprocessor to produce a .i or .ii file from the source
+# code, then compile once with optimizer enabled (and the output to /dev/null),
+# and if that doesn't fail then compile again with optimizer disabled
+ifeq ($(findstring DONT_OPTIMIZE,$(MENUSELECT_CFLAGS))$(AST_DEVMODE),DONT_OPTIMIZEyes)
+COMPILE_DOUBLE=yes
+endif
+
+%.o: %.s
+	$(ECHO_PREFIX) echo "   [AS] $< -> $@"
+ifeq ($(COMPILE_DOUBLE),yes)
+	$(CMD_PREFIX) $(CC) -o /dev/null -c $< $(CC_CFLAGS) $(OPTIMIZE)
+endif
+	$(CMD_PREFIX) $(CC) -o $@ -c $< $(CC_CFLAGS)
+
+%.o: %.i
+	$(ECHO_PREFIX) echo "   [CCi] $< -> $@"
+ifeq ($(COMPILE_DOUBLE),yes)
+	$(CMD_PREFIX) $(CC) -o /dev/null -c $< $(CC_CFLAGS) $(OPTIMIZE)
+endif
+	$(CMD_PREFIX) $(CC) -o $@ -c $< $(CC_CFLAGS)
 
 %.o: %.c
 	$(ECHO_PREFIX) echo "   [CC] $< -> $@"
-	$(CMD_PREFIX) $(CC) -o $@ -c $< $(PTHREAD_CFLAGS) $(ASTCFLAGS) -MD -MT $@ -MF .$(subst /,_,$@).d -MP
-
-%.o: %.i
-	$(ECHO_PREFIX) echo "   [CCi] $< -> $@"
-	$(CMD_PREFIX) $(CC) -o $@ -c $< $(PTHREAD_CFLAGS) $(ASTCFLAGS) -MD -MT $@ -MF .$(subst /,_,$@).d -MP
+ifeq ($(COMPILE_DOUBLE),yes)
+	$(CMD_PREFIX) $(CC) -o $(@:%.o=%.i) -E $< $(CC_CFLAGS) $(MAKE_DEPS)
+	$(CMD_PREFIX) $(CC) -o /dev/null -c $(@:%.o=%.i) $(CC_CFLAGS) $(OPTIMIZE)
+	$(CMD_PREFIX) $(CC) -o $@ -c $(@:%.o=%.i) $(CC_CFLAGS)
+else
+	$(CMD_PREFIX) $(CC) -o $@ -c $< $(CC_CFLAGS) $(MAKE_DEPS)
+endif
 
 %.i: %.c
 	$(ECHO_PREFIX) echo "   [CPP] $< -> $@"
-	$(CMD_PREFIX) $(CC) -o $@ -E $< $(PTHREAD_CFLAGS) $(ASTCFLAGS) -MD -MT $@ -MF .$(subst /,_,$@).d -MP
+	$(CMD_PREFIX) $(CC) -o $@ -E $< $(CC_CFLAGS) $(MAKE_DEPS)
 
-%.o: %.s
-	$(ECHO_PREFIX) echo "   [AS] $< -> $@"
-	$(CMD_PREFIX) $(CC) -o $@ -c $< $(PTHREAD_CFLAGS) $(ASTCFLAGS) -MD -MT $@ -MF .$(subst /,_,$@).d -MP
+%.oo: %.ii
+	$(ECHO_PREFIX) echo "   [CXXi] $< -> $@"
+ifeq ($(COMPILE_DOUBLE),yes)
+	$(CMD_PREFIX) $(CXX) -o /dev/null -c $< $(CXX_CFLAGS) $(OPTIMIZE)
+endif
+	$(CMD_PREFIX) $(CXX) -o $@ -c $< $(CXX_CFLAGS)
 
 %.oo: %.cc
 	$(ECHO_PREFIX) echo "   [CXX] $< -> $@"
-	$(CMD_PREFIX) $(CXX) -o $@ -c $< $(PTHREAD_CFLAGS) $(filter-out -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(AST_DECLARATION_AFTER_STATEMENT),$(ASTCFLAGS)) -MD -MT $@ -MF .$(subst /,_,$@).d -MP
+ifeq ($(COMPILE_DOUBLE),yes)
+	$(CMD_PREFIX) $(CXX) -o $(@:%.oo=%.ii) -E $< $(CXX_CFLAGS) $(MAKE_DEPS)
+	$(CMD_PREFIX) $(CXX) -o /dev/null -c $(@:%.oo=%.ii) $(CXX_CFLAGS) $(MAKE_DEPS) $(OPTIMIZE)
+	$(CMD_PREFIX) $(CXX) -o $@ -c $(@:%.oo=%.ii) $(CXX_CFLAGS) $(MAKE_DEPS)
+else
+	$(CMD_PREFIX) $(CXX) -o $@ -c $< $(CXX_CFLAGS) $(MAKE_DEPS)
+endif
+
+%.ii: %.cc
+	$(ECHO_PREFIX) echo "   [CPP] $< -> $@"
+	$(CMD_PREFIX) $(CXX) -o $@ -E $< $(CXX_CFLAGS) $(MAKE_DEPS)
 
 %.c: %.y
 	$(ECHO_PREFIX) echo "   [BISON] $< -> $@"
@@ -68,14 +119,14 @@
 
 %.so: %.o
 	$(ECHO_PREFIX) echo "   [LD] $^ -> $@"
-	$(CMD_PREFIX) $(CC) $(STATIC_BUILD) -o $@ $(PTHREAD_CFLAGS) $(ASTLDFLAGS) $(SOLINK) $^ $(PTHREAD_LIBS) $(LIBS)
+	$(CMD_PREFIX) $(CC) $(STATIC_BUILD) -o $@ $(CC_LDFLAGS_SO) $^ $(CC_LIBS)
 
 %.so: %.oo
 	$(ECHO_PREFIX) echo "   [LDXX] $^ -> $@"
-	$(CMD_PREFIX) $(CXX) $(STATIC_BUILD) -o $@ $(PTHREAD_CFLAGS) $(ASTLDFLAGS) $(SOLINK) $^ $(PTHREAD_LIBS) $(LIBS)
+	$(CMD_PREFIX) $(CXX) $(STATIC_BUILD) -o $@ $(CXX_LDFLAGS_SO) $^ $(CXX_LIBS)
 
 %: %.o
 	$(ECHO_PREFIX) echo "   [LD] $^ -> $@"
-	$(CMD_PREFIX) $(CXX) $(STATIC_BUILD) -o $@ $(PTHREAD_CFLAGS) $(ASTLDFLAGS) $^ $(PTHREAD_LIBS) $(LIBS)
+	$(CMD_PREFIX) $(CXX) $(STATIC_BUILD) -o $@ $(PTHREAD_CFLAGS) $(ASTLDFLAGS) $^ $(CXX_LIBS)
 
 dist-clean:: clean

Propchange: branches/1.4/channels/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Wed Nov 19 15:34:47 2008
@@ -1,6 +1,7 @@
 *.a
 *.d
 *.i
+*.ii
 *.oo
 *.makeopts
 *.moduleinfo

Propchange: branches/1.4/channels/misdn/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Wed Nov 19 15:34:47 2008
@@ -1,1 +1,2 @@
 *.a
+*.i

Modified: branches/1.4/channels/misdn/Makefile
URL: http://svn.digium.com/view/asterisk/branches/1.4/channels/misdn/Makefile?view=diff&rev=157859&r1=157858&r2=157859
==============================================================================
--- branches/1.4/channels/misdn/Makefile (original)
+++ branches/1.4/channels/misdn/Makefile Wed Nov 19 15:34:47 2008
@@ -14,4 +14,4 @@
 	$(CC) -o $@ $^ -lisdnnet -lmISDN -lpthread
 
 clean: 
-	rm -rf *.a *.o *.so portinfo
+	rm -rf *.a *.o *.so portinfo *.i

Modified: branches/1.4/codecs/gsm/Makefile
URL: http://svn.digium.com/view/asterisk/branches/1.4/codecs/gsm/Makefile?view=diff&rev=157859&r1=157858&r2=157859
==============================================================================
--- branches/1.4/codecs/gsm/Makefile (original)
+++ branches/1.4/codecs/gsm/Makefile Wed Nov 19 15:34:47 2008
@@ -477,7 +477,7 @@
 			$(TOAST) $(TCAT) $(UNTOAST)	\
 			$(ROOT)/gsm-1.0.tar.Z
 		rm -rf lib
-		rm -f .*.d
+		rm -f .*.d *.i */*.i
 
 # Two tools that helped me generate gsm_encode.c and gsm_decode.c,
 # but aren't generally needed to port this.

Propchange: branches/1.4/codecs/gsm/src/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Nov 19 15:34:47 2008
@@ -1,0 +1,1 @@
+*.i

Modified: branches/1.4/main/db1-ast/Makefile
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/db1-ast/Makefile?view=diff&rev=157859&r1=157858&r2=157859
==============================================================================
--- branches/1.4/main/db1-ast/Makefile (original)
+++ branches/1.4/main/db1-ast/Makefile Wed Nov 19 15:34:47 2008
@@ -46,7 +46,7 @@
 clean-depend:
 
 clean:
-	rm -f $(LIBDB) $(LIBDBSO) $(OBJS) $(SHOBJS) *.s *.i
+	rm -f $(LIBDB) $(LIBDBSO) $(OBJS) $(SHOBJS) */*.s */*.i
 
 ASTCFLAGS:=-Wall -D__DBINTERFACE_PRIVATE -I. -I.. -Iinclude -Ihash -Ibtree -Irecno $(ASTCFLAGS)
 

Propchange: branches/1.4/main/db1-ast/btree/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Nov 19 15:34:47 2008
@@ -1,0 +1,1 @@
+*.i

Propchange: branches/1.4/main/db1-ast/db/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Nov 19 15:34:47 2008
@@ -1,0 +1,1 @@
+*.i

Propchange: branches/1.4/main/db1-ast/hash/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Nov 19 15:34:47 2008
@@ -1,0 +1,1 @@
+*.i

Propchange: branches/1.4/main/db1-ast/mpool/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Nov 19 15:34:47 2008
@@ -1,0 +1,1 @@
+*.i

Propchange: branches/1.4/main/db1-ast/recno/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Nov 19 15:34:47 2008
@@ -1,0 +1,1 @@
+*.i

Propchange: branches/1.4/main/stdtime/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Wed Nov 19 15:34:47 2008
@@ -1,3 +1,4 @@
 .depend
 *.a
 *.so
+*.i

Modified: branches/1.4/main/stdtime/Makefile
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/stdtime/Makefile?view=diff&rev=157859&r1=157858&r2=157859
==============================================================================
--- branches/1.4/main/stdtime/Makefile (original)
+++ branches/1.4/main/stdtime/Makefile Wed Nov 19 15:34:47 2008
@@ -14,7 +14,7 @@
 	rm -f .depend
 
 clean: clean-depend
-	rm -f libtime.a *.o test
+	rm -f libtime.a *.o test *.i
 
 depend: .depend
 

Modified: branches/1.4/pbx/Makefile
URL: http://svn.digium.com/view/asterisk/branches/1.4/pbx/Makefile?view=diff&rev=157859&r1=157858&r2=157859
==============================================================================
--- branches/1.4/pbx/Makefile (original)
+++ branches/1.4/pbx/Makefile Wed Nov 19 15:34:47 2008
@@ -32,7 +32,7 @@
 include $(ASTTOPDIR)/Makefile.moddir_rules
 
 clean::
-	rm -f ael/*.o
+	rm -f ael/*.o ael/*.i
 
 ael/ael_lex.o: ael/ael_lex.c ../include/asterisk/ael_structs.h ael/ael.tab.h
 ael/ael_lex.o: ASTCFLAGS+=-I. -Wno-unused

Propchange: branches/1.4/pbx/ael/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Wed Nov 19 15:34:47 2008
@@ -1,1 +1,2 @@
 ael.output
+*.i

Modified: branches/1.4/res/Makefile
URL: http://svn.digium.com/view/asterisk/branches/1.4/res/Makefile?view=diff&rev=157859&r1=157858&r2=157859
==============================================================================
--- branches/1.4/res/Makefile (original)
+++ branches/1.4/res/Makefile Wed Nov 19 15:34:47 2008
@@ -36,4 +36,4 @@
 $(if $(filter res_snmp,$(EMBEDDED_MODS)),modules.link,res_snmp.so): snmp/agent.o
 
 clean::
-	rm -f snmp/*.o
+	rm -f snmp/*.o snmp/*.i

Propchange: branches/1.4/res/snmp/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Nov 19 15:34:47 2008
@@ -1,0 +1,1 @@
+*.i




More information about the asterisk-commits mailing list