This patch adds a basic infrastructure support for building binaries for debugging purposes. A new knob, WITH_DEBUG is introduced. If set DEBUG_FLAGS (-g at default) are added to CFLAGS and binaries doesn't get stripped by INSTALL_PROGRAM. Besides, each port could/should add its specific things for WITH_DEBUG. DEBUG_FLAGS can be overridden, of course. Suggested by: netchild Reviewed by: netchild
Responsible Changed From-To: freebsd-ports-bugs->portmgr bsd.port.mk is port manager territory
State Changed From-To: open->feedback The intention here is a good one but further work is necessary to make it useful: * even if built with debugging symbols, install(1) will strip them out unless you tell it not to, so this change also needs to modify the INSTALL_* macros. * Options are not disabled by setting WITH_FOO=no, they're disabled by setting WITHOUT_FOO. The value of these variables has no meaning.
Updated patch from submitter: http://gabor.t-hosting.hu/patches/with_debug.diff Another updated patch from submitter at same URL from Nov 30.
> http://gabor.t-hosting.hu/patches/with_debug.diff > > What about this patch? I added a check against WITHOUT_DEBUG and did a > sweep against ports that use WITH_DEBUG in some way > and deleted the redundant things there. I also made some standardization > among these, they always respect DEBUG_FLAGS and > always use WITH_DEBUG, instead of WITH_DEBUG_INFO now. As Pav > recommended, the optimizations in CFLAGS are not > passed here, by setting CFLAGS just to DEBUG_FLAGS, since -O2 > optimizations are not quite useful for debugging. This patch have one problem. If the port needs to add something to CFLAGS, it gets lost. Example with net/iaxmodem: $ make -V CFLAGS -O2 -fno-strict-aliasing -pipe -I/usr/local/include $ make -V CFLAGS WITH_DEBUG=1 -g Obviously, the second line should read -g -I/usr/local/include I think you'll need to do something like CFLAGS:= ${CFLAGS:N-O*:N-f*} to only remove -O* and -f* flags from existing CFLAGS. PS Keep Cc:ing bug-followup@FreeBSD.org so your updates get recorded in PR. -- Pav Lucistnik <pav@oook.cz> <pav@FreeBSD.org> Pain clots and unformed lice pat this train.
Pav Lucistnik schrieb: >> http://gabor.t-hosting.hu/patches/with_debug.diff >> >> What about this patch? I added a check against WITHOUT_DEBUG and did a >> sweep against ports that use WITH_DEBUG in some way >> and deleted the redundant things there. I also made some standardization >> among these, they always respect DEBUG_FLAGS and >> always use WITH_DEBUG, instead of WITH_DEBUG_INFO now. As Pav >> recommended, the optimizations in CFLAGS are not >> passed here, by setting CFLAGS just to DEBUG_FLAGS, since -O2 >> optimizations are not quite useful for debugging. >> > > This patch have one problem. If the port needs to add something to > CFLAGS, it gets lost. Example with net/iaxmodem: > > $ make -V CFLAGS > -O2 -fno-strict-aliasing -pipe -I/usr/local/include > $ make -V CFLAGS WITH_DEBUG=1 > -g > > Obviously, the send line should read -g -I/usr/local/include > > I think you'll need to do something like > CFLAGS:= ${CFLAGS:N-O*:N-f*} > to only remove -O* and -f* flags from existing CFLAGS. > > PS > Keep Cc:ing bug-followup@FreeBSD.org so your updates get recorded in PR. > > Rerolled, and seems to work: http://gabor.t-hosting.hu/patches/with_debug.diff At the same manner, what about -march? And -mmmx, -msse, -msse2, -msse3, -m3dnow? Can they be kept or should be removed as well? Or can we suppose one won't use them for debugging? Cheers, Gabor
> > This patch have one problem. If the port needs to add something to > > CFLAGS, it gets lost. Example with net/iaxmodem: > > > > $ make -V CFLAGS > > -O2 -fno-strict-aliasing -pipe -I/usr/local/include > > $ make -V CFLAGS WITH_DEBUG=1 > > -g > > > > Obviously, the second line should read -g -I/usr/local/include > > > > I think you'll need to do something like > > CFLAGS:= ${CFLAGS:N-O*:N-f*} > > to only remove -O* and -f* flags from existing CFLAGS. > > > > PS > > Keep Cc:ing bug-followup@FreeBSD.org so your updates get recorded in PR. > > > > > Rerolled, and seems to work: > > http://gabor.t-hosting.hu/patches/with_debug.diff $ make -V CFLAGS WITH_DEBUG=1 Variable CFLAGS is recursive. Have you tested it, at all? > At the same manner, what about -march? And -mmmx, -msse, -msse2, -msse3, > -m3dnow? Can they be kept or should be removed as well? Or can we > suppose one won't use them for debugging? I don't think we have to strip these. -- Pav Lucistnik <pav@oook.cz> <pav@FreeBSD.org> That must be wonderful! I don't understand it at all. -- Moliere
Pav Lucistnik schrieb: > > $ make -V CFLAGS WITH_DEBUG=1 > Variable CFLAGS is recursive. > > Have you tested it, at all? > > Sure, I just uploaded the wrong patch. Sorry for the mess. It works with ":=". The correct patch is at the same location now. Gabor
State Changed From-To: feedback->open A good patch available now
State Changed From-To: open->analyzed Accepted for a test build on the cluster. http://people.freebsd.org/~pav/with_debug.diff <- tested patch
State Changed From-To: analyzed->closed Committed, thanks.