Improvements to bsd.dtrace.mk

markj at freebsd.org markj at freebsd.org
Tue Feb 25 01:31:23 UTC 2014


On Sun, Jan 26, 2014 at 06:27:13PM +0200, Mikolaj Golub wrote:
> Hi,
> 

Hi Mikolaj,

> Trying to use bsd.dtrace.mk for building userland programs with
> statically defined traces, I facesed the following issues:
> 
> 1) To generate a header file (e.g. provider.h) from a dtrace file
> (provider.d) you had to explicitly run `make depend'.
> 
> 2) If a makefile included bsd.dtrace.mk and sources contained probe
> macros, it would fail to build when WITH_DTRACE was not
> defined. I.e. you couldn't build the same sources with and without
> dtrace probes.
> 
> 3) It failed to build if you had several provider files (several files
> specified in DTRACEOBJS).
> 
> 4) It failed if OBJDIR was not current directory.
> 
> 5) It failed to rebuild dtrace objects if the old ones had not been
> removed before, because dtrace(1) refuses to rewrite objects.

Note that this behaviour is specific to FreeBSD; see:
http://svnweb.freebsd.org/base?view=revision&revision=212358

I'm not sure if it's still necessary.

> 
> 6) It was not possible to specify additional trace(1) options (e.g.
> library or header directory paths).
> 
> Here is my attempt to solve most of these issues:
> 
> http://people.freebsd.org/~trociny/patches/bsd.dtrace.mk.3.patch
> 
> The only issue remains is (1) -- necessity to run `make depend' to
> generate probider header files. I had also to tweak dt_program.c --
> header files generation.

I've been working around this by adding "all: depend" to my Makefiles,
but there should be a better way to do it. What do you think of just
replacing

    beforedepend: ${DTRACEHEADERS}

with

    ${SRCS}: ${DTRACEHEADERS}

?

It's overkill, but it seems to result in the correct behaviour for me. I
spent a bit of time looking other examples of auto-generated headers in
the tree, but couldn't find any.

> 
> Note, I didn't have much practice in writing makefiles, so any
> suggestions how this can be improved (or should be done properly) are
> highly appreciated.

It works and looks fine to me, for what that's worth. I tested with some
Makefiles that I've written in the past. I'm not aware of any ports that
make use of bsd.dtrace.mk.

As a side comment, I'm wondering whether it should be necessary to have
Makefiles explicitly include bsd.dtrace.mk. Maybe bsd.prog.mk and
bsd.lib.mk could always include bsd.dtrace.mk, which will have no effect
when DTRACESRCS isn't defined.

Thanks,
-Mark


More information about the freebsd-dtrace mailing list