Print this page
Arrange things Gordon's way, and be sure to pass -xs
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>

@@ -533,23 +533,50 @@
 amd64_XREGSFLAG         =
 
 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
 CPPFLAGS.master=$(DTEXTDOM) $(DTS_ERRNO) \
         $(ENVCPPFLAGS1) $(ENVCPPFLAGS2) $(ENVCPPFLAGS3) $(ENVCPPFLAGS4)

@@ -607,12 +634,14 @@
 i386_CCOPTFLAG=         -O
 amd64_CCOPTFLAG=        -O
 
 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   =       

@@ -885,16 +914,20 @@
 
 #
 # 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) $@
 
 ELFSIGN_O=      $(TRUE)
 ELFSIGN_CRYPTO= $(ELFSIGN_O)

@@ -973,10 +1006,11 @@
 $(STRIP_COMMENTS)PROCESS_COMMENT=  @?${MCS} -d -a $(RELEASE_CM) -a $(DEV_CM)
 $(RELEASE_BUILD)PROCESS_COMMENT=   @?${MCS} -d -a $(RELEASE_CM)
 
 STRIP_STABS=                       :
 $(RELEASE_BUILD)STRIP_STABS=       $(STRIP) -x $@
+$(SRCDBGBLD)STRIP_STABS=           :
 
 POST_PROCESS_O=         $(PROCESS_COMMENT) $@
 POST_PROCESS_A=
 POST_PROCESS_SO=        $(PROCESS_COMMENT) $@ ; $(STRIP_STABS) ; \
                         $(ELFSIGN_OBJECT)