changeset 14108:8d40b8fbaa54

3735 should include an empty make variable in the default CFLAGS/CCFLAGS 3844 the build should make source-level debugging easier Reviewed by: Robert Mustacchi <rm@joyent.com> Reviewed by: Garrett D'Amore <garrett@damore.org> Reviewed by: Gordon Ross <gwr@nexenta.com> Approved by: Gordon Ross <gwr@nexenta.com>
author Richard Lowe <richlowe@richlowe.net>
date Sun, 23 Jun 2013 17:17:05 -0400
parents 3d9eb655623f
children 9365fdf3a618
files usr/src/Makefile.master usr/src/cmd/Makefile.ctf usr/src/lib/Makefile.lib usr/src/uts/Makefile.uts usr/src/uts/sparc/Makefile.sparc.shared usr/src/uts/sun4u/Makefile.sun4u.shared usr/src/uts/sun4v/Makefile.sun4v.shared
diffstat 7 files changed, 60 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/Makefile.master	Thu May 09 18:56:46 2013 +0000
+++ b/usr/src/Makefile.master	Sun Jun 23 17:17:05 2013 -0400
@@ -350,7 +350,7 @@
 # Since we do some of this (foo might be referenced in common kernel code
 # but provided only for some cpu modules or platforms), we disable this
 # optimization.
-# 
+#
 sparc_CCUNBOUND	= -Wd,-xsafe=unboundsym
 i386_CCUNBOUND	=
 CCUNBOUND	= $($(MACH)_CCUNBOUND)
@@ -397,7 +397,7 @@
 XDEPEND=		-xdepend
 XFFLAG=			-xF=%all
 XESS=			-xs
-XSTRCONST=		-xstrconst 
+XSTRCONST=		-xstrconst
 
 #
 # turn warnings into errors (C)
@@ -535,19 +535,46 @@
 XREGSFLAG		= $($(MACH)_XREGSFLAG)
 XREGSFLAG64		= $($(MACH64)_XREGSFLAG)
 
+# dmake SOURCEDEBUG=yes ... enables source-level debugging information, and
+# avoids stripping it.
+SOURCEDEBUG	= $(POUND_SIGN)
+SRCDBGBLD	= $(SOURCEDEBUG:yes=)
+
+#
+# These variables are intended ONLY for use by developers to safely pass extra
+# flags to the compilers without unintentionally overriding Makefile-set
+# flags.  They should NEVER be set to any value in a Makefile.
+#
+# They come last in the associated FLAGS variable such that they can
+# explicitly override things if necessary, there are gaps in this, but it's
+# the best we can manage.
+#
+CUSERFLAGS		=
+CUSERFLAGS64		= $(CUSERFLAGS)
+CCUSERFLAGS		=
+CCUSERFLAGS64		= $(CCUSERFLAGS)
+
+CSOURCEDEBUGFLAGS	=
+CCSOURCEDEBUGFLAGS	=
+$(SRCDBGBLD)CSOURCEDEBUGFLAGS	= -g -xs
+$(SRCDBGBLD)CCSOURCEDEBUGFLAGS	= -g -xs
+
 CFLAGS=         $(COPTFLAG) $($(MACH)_CFLAGS) $(SPACEFLAG) $(CCMODE) \
 		$(ILDOFF) $(CERRWARN) $(C99MODE) $(CCUNBOUND) $(IROPTFLAG) \
-		$(CGLOBALSTATIC) $(CCNOAUTOINLINE)
+		$(CGLOBALSTATIC) $(CCNOAUTOINLINE) $(CSOURCEDEBUGFLAGS) \
+		$(CUSERFLAGS)
 CFLAGS64=       $(COPTFLAG64) $($(MACH64)_CFLAGS) $(SPACEFLAG64) $(CCMODE64) \
 		$(ILDOFF) $(CERRWARN) $(C99MODE) $(CCUNBOUND) $(IROPTFLAG64) \
-		$(CGLOBALSTATIC) $(CCNOAUTOINLINE)
+		$(CGLOBALSTATIC) $(CCNOAUTOINLINE) $(CSOURCEDEBUGFLAGS) \
+		$(CUSERFLAGS64)
 #
 # Flags that are used to build parts of the code that are subsequently
 # run on the build machine (also known as the NATIVE_BUILD).
 #
 NATIVE_CFLAGS=	$(COPTFLAG) $($(NATIVE_MACH)_CFLAGS) $(CCMODE) \
 		$(ILDOFF) $(CERRWARN) $(C99MODE) $($(NATIVE_MACH)_CCUNBOUND) \
-		$(IROPTFLAG) $(CGLOBALSTATIC) $(CCNOAUTOINLINE)
+		$(IROPTFLAG) $(CGLOBALSTATIC) $(CCNOAUTOINLINE) \
+		$(CSOURCEDEBUGFLAGS) $(CUSERFLAGS)
 
 DTEXTDOM=-DTEXT_DOMAIN=\"$(TEXT_DOMAIN)\"	# For messaging.
 DTS_ERRNO=-D_TS_ERRNO
@@ -565,7 +592,7 @@
 MSGROOT= $(ROOT)/catalog
 MSGDOMAIN= $(MSGROOT)/$(TEXT_DOMAIN)
 MSGDOMAINPOFILE = $(MSGDOMAIN)/$(POFILE)
-DCMSGDOMAIN= $(MSGROOT)/LC_TIME/$(TEXT_DOMAIN) 
+DCMSGDOMAIN= $(MSGROOT)/LC_TIME/$(TEXT_DOMAIN)
 DCMSGDOMAINPOFILE = $(DCMSGDOMAIN)/$(DCFILE:.dc=.po)
 
 CLOBBERFILES += $(POFILE) $(POFILES)
@@ -609,13 +636,15 @@
 
 CCOPTFLAG=	$($(MACH)_CCOPTFLAG)
 CCOPTFLAG64=	$($(MACH64)_CCOPTFLAG)
-CCFLAGS=	$(CCOPTFLAG) $($(MACH)_CCFLAGS)
-CCFLAGS64=	$(CCOPTFLAG64) $($(MACH64)_CCFLAGS)
+CCFLAGS=	$(CCOPTFLAG) $($(MACH)_CCFLAGS) $(CCSOURCEDEBUGFLAGS) \
+		$(CCUSERFLAGS)
+CCFLAGS64=	$(CCOPTFLAG64) $($(MACH64)_CCFLAGS) $(CCSOURCEDEBUGFLAGS) \
+		$(CCUSERFLAGS64)
 
 #
 #
 #
-ELFWRAP_FLAGS	=	
+ELFWRAP_FLAGS	=
 ELFWRAP_FLAGS64	=	-64
 
 #
@@ -654,7 +683,7 @@
 #
 MAPFILE.INT =		mapfile-intf
 
-# 
+#
 # LDLIBS32 can be set in the environment to override the following assignment.
 # LDLIBS64 can be set to override the assignment made in Makefile.master.64.
 # These environment settings make sure that no libraries are searched outside
@@ -887,12 +916,16 @@
 # Default label for CTF sections
 #
 CTFCVTFLAGS=		-i -L VERSION
+$(SRCDBGBLD)CTFCVTFLAGS 	+= -g
 
 #
-# Override to pass module-specific flags to ctfmerge.  Currently used
-# only by krtld to turn on fuzzy matching.
+# Override to pass module-specific flags to ctfmerge.  Currently used only by
+# krtld to turn on fuzzy matching, and source-level debugging to inhibit
+# stripping.
 #
 CTFMRGFLAGS=
+$(SRCDBGBLD)CTFMRGFLAGS 	+= -g
+
 
 CTFCONVERT_O		= $(CTFCONVERT) $(CTFCVTFLAGS) $@
 
@@ -975,6 +1008,7 @@
 
 STRIP_STABS=			   :
 $(RELEASE_BUILD)STRIP_STABS=	   $(STRIP) -x $@
+$(SRCDBGBLD)STRIP_STABS=	   :
 
 POST_PROCESS_O=		$(PROCESS_COMMENT) $@
 POST_PROCESS_A=
@@ -1127,7 +1161,7 @@
 .y.i:
 	$(YACC) -d $<
 	$(CPPFORPO) y.tab.c  > $@
-	$(RM) y.tab.c 
+	$(RM) y.tab.c
 
 .l.i:
 	$(LEX) $<
@@ -1142,7 +1176,7 @@
 	$(YACC) -d $<
 	$(CPPFORPO) y.tab.c  > $<.i
 	$(BUILD.po)
-	$(RM) y.tab.c 
+	$(RM) y.tab.c
 
 .l.po:
 	$(LEX) $<
@@ -1166,5 +1200,5 @@
 
 #
 # Include rules to render automated sccs get rules "safe".
-# 
+#
 include $(SRC)/Makefile.noget
--- a/usr/src/cmd/Makefile.ctf	Thu May 09 18:56:46 2013 +0000
+++ b/usr/src/cmd/Makefile.ctf	Sun Jun 23 17:17:05 2013 -0400
@@ -23,7 +23,7 @@
 # Use is subject to license terms.
 #
 
-POST_PROCESS += ; $(CTFMERGE) -L VERSION -o $@ $(OBJS)
+POST_PROCESS += ; $(CTFMERGE) $(CTFMRGFLAGS) -L VERSION -o $@ $(OBJS)
 POST_PROCESS_O += ; $(CTFCONVERT_O)
 
 CFLAGS += $(CTF_FLAGS)
--- a/usr/src/lib/Makefile.lib	Thu May 09 18:56:46 2013 +0000
+++ b/usr/src/lib/Makefile.lib	Sun Jun 23 17:17:05 2013 -0400
@@ -187,7 +187,7 @@
 POST_PROCESS_O += ; $(CTFCONVERT_POST)
 POST_PROCESS_SO += ; $(CTFMERGE_POST)
 
-CTFMERGE_LIB	= $(CTFMERGE) -t -f -L VERSION -o $@ $(PICS)
+CTFMERGE_LIB	= $(CTFMERGE) $(CTFMRGFLAGS) -t -f -L VERSION -o $@ $(PICS)
 
 # conditional assignments
 
--- a/usr/src/uts/Makefile.uts	Thu May 09 18:56:46 2013 +0000
+++ b/usr/src/uts/Makefile.uts	Sun Jun 23 17:17:05 2013 -0400
@@ -236,6 +236,8 @@
 CFLAGS_uts		+= $(CCNOAUTOINLINE)
 CFLAGS_uts		+= $(CGLOBALSTATIC)
 CFLAGS_uts		+= $(EXTRA_CFLAGS)
+CFLAGS_uts		+= $(CSOURCEDEBUGFLAGS)
+CFLAGS_uts		+= $(CUSERFLAGS)
 
 #
 #	Declare that $(OBJECTS) and $(LINTS) can be compiled in parallel.
--- a/usr/src/uts/sparc/Makefile.sparc.shared	Thu May 09 18:56:46 2013 +0000
+++ b/usr/src/uts/sparc/Makefile.sparc.shared	Sun Jun 23 17:17:05 2013 -0400
@@ -141,6 +141,8 @@
 CFLAGS		+= $(CGLOBALSTATIC)
 CFLAGS		+= -xregs=no%float
 CFLAGS		+= -xstrconst
+CFLAGS		+= $(CSOURCEDEBUGFLAGS)
+CFLAGS		+= $(CUSERFLAGS)
 
 ASFLAGS		+= $(XARCH)
 
--- a/usr/src/uts/sun4u/Makefile.sun4u.shared	Thu May 09 18:56:46 2013 +0000
+++ b/usr/src/uts/sun4u/Makefile.sun4u.shared	Sun Jun 23 17:17:05 2013 -0400
@@ -215,6 +215,8 @@
 CFLAGS		+= $(CGLOBALSTATIC)
 CFLAGS		+= -xregs=no%float
 CFLAGS		+= -xstrconst
+CFLAGS		+= $(CSOURCEDEBUGFLAGS)
+CFLAGS		+= $(CUSERFLAGS)
 
 ASFLAGS		+= $(AS_XARCH)
 
--- a/usr/src/uts/sun4v/Makefile.sun4v.shared	Thu May 09 18:56:46 2013 +0000
+++ b/usr/src/uts/sun4v/Makefile.sun4v.shared	Sun Jun 23 17:17:05 2013 -0400
@@ -189,6 +189,9 @@
 CFLAGS		+= $(CGLOBALSTATIC)
 CFLAGS		+= -xregs=no%float
 CFLAGS		+= -xstrconst
+CFLAGS		+= $(CSOURCEDEBUGFLAGS)
+CFLAGS		+= $(CUSERFLAGS)
+
 CPPFLAGS	+= -DGLREG
 
 ASFLAGS		+= $(AS_XARCH) -DGLREG