svn commit: r320396 - projects/runtime-coverage/share/mk
Ngie Cooper
ngie at FreeBSD.org
Tue Jun 27 06:02:52 UTC 2017
Author: ngie
Date: Tue Jun 27 06:02:50 2017
New Revision: 320396
URL: https://svnweb.freebsd.org/changeset/base/320396
Log:
Stash work for adding runtime coverage support to bsd.lib.mk
The initial work uses static libraries instead of dynamic libraries, for
parity with pico-style libraries.
I suspect this approach is slightly flawed, but I wanted to stash the WiP,
just in case.
Modified:
projects/runtime-coverage/share/mk/bsd.lib.mk
Modified: projects/runtime-coverage/share/mk/bsd.lib.mk
==============================================================================
--- projects/runtime-coverage/share/mk/bsd.lib.mk Tue Jun 27 04:54:58 2017 (r320395)
+++ projects/runtime-coverage/share/mk/bsd.lib.mk Tue Jun 27 06:02:50 2017 (r320396)
@@ -76,9 +76,9 @@ CTFFLAGS+= -g
.include <bsd.libnames.mk>
-# prefer .s to a .c, add .po, remove stuff not used in the BSD libraries
+# prefer .s to a .c, add .covo and .po, remove stuff not used in the BSD libraries
# .pico used for PIC object files
-.SUFFIXES: .out .o .bc .ll .po .pico .S .asm .s .c .cc .cpp .cxx .C .f .y .l .ln
+.SUFFIXES: .out .o .bc .covo .ll .po .pico .S .asm .s .c .cc .cpp .cxx .C .f .y .l .ln
.if !defined(PICFLAG)
.if ${MACHINE_CPUARCH} == "sparc64"
@@ -88,8 +88,14 @@ PICFLAG=-fpic
.endif
.endif
+COV_FLAG=--coverage -g
+
PO_FLAG=-pg
+.c.covo:
+ ${CC} ${COV_FLAG} ${STATIC_CFLAGS} ${COV_CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
+ ${CTFCONVERT_CMD}
+
.c.po:
${CC} ${PO_FLAG} ${STATIC_CFLAGS} ${PO_CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
${CTFCONVERT_CMD}
@@ -98,6 +104,9 @@ PO_FLAG=-pg
${CC} ${PICFLAG} -DPIC ${SHARED_CFLAGS} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
${CTFCONVERT_CMD}
+.cc.covo .C.covo .cpp.covo .cxx.covo:
+ ${CXX} ${COV_FLAG} ${STATIC_CXXFLAGS} ${COV_CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET}
+
.cc.po .C.po .cpp.po .cxx.po:
${CXX} ${PO_FLAG} ${STATIC_CXXFLAGS} ${PO_CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET}
@@ -112,10 +121,15 @@ PO_FLAG=-pg
${FC} ${PICFLAG} -DPIC ${FFLAGS} -o ${.TARGET} -c ${.IMPSRC}
${CTFCONVERT_CMD}
-.s.po .s.pico:
+.s.covo .s.po .s.pico:
${AS} ${AFLAGS} -o ${.TARGET} ${.IMPSRC}
${CTFCONVERT_CMD}
+.asm.covo:
+ ${CC:N${CCACHE_BIN}} -x assembler-with-cpp -DCOV ${COV_CFLAGS} \
+ ${ACFLAGS} -c ${.IMPSRC} -o ${.TARGET}
+ ${CTFCONVERT_CMD}
+
.asm.po:
${CC:N${CCACHE_BIN}} -x assembler-with-cpp -DPROF ${PO_CFLAGS} \
${ACFLAGS} -c ${.IMPSRC} -o ${.TARGET}
@@ -126,6 +140,11 @@ PO_FLAG=-pg
${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} -o ${.TARGET}
${CTFCONVERT_CMD}
+.S.covo:
+ ${CC:N${CCACHE_BIN}} -DCOV ${COV_CFLAGS} ${ACFLAGS} -c ${.IMPSRC} \
+ -o ${.TARGET}
+ ${CTFCONVERT_CMD}
+
.S.po:
${CC:N${CCACHE_BIN}} -DPROF ${PO_CFLAGS} ${ACFLAGS} -c ${.IMPSRC} \
-o ${.TARGET}
@@ -184,6 +203,22 @@ lib${LIB_PRIVATE}${LIB}.a: ${OBJS} ${STATICOBJS}
.endif
.if !defined(INTERNALLIB)
+
+.if ${MK_COVERAGE} != "no" && defined(LIB) && !empty(LIB)
+_LIBS+= lib${LIB_PRIVATE}${LIB}_c.a
+COV_OBJS+= ${OBJS:.o=.covo} ${STATICOBJS:.o=.covo}
+DEPENDOBJS+= ${COV_OBJS}
+CLEANFILES+= ${COV_OBJS}
+# XXX (ngie): tighten this down
+CLEANFILES+= *.gcda *.gcno
+
+lib${LIB_PRIVATE}${LIB}_c.a: ${COV_OBJS}
+ @${ECHO} building coverage instrumented ${LIB} library
+ @rm -f ${.TARGET}
+ ${AR} ${ARFLAGS} ${.TARGET} `NM='${NM}' NMFLAGS='${NMFLAGS}' \
+ ${LORDER} ${COV_OBJS} | ${TSORT} ${TSORTFLAGS}` ${ARADD}
+ ${RANLIB} ${RANLIBFLAGS} ${.TARGET}
+.endif
.if ${MK_PROFILE} != "no" && defined(LIB) && !empty(LIB)
_LIBS+= lib${LIB_PRIVATE}${LIB}_p.a
More information about the svn-src-projects
mailing list