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

Bug#43787: PROPOSAL] changing policy on compiling with -g .. a better way



Ok, reformated Manoj's great work. Only change being DEB_BUILD_OPTIONS
instead of just BUILD_OPTIONS.

I wondered if anyone else has an opionion on which of these to choose.
Either one works for me, but I think the first one is probably needed
since some builds just can't be changed sensibly.

Ben

======================================================================
  The minimal change
======================================================================
          CC = gcc
          CFLAGS = -O2 -g -Wall # sane warning options vary between programs
          LDFLAGS = # none
          install -s # (or use strip on the files in debian/tmp)
...

          The `-g' flag is useful on compilation so that you have available a
          full set of debugging symbols in your built source tree, in case
          anyone should file a bug report involving (for example) a core dump.
+         Alternately, you could use an environment variable
+         DEB_BUILD_OPTIONS, which, if it contains `debug', would cause
+         compilation to be done with -g. (Remember not to call
+         ``install -s'' or strip on the binaries afterwards for this
+         case). The resulting binaries in your built package will then
+         contain the full set of debugging symbols (remember not to call 
+         ``install -s'' or ``strip'' on the binaries afterwards). 
+
+          This would let us later add other options in a fairly clean way.
+
+         Additionally, (and optionally) you may also provide a target
+         `build-debug' in debian/rules which has the same effect as
+         setting DEB_BUILD_OPTIONS to  contain `debug'. This can be done 
+         quite simply, with the folowing lines:
+ build-debug: DEB_BUILD_OPTIONS+=debug
+ build-debug: build
+        Note: You still have to ensure that DEB_BUILD_OPTIONS is honoured.
======================================================================

        The second way: we don't just offer an alternative, we
 deprecate the old method, but let it be still legal.
======================================================================
          CC = gcc
-         CFLAGS = -O2 -g -Wall # sane warning options vary between programs
+         # sane warning options vary between programs
+         CFLAGS = -O2 -Wall
+         ifneq (,$(findstring $(DEB_BUILD_OPTIONS),DEBUG Debug debug))
+         CFLAGS += -g 
+         INSTALL_FLAGS= -s
+         endif
          LDFLAGS = # none
-         install -s # (or use strip on the files in debian/tmp)
+         install $(INSTALL_FLAGS) # 
...

          
          The `-g' flag is useful on compilation so that you have available a
          full set of debugging symbols in your built source tree, in case
          anyone should file a bug report involving (for example) a core dump.
+         It is acceptable, but deprecated, to always have -g in
+         ``CFLAGS'', and ``use install -s'' to install binaries or use
+         ``strip'' on the binaries in debian/tmp, but that make it
+         hard to create a debuggable debian package, and increase
+         build time for all builds, since debugging information is
+         created and then stripped away. The preferred method is to
+         use an environment variable DEB_BUILD_OPTIONS, which, if it 
+         contains `debug', would cause compilation to be done with -g. The
+         resulting binaries in your package will then contain the full
+         set of debugging symbols (remember not to call ``install -s''
+         or ``strip'' on the binaries afterwards). 
+
+          This would let us later add other options in a fairly clean way.
+
+         Additionally, (and optionally) you may also provide a target
+         `build-debug' in debian/rules which has the same effect as
+         setting DEB_BUILD_OPTIONS to contain `debug'. This can be done 
+         quite simply, with the folowing lines:
+ build-debug: DEB_BUILD_OPTIONS+=debug
+ build-debug: build
======================================================================


Reply to: