Bug 228308 - [NEW PORT] devel/kcov: ptrace-based coverage analyzer
Summary: [NEW PORT] devel/kcov: ptrace-based coverage analyzer
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: Alan Somers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-05-17 01:29 UTC by Alan Somers
Modified: 2018-05-28 13:08 UTC (History)
2 users (show)

See Also:


Attachments
devel/kcov: new port (3.38 KB, patch)
2018-05-17 01:29 UTC, Alan Somers
no flags Details | Diff
devel/kcov: new port (4.55 KB, patch)
2018-05-17 17:02 UTC, Alan Somers
no flags Details | Diff
devel/kcov: new port (4.64 KB, patch)
2018-05-24 15:08 UTC, Alan Somers
no flags Details | Diff
devel/kcov: new port (4.74 KB, patch)
2018-05-25 03:23 UTC, Alan Somers
no flags Details | Diff
devel/kcov: new port (4.69 KB, patch)
2018-05-25 12:34 UTC, Alan Somers
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alan Somers freebsd_committer freebsd_triage 2018-05-17 01:29:52 UTC
Created attachment 193473 [details]
devel/kcov: new port

kcov is a coverage analyzer that works with ELF, bash, and python programs.  Unlike gcov, it works with uninstrumented binaries, requiring only that they include debugging symbols.  It is especially popular in the Rust community.
Comment 1 Alan Somers freebsd_committer freebsd_triage 2018-05-17 01:32:43 UTC
I only have a src commit bit, so I need review for this port before I can commit it.  I'm happy to maintain it, though.
Comment 2 Tobias Kortkamp freebsd_committer freebsd_triage 2018-05-17 06:21:59 UTC
(In reply to Alan Somers from comment #1)
+BUILD_DEPENDS=	binutils>=2.30:devel/binutils \
+		cmake:devel/cmake

cmake is redundant here because USES=cmake already adds it.

+PORTVERSION=	35.55.20180516
[...]
+# Use a GitHub tag until version 36 gets released, whenever that might be
+USE_GITHUB=	yes
+GH_ACCOUNT=	SimonKagstrom
+GH_PROJECT=	kcov
+GH_TAGNAME=	69dfa9c

The USE_GITHUB bits should go directly below the USES= line.

GH_PROJECT defaults to whatever PORTNAME is set to, so it's redundant
here.

Instead of setting GH_TAGNAME and inventing your own PORTVERSION try to
follow the procedure at [1] to derive a DISTVERSION{,SUFFIX,PREFIX}
triple. Only set GH_TAGNAME and PORTVERSION if that doesn't work.

In this case just set

DISTVERSIONPREFIX=	v
DISTVERSION=	35-57
DISTVERSIONSUFFIX=	-g69dfa9c

and remove PORTVERSION and GH_TAGNAME.

+USES=		cmake:outsource shebangfix python:build

Do the build scripts work with Python 3.x? If not you might have to
restrict the Python version here i.e. python:2.7,build.

+CMAKE_ARGS+=	-DKCOV_INSTALL_MANDIR=${PREFIX}/man

s/+=/=/

+python_CMD=	${PYTHON_CMD}

Redundant.

+SHEBANG_REGEX=	'.*\.py'

SHEBANG_GLOB=	*.py

+PORTDOCS=	COPYING \
+		COPYING.externals \
+		ChangeLog

If you use PORTDOCS the port must have a DOCS option.

OPTIONS_DEFINE=	DOCS

Assuming that COPYING contains the license it should be installed via e.g.

LICENSE_FILE=	${WRKSRC}/COPYING

instead.

[1] https://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/makefile-distfiles.html#makefile-master_sites-github-ex5
Comment 3 Alan Somers freebsd_committer freebsd_triage 2018-05-17 17:02:27 UTC
Created attachment 193489 [details]
devel/kcov: new port

Fixed Tobias's feedback.  The build scripts, BTW, do work with both Python2 and Python3.  Also, I fixed the embedded version identifier (what you get from kcov --version), and added license information for the bundled bits.
Comment 4 Tobias Kortkamp freebsd_committer freebsd_triage 2018-05-24 09:09:09 UTC
(In reply to Alan Somers from comment #3)

Looks better, but OPTIONS_DEFINE=DOCS should be before post-stage or
PORTDOCS (see [1]) and SHEBANG_GLOB doesn't need the quotes.

While this builds fine on 11.1/amd64, it doesn't build on 11.1/i386:

/wrkdirs/usr/ports/devel/kcov/work/kcov-35-57-g69dfa9c/src/engines/ptrace_freebsd.cc:22:3: error: Unsupported architecture
# error Unsupported architecture
  ^
/wrkdirs/usr/ports/devel/kcov/work/kcov-35-57-g69dfa9c/src/engines/ptrace_freebsd.cc:31:3: error: Unsupported architecture
# error Unsupported architecture
  ^
2 errors generated.

And not on 10.4/i386:

FAILED: src/CMakeFiles/kcov.dir/parsers/elf.cc.o 
/usr/bin/c++  -DPACKAGE -DPACKAGE_VERSION -I/wrkdirs/usr/ports/devel/kcov/work/kcov-35-57-g69dfa9c/src/include -I/wrkdirs/usr/ports/devel/kcov/work/kcov-35-57-g69dfa9c/src/../external/lldb/include -I/usr/local/include -O2 -pipe -fstack-protector -fno-strict-aliasing -std=c++0x -g -Wall -D_GLIBCXX_USE_NANOSLEEP -DKCOV_LIBRARY_PREFIX=/tmp -DKCOV_HAS_LIBBFD=0 -O2 -pipe -fstack-protector -fno-strict-aliasing -MD -MT src/CMakeFiles/kcov.dir/parsers/elf.cc.o -MF src/CMakeFiles/kcov.dir/parsers/elf.cc.o.d -o src/CMakeFiles/kcov.dir/parsers/elf.cc.o -c /wrkdirs/usr/ports/devel/kcov/work/kcov-35-57-g69dfa9c/src/parsers/elf.cc
In file included from /wrkdirs/usr/ports/devel/kcov/work/kcov-35-57-g69dfa9c/src/parsers/elf.cc:5:
In file included from /usr/local/include/elfutils/libdw.h:32:
In file included from /usr/local/include/gelf.h:32:
/usr/local/include/libelf.h:332:8: error: unknown type name 'Elf32_Chdr'
extern Elf32_Chdr *elf32_getchdr (Elf_Scn *__scn);
       ^
/usr/local/include/libelf.h:333:8: error: unknown type name 'Elf64_Chdr'
extern Elf64_Chdr *elf64_getchdr (Elf_Scn *__scn);
       ^
In file included from /wrkdirs/usr/ports/devel/kcov/work/kcov-35-57-g69dfa9c/src/parsers/elf.cc:5:
In file included from /usr/local/include/elfutils/libdw.h:32:
/usr/local/include/gelf.h:93:9: error: unknown type name 'Elf64_Chdr'
typedef Elf64_Chdr GElf_Chdr;
        ^
3 errors generated.

If this is expected set either NOT_FOR_ARCHS{,_REASON} or
ONLY_FOR_ARCHS{,_REASON}.

[1] https://www.freebsd.org/doc/en/books/porters-handbook/porting-order.html
Comment 5 Alan Somers freebsd_committer freebsd_triage 2018-05-24 15:08:58 UTC
Created attachment 193657 [details]
devel/kcov: new port

Fixes OPTIONS_DEFINE order, and sets ONLY_FOR_ARCHS=amd64
Comment 6 Tobias Kortkamp freebsd_committer freebsd_triage 2018-05-24 17:23:58 UTC
(In reply to Alan Somers from comment #5)

It also fails to build on 10.4/amd64 with the same error as on 10.4/i386, but
feel free to commit if you set IGNORE_FreeBSD_10 or BROKEN_FreeBSD_10 as well.

Also use USES=gettext-runtime instead of
LIB_DEPENDS=libintl.so:devel/gettext-runtime
Comment 7 Alan Somers freebsd_committer freebsd_triage 2018-05-25 03:23:43 UTC
Created attachment 193676 [details]
devel/kcov: new port

use "USES=gettext-runtime", and mark as broken on 10.4 due to PR 228478.
Comment 8 Tobias Kortkamp freebsd_committer freebsd_triage 2018-05-25 07:00:50 UTC
(In reply to Alan Somers from comment #7)
This doesn't work in the position you have it in.

+.if ${OPSYS} == FreeBSD && ${OSVERSION} < 1101000
+BROKEN=	PR228478 devel/elfutils: undefined symbols on 10.4-RELEASE
+.endif

It's also equivalent to BROKEN_FreeBSD_10 at this point since we do not support
anything other than 11.1-RELEASE and 10.4-RELEASE.
 
BROKEN_FreeBSD_10=	PR228478 devel/elfutils: undefined symbols on 10.4-RELEASE
Comment 9 Alan Somers freebsd_committer freebsd_triage 2018-05-25 12:34:05 UTC
Created attachment 193686 [details]
devel/kcov: new port

Prefer "BROKEN_FreeBSD_10" syntax over OSVERSION
Comment 10 Alan Somers freebsd_committer freebsd_triage 2018-05-27 22:43:01 UTC
Ping.  Does it look ok to you now, Tobias?  I'd like to get it committed soon, so it can make it into the next quarterly ports branch.
Comment 11 Tobias Kortkamp freebsd_committer freebsd_triage 2018-05-28 07:39:28 UTC
(In reply to Alan Somers from comment #10)
Please use a tab after BROKEN_FreeBSD_10 not a space.

Other than that I think I nitpicked enough, so go ahead and commit it.
Comment 12 Alan Somers freebsd_committer freebsd_triage 2018-05-28 13:01:45 UTC
Woohoo!  Thanks Tobias!
Comment 13 commit-hook freebsd_committer freebsd_triage 2018-05-28 13:03:06 UTC
A commit references this bug:

Author: asomers
Date: Mon May 28 13:02:55 UTC 2018
New revision: 471041
URL: https://svnweb.freebsd.org/changeset/ports/471041

Log:
  devel/kcov: new port

  kcov is a coverage analyzer that works with ELF, bash, and python programs.
  Unlike gcov, it works with uninstrumented binaries, requiring only that they
  include debugging symbols.  It is especially popular in the Rust community.

  PR:		228308
  Reviewed by:	tobik
  Approved by:	tobik (ports)

Changes:
  head/devel/Makefile
  head/devel/kcov/
  head/devel/kcov/Makefile
  head/devel/kcov/distinfo
  head/devel/kcov/files/
  head/devel/kcov/files/patch-src_CMakeLists.txt
  head/devel/kcov/pkg-descr