Re: builworld fails if debugging enabled in usr.sbin/pkg_install/lib

From: Ruslan Ermilov <ru_at_freebsd.org>
Date: Thu, 12 Aug 2004 23:11:38 +0300
On Thu, Aug 12, 2004 at 02:58:23PM -0500, Conrad J. Sabatier wrote:
> 
> On 12-Aug-2004 Ruslan Ermilov wrote:
> > On Thu, Aug 12, 2004 at 02:41:37PM -0500, Conrad J. Sabatier wrote:
> >> To help in debugging a problem with news/pan2, I decided to try
> >> rebuilding the port and all of its dependencies with debugging
> >> enabled.
> >> Then I decided to go ahead and do the same with the base system. 
> >> The
> >> buildworld with "-g" worked fine with one exception:
> >> 
> >> cc -O2 -pipe -march=athlon64 -m64 -g  1 -Wsystem-headers -Wall
> >> -Wno-format-y2k -W -Wstrict-prototypes -Wmissing-prototypes
> >> -Wpointer-arith -Wno-uninitialized -Wformat=2 -Wno-format-extra-args
> >> -c
> >> /usr/src/usr.sbin/pkg_install/lib/file.c
> >> cc: 1: No such file or directory
> >> *** Error code 1
> >> 
> >> Stop in /usr/src/usr.sbin/pkg_install/lib.
> >> 
> >> I can't figure out where this "1" just after the "-g" switch is
> >> coming
> >> from.  Without "-g", the compile works OK:
> >> 
> >> cc -O2 -pipe -march=athlon64 -m64   -Wsystem-headers -Wall
> >> -Wno-format-y2k -W -Wstrict-prototypes -Wmissing-prototypes
> >> -Wpointer-arith -Wno-uninitialized -Wformat=2 -Wno-format-extra-args
> >> -c
> >> /usr/src/usr.sbin/pkg_install/lib/file.c
> >> 
> >> Strange.
> >> 
> > How are you building your world with -g?
> 
> I have the following in /etc/make.conf:
> 
> .if defined(DEBUG)
> CFLAGS+=-g
> .endif
> 
> And then use "make -DDEBUG buildworld".
> 
I suspected something like this.  src/usr.sbin/pkg_install/*/Makefile's
added the contents of the DEBUG variable to CFLAGS.  By passing the
-DDEBUG to make(1), you effectively set the value of the DEBUG variable
to 1 (see the make(1) manpage), so "1" was added to CFLAGS.

I've "fixed" these makefiles to not add DEBUG to CFLAGS.  Note that the
name DEBUG is unsafe to use anyway.  Also, there's an alternative and
standard way to recompile your programs and libraries with -g: there's
the DEBUG_FLAGS variable, so you could as well do it like this:

	make buildworld DEBUG_FLAGS=-g

Passing DEBUG_FLAGS=-g to ``make installworld'' will also cause the
binaries to *not* be stripped when installing, which is essential
for having the debugger symbols in binaries.  Please consider switching
to this method of building world with debug infomation.


Cheers,
-- 
Ruslan Ermilov
ru_at_FreeBSD.org
FreeBSD committer

Received on Thu Aug 12 2004 - 18:11:52 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:06 UTC