[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#157131: [PROPOSAL] Suggest to minimize optimization when DEB_BUILD_OPTIONS contains "debug"



Package: debian-policy
Severity: wishlist

The attached patch should mostly speak for itself.  I think it's great
that a lot of packages support DEB_BUILD_OPTIONS=debug now, but if the
program is compiled with optimization, it's very difficult to debug.

Another alternative is to make a whole different option "noopt" or
something; I'd accept that as well.

--- debian-policy-3.5.6.1/policy.sgml	2002-03-14 13:17:48.000000000 -0500
+++ debian-policy-3.5.6.1.hacked/policy.sgml	2002-08-17 22:36:06.000000000 -0400
@@ -5362,10 +5362,12 @@
 	  If the environment variable <tt>DEB_BUILD_OPTIONS</tt>
 	  contains the string <tt>debug</tt>, compile the software
 	  with debugging information (usually this involves adding the
-	  <tt>-g</tt> flag to <tt>CFLAGS</tt>).  This allows the
-	  generation of a build tree with debugging information.  If
-	  the environment variable <tt>DEB_BUILD_OPTIONS</tt> contains
-	  the string <tt>nostrip</tt>, do not strip the files at
+	  <tt>-g</tt> and the <tt>-O0</tt> flags to <tt>CFLAGS</tt>).
+	  This allows the generation of a build tree with debugging
+	  information; the reduced optimization ensures that the
+	  debugging tools can easily analyze the program.  If the
+	  environment variable <tt>DEB_BUILD_OPTIONS</tt> contains the
+	  string <tt>nostrip</tt>, do not strip the files at
 	  installation time.  This allows one to generate a package
 	  with debugging information included.<footnote>
 	    <p>
@@ -5384,7 +5386,7 @@
 	  test for either condition; you will probably have to massage
 	  this example in order to make it work for your package.
 	  <example compact="compact">
-CFLAGS = -O2 -Wall
+CFLAGS = -Wall
 INSTALL = install
 INSTALL_FILE    = $(INSTALL) -p    -o root -g root  -m  644
 INSTALL_PROGRAM = $(INSTALL) -p    -o root -g root  -m  755
@@ -5392,7 +5394,9 @@
 INSTALL_DIR     = $(INSTALL) -p -d -o root -g root  -m  755
 
 ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
-CFLAGS += -g
+CFLAGS += -g -O0
+else
+CFLAGS += -O2
 endif
 ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
 INSTALL_PROGRAM += -s






Reply to: