Index: Makefile.inc1 =================================================================== --- Makefile.inc1 (revision 225693) +++ Makefile.inc1 (working copy) @@ -48,8 +48,6 @@ .endif .if ${MK_CDDL} != "no" SUBDIR+=cddl -.else -NO_CTF=1 .endif SUBDIR+=gnu include .if ${MK_KERBEROS} != "no" Index: share/man/man7/build.7 =================================================================== --- share/man/man7/build.7 (revision 225693) +++ share/man/man7/build.7 (working copy) @@ -349,6 +349,15 @@ .It Va NO_WERROR If defined, compiler warnings will not cause the build to halt, even if the makefile says otherwise. +.It Va WITH_CTF +If defined, the build process will run the DTrace CTF conversion +tools on built objects. +Please note that this WITH_ option is handled differently than all +other WITH_ options (there is no +.Va WITHOUT_CTF , +or corresponding +.Va MK_CTF +in the build system). .El .Pp Additionally, builds in Index: share/mk/bsd.own.mk =================================================================== --- share/mk/bsd.own.mk (revision 225693) +++ share/mk/bsd.own.mk (working copy) @@ -186,6 +186,7 @@ # regardless of user's setting). # .for var in \ + CTF \ INSTALLLIB \ MAN \ PROFILE @@ -407,6 +408,7 @@ BIND_LIBS \ BIND_SIGCHASE \ BIND_XML \ + CTF \ HESIOD \ IDEA .if defined(WITH_${var}) && defined(WITHOUT_${var}) @@ -450,6 +452,7 @@ .if ${MK_CDDL} == "no" MK_ZFS:= no +MK_CTF:= no .endif .if ${MK_CRYPT} == "no" @@ -541,6 +544,14 @@ .endif .endfor +.if ${MK_CTF} != "no" +CTFCONVERT_CMD= ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} +.elif ${MAKE_VERSION} >= 5201111300 +CTFCONVERT_CMD= +.else +CTFCONVERT_CMD= @: +.endif + .endif # !_WITHOUT_SRCCONF .endif # !target(____) Index: share/mk/bsd.lib.mk =================================================================== --- share/mk/bsd.lib.mk (revision 225693) +++ share/mk/bsd.lib.mk (working copy) @@ -36,7 +36,7 @@ .if defined(DEBUG_FLAGS) CFLAGS+= ${DEBUG_FLAGS} -.if !defined(NO_CTF) && (${DEBUG_FLAGS:M-g} != "") +.if ${MK_CTF} != "no" && ${DEBUG_FLAGS:M-g} != "" CTFFLAGS+= -g .endif .endif @@ -68,15 +68,11 @@ .c.po: ${CC} ${PO_FLAG} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET} -.if defined(CTFCONVERT) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .c.So: ${CC} ${PICFLAG} -DPIC ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET} -.if defined(CTFCONVERT) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .cc.po .C.po .cpp.po .cxx.po: ${CXX} ${PO_FLAG} ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET} @@ -86,58 +82,40 @@ .f.po: ${FC} -pg ${FFLAGS} -o ${.TARGET} -c ${.IMPSRC} -.if defined(CTFCONVERT) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .f.So: ${FC} ${PICFLAG} -DPIC ${FFLAGS} -o ${.TARGET} -c ${.IMPSRC} -.if defined(CTFCONVERT) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .m.po: ${OBJC} ${OBJCFLAGS} -pg -c ${.IMPSRC} -o ${.TARGET} -.if defined(CTFCONVERT) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .m.So: ${OBJC} ${PICFLAG} -DPIC ${OBJCFLAGS} -c ${.IMPSRC} -o ${.TARGET} -.if defined(CTFCONVERT) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .s.po .s.So: ${AS} ${AFLAGS} -o ${.TARGET} ${.IMPSRC} -.if defined(CTFCONVERT) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .asm.po: ${CC} -x assembler-with-cpp -DPROF ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET} -.if defined(CTFCONVERT) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .asm.So: ${CC} -x assembler-with-cpp ${PICFLAG} -DPIC ${CFLAGS} \ -c ${.IMPSRC} -o ${.TARGET} -.if defined(CTFCONVERT) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .S.po: ${CC} -DPROF ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET} -.if defined(CTFCONVERT) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .S.So: ${CC} ${PICFLAG} -DPIC ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET} -.if defined(CTFCONVERT) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} all: objwarn @@ -193,7 +171,11 @@ .if defined(SHLIB_NAME) _LIBS+= ${SHLIB_NAME} +.if target(beforelinking) +${SHLIB_NAME}: ${SOBJS} beforelinking +.else ${SHLIB_NAME}: ${SOBJS} +.endif @${ECHO} building shared library ${SHLIB_NAME} @rm -f ${.TARGET} ${SHLIB_LINK} .if defined(SHLIB_LINK) @@ -208,7 +190,7 @@ -o ${.TARGET} -Wl,-soname,${SONAME} \ `NM='${NM}' lorder ${SOBJS} | tsort -q` ${LDADD} .endif -.if defined(CTFMERGE) +.if ${MK_CTF} != "no" ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${SOBJS} .endif .endif Index: share/mk/sys.mk =================================================================== --- share/mk/sys.mk (revision 225693) +++ share/mk/sys.mk (working copy) @@ -45,24 +45,18 @@ .endif .endif -# Turn CTF conversion off by default for now. This default could be -# changed later if DTrace becomes popular. -.if !defined(WITH_CTF) -NO_CTF = 1 -.endif - # C Type Format data is required for DTrace CTFFLAGS ?= -L VERSION -.if !defined(NO_CTF) CTFCONVERT ?= ctfconvert CTFMERGE ?= ctfmerge .if defined(CFLAGS) && (${CFLAGS:M-g} != "") CTFFLAGS += -g .else -CFLAGS += -g +# XXX: What to do here? Is removing the CFLAGS part completely ok here? +# For now comment it out to not compile with -g unconditionally. +#CFLAGS += -g .endif -.endif CXX ?= c++ CXXFLAGS ?= ${CFLAGS:N-std=*:N-Wnested-externs:N-W*-prototypes:N-Wno-pointer-sign} @@ -142,15 +136,11 @@ # SINGLE SUFFIX RULES .c: ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC} -.if defined(CTFCONVERT) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .f: ${FC} ${FFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC} -.if defined(CTFCONVERT) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .sh: cp ${.IMPSRC} ${.TARGET} @@ -160,33 +150,25 @@ .c.o: ${CC} ${CFLAGS} -c ${.IMPSRC} -.if defined(CTFCONVERT) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .f.o: ${FC} ${FFLAGS} -c ${.IMPSRC} -.if defined(CTFCONVERT) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .y.o: ${YACC} ${YFLAGS} ${.IMPSRC} ${CC} ${CFLAGS} -c y.tab.c rm -f y.tab.c mv y.tab.o ${.TARGET} -.if defined(CTFCONVERT) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .l.o: ${LEX} ${LFLAGS} ${.IMPSRC} ${CC} ${CFLAGS} -c lex.yy.c rm -f lex.yy.c mv lex.yy.o ${.TARGET} -.if defined(CTFCONVERT) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .y.c: ${YACC} ${YFLAGS} ${.IMPSRC} @@ -224,15 +206,11 @@ .c: ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET} -.if defined(CTFCONVERT) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .c.o: ${CC} ${CFLAGS} -c ${.IMPSRC} -.if defined(CTFCONVERT) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .cc .cpp .cxx .C: ${CXX} ${CXXFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET} @@ -242,15 +220,11 @@ .m.o: ${OBJC} ${OBJCFLAGS} -c ${.IMPSRC} -.if defined(CTFCONVERT) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .p.o: ${PC} ${PFLAGS} -c ${.IMPSRC} -.if defined(CTFCONVERT) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .e .r .F .f: ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} \ @@ -261,38 +235,28 @@ .S.o: ${CC} ${CFLAGS} -c ${.IMPSRC} -.if defined(CTFCONVERT) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .asm.o: ${CC} -x assembler-with-cpp ${CFLAGS} -c ${.IMPSRC} -.if defined(CTFCONVERT) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .s.o: ${AS} ${AFLAGS} -o ${.TARGET} ${.IMPSRC} -.if defined(CTFCONVERT) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} # XXX not -j safe .y.o: ${YACC} ${YFLAGS} ${.IMPSRC} ${CC} ${CFLAGS} -c y.tab.c -o ${.TARGET} rm -f y.tab.c -.if defined(CTFCONVERT) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .l.o: ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c ${CC} ${CFLAGS} -c ${.PREFIX}.tmp.c -o ${.TARGET} rm -f ${.PREFIX}.tmp.c -.if defined(CTFCONVERT) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} # XXX not -j safe .y.c: @@ -304,34 +268,26 @@ .s.out .c.out .o.out: ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET} -.if defined(CTFCONVERT) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .f.out .F.out .r.out .e.out: ${FC} ${EFLAGS} ${RFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} \ ${LDLIBS} -o ${.TARGET} rm -f ${.PREFIX}.o -.if defined(CTFCONVERT) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} # XXX not -j safe .y.out: ${YACC} ${YFLAGS} ${.IMPSRC} ${CC} ${CFLAGS} ${LDFLAGS} y.tab.c ${LDLIBS} -ly -o ${.TARGET} rm -f y.tab.c -.if defined(CTFCONVERT) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} .l.out: ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c ${CC} ${CFLAGS} ${LDFLAGS} ${.PREFIX}.tmp.c ${LDLIBS} -ll -o ${.TARGET} rm -f ${.PREFIX}.tmp.c -.if defined(CTFCONVERT) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${CTFCONVERT_CMD} # FreeBSD build pollution. Hide it in the non-POSIX part of the ifdef. __MAKE_CONF?=/etc/make.conf Index: share/mk/bsd.prog.mk =================================================================== --- share/mk/bsd.prog.mk (revision 225693) +++ share/mk/bsd.prog.mk (working copy) @@ -18,7 +18,7 @@ .if defined(DEBUG_FLAGS) CFLAGS+=${DEBUG_FLAGS} -.if !defined(NO_CTF) && (${DEBUG_FLAGS:M-g} != "") +.if ${MK_CTF} != "no" && ${DEBUG_FLAGS:M-g} != "" CTFFLAGS+= -g .endif .endif @@ -54,13 +54,17 @@ OBJS+= ${SRCS:N*.h:R:S/$/.o/g} +.if target(beforelinking) +${PROG}: ${OBJS} beforelinking +.else ${PROG}: ${OBJS} +.endif .if defined(PROG_CXX) ${CXX} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} .else ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} .endif -.if defined(CTFMERGE) +.if ${MK_CTF} != "no" ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${OBJS} .endif @@ -80,13 +84,17 @@ # - it's useful to keep objects around for crunching. OBJS= ${PROG}.o +.if target(beforelinking) +${PROG}: ${OBJS} beforelinking +.else ${PROG}: ${OBJS} +.endif .if defined(PROG_CXX) ${CXX} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} .else ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} .endif -.if defined(CTFMERGE) +.if ${MK_CTF} != "no" ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${OBJS} .endif .endif Index: share/mk/bsd.port.mk =================================================================== --- share/mk/bsd.port.mk (revision 225693) +++ share/mk/bsd.port.mk (working copy) @@ -7,5 +7,10 @@ # and setting MK_* variables when building ports. _WITHOUT_SRCCONF= +# Enable CTF conversion on request. +.if defined(WITH_CTF) +.undef NO_CTF +.endif + .include .include "${BSDPORTMK}" Index: sys/conf/kern.post.mk =================================================================== --- sys/conf/kern.post.mk (revision 225693) +++ sys/conf/kern.post.mk (working copy) @@ -15,6 +15,10 @@ SYSDIR?= ${S:C;^[^/];${.CURDIR}/&;} MKMODULESENV+= KERNBUILDDIR="${.CURDIR}" SYSDIR="${SYSDIR}" +.if defined(WITH_CTF) +MKMODULESENV+= WITH_CTF="${WITH_CTF}" +.endif + .MAIN: all .for target in all clean cleandepend cleandir clobber depend install \ @@ -86,8 +90,8 @@ @rm -f ${.TARGET} @echo linking ${.TARGET} ${SYSTEM_LD} -.if defined(CTFMERGE) - ${SYSTEM_CTFMERGE} +.if ${MK_CTF} != "no" + ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${SYSTEM_OBJS} vers.o .endif .if !defined(DEBUG) ${OBJCOPY} --strip-debug ${.TARGET} @@ -236,9 +240,7 @@ config.o env.o hints.o vers.o vnode_if.o: ${NORMAL_C} -.if defined(CTFCONVERT) - ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.endif + ${NORMAL_CTFCONVERT} config.ln env.ln hints.ln vers.ln vnode_if.ln: ${NORMAL_LINT} Index: sys/conf/kern.pre.mk =================================================================== --- sys/conf/kern.pre.mk (revision 225693) +++ sys/conf/kern.pre.mk (working copy) @@ -131,10 +131,12 @@ NORMAL_M= ${AWK} -f $S/tools/makeobjops.awk ${.IMPSRC} -c ; \ ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.PREFIX}.c -.if defined(CTFCONVERT) -NORMAL_CTFCONVERT= ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} -.else +.if ${MK_CTF} != "no" +NORMAL_CTFCONVERT= ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} +.elif ${MAKE_VERSION} >= 5201111300 NORMAL_CTFCONVERT= +.else +NORMAL_CTFCONVERT= @: .endif NORMAL_LINT= ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC} @@ -145,10 +147,6 @@ SYSTEM_OBJS= locore.o ${MDOBJS} ${OBJS} SYSTEM_OBJS+= ${SYSTEM_CFILES:.c=.o} SYSTEM_OBJS+= hack.So -.if defined(CTFMERGE) -SYSTEM_CTFMERGE= ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${SYSTEM_OBJS} vers.o -LD+= -g -.endif SYSTEM_LD= @${LD} -Bdynamic -T ${LDSCRIPT} \ -warn-common -export-dynamic -dynamic-linker /red/herring \ -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o Index: sys/conf/kmod.mk =================================================================== --- sys/conf/kmod.mk (revision 225693) +++ sys/conf/kmod.mk (working copy) @@ -133,7 +133,7 @@ .endif .if defined(DEBUG) || defined(DEBUG_FLAGS) -CTFFLAGS+= -g +CTFFLAGS+= -g .endif .if defined(FIRMWS) @@ -201,7 +201,7 @@ ${FULLPROG}: ${OBJS} .endif ${LD} ${LDFLAGS} -r -d -o ${.TARGET} ${OBJS} -.if defined(WITH_CTF) +.if defined(MK_CTF) && ${MK_CTF} != "no" ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${OBJS} .endif .if defined(EXPORT_SYMS) Index: usr.sbin/config/mkmakefile.c =================================================================== --- usr.sbin/config/mkmakefile.c (revision 225693) +++ usr.sbin/config/mkmakefile.c (working copy) @@ -426,7 +426,7 @@ next_quoted_word(fp, wd); if (wd == 0) { fprintf(stderr, - "%s: %s missing compile command string.\n", + "%s: %s missing dependency string.\n", fname, this); exit(1); } @@ -742,15 +742,18 @@ break; } snprintf(cmd, sizeof(cmd), - "${%s_%c%s}\n.if defined(NORMAL_CTFCONVERT) && " - "!empty(NORMAL_CTFCONVERT)\n" - "\t${NORMAL_CTFCONVERT}\n.endif", ftype, + "${%s_%c%s}", ftype, toupper(och), ftp->f_flags & NOWERROR ? "_NOWERROR" : ""); compilewith = cmd; } *cp = och; - fprintf(f, "\t%s\n\n", compilewith); + fprintf(f, "\t%s\n", compilewith); + + if (!(ftp->f_flags & NO_OBJ)) + fprintf(f, "\t${NORMAL_CTFCONVERT}\n\n"); + else + fprintf(f, "\n"); } }