Improvements to bsd.dtrace.mk

Mikolaj Golub trociny at FreeBSD.org
Tue Feb 25 19:18:38 UTC 2014


On Mon, Feb 24, 2014 at 08:31:15PM -0500, markj at freebsd.org wrote:
> On Sun, Jan 26, 2014 at 06:27:13PM +0200, Mikolaj Golub wrote:

> > 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.

Interesting. Thank you for the link!

> 
> > 
> > 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.

It is rather strange, because when I tried this last version recently
it actually stopped work for me :-). Anyway, it still needs many
improvements.

> 
> 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.

Yes, I came to the same conclusion later. I was also considering a
possibility to remove bsd.dtrace.mk at all and just extend bsd.prog.mk
and bsd.lib.mk. Futher, it might be better to make users specify
DTRACESRCS instead of DTRACEOBJS, or just add *.d files to SRCS, as we
do e.g. with *.y files.

Did not have much time to experiment yet though.

Thanks for the comments.

-- 
Mikolaj Golub


More information about the freebsd-dtrace mailing list