Bug 212843

Summary: sysutils/pftop: fails to build on FreeBSD 9.x
Product: Ports & Packages Reporter: Yani Karydis <yani>
Component: Individual Port(s)Assignee: Marcelo Araujo <araujo>
Status: Closed Overcome By Events    
Severity: Affects Many People CC: andrew.daugherity, miwi
Priority: --- Flags: bugzilla: maintainer-feedback? (araujo)
Version: Latest   
Hardware: amd64   
OS: Any   

Description Yani Karydis 2016-09-20 08:29:03 UTC
Hello,

Building on FreeBSD 9.x (amd64) fails with the following error:

Warning: Object directory not changed from original /mnt/tdata/miniserver/ports/usr/ports/sysutils/pftop/work/pftop-0.7
gzip -cn pftop.8 > pftop.8.gz
yacc -d -o sf-grammer.c sf-grammer.y
lex -t  sf-scanner.l > sf-scanner.c
cc -march=native -O2 -fno-strict-aliasing -pipe -DHAVE_ALTQ=1 -DHAVE_SNPRINTF=1 -DHAVE_VSNPRINTF=1 -fstack-protector  -Wall -DOS_LEVEL=45 -std=gnu89  -fstack-protector  -c pftop.c
cc -march=native -O2 -fno-strict-aliasing -pipe -DHAVE_ALTQ=1 -DHAVE_SNPRINTF=1 -DHAVE_VSNPRINTF=1 -fstack-protector  -Wall -DOS_LEVEL=45 -std=gnu89  -fstack-protector  -c cache.c
cc -march=native -O2 -fno-strict-aliasing -pipe -DHAVE_ALTQ=1 -DHAVE_SNPRINTF=1 -DHAVE_VSNPRINTF=1 -fstack-protector  -Wall -DOS_LEVEL=45 -std=gnu89  -fstack-protector  -c engine.c
cc -march=native -O2 -fno-strict-aliasing -pipe -DHAVE_ALTQ=1 -DHAVE_SNPRINTF=1 -DHAVE_VSNPRINTF=1 -fstack-protector  -Wall -DOS_LEVEL=45 -std=gnu89  -fstack-protector  -c sf-gencode.c
pftop.c: In function 'read_states':
pftop.c:857: warning: pointer targets in passing argument 2 of 'bpf_filter' differ in signedness
sf-gencode.c: In function 'gen_ifname':
sf-gencode.c:1861: warning: pointer targets in passing argument 3 of 'gen_bcmp' differ in signedness
cc -march=native -O2 -fno-strict-aliasing -pipe -DHAVE_ALTQ=1 -DHAVE_SNPRINTF=1 -DHAVE_VSNPRINTF=1 -fstack-protector  -Wall -DOS_LEVEL=45 -std=gnu89  -fstack-protector  -c sf-grammer.c
cc -march=native -O2 -fno-strict-aliasing -pipe -DHAVE_ALTQ=1 -DHAVE_SNPRINTF=1 -DHAVE_VSNPRINTF=1 -fstack-protector  -Wall -DOS_LEVEL=45 -std=gnu89  -fstack-protector  -c pcap-nametoaddr.c
cc -march=native -O2 -fno-strict-aliasing -pipe -DHAVE_ALTQ=1 -DHAVE_SNPRINTF=1 -DHAVE_VSNPRINTF=1 -fstack-protector  -Wall -DOS_LEVEL=45 -std=gnu89  -fstack-protector  -c bpf_optimize.c
cc -march=native -O2 -fno-strict-aliasing -pipe -DHAVE_ALTQ=1 -DHAVE_SNPRINTF=1 -DHAVE_VSNPRINTF=1 -fstack-protector  -Wall -DOS_LEVEL=45 -std=gnu89  -fstack-protector  -c bpf_filter.c
cc -march=native -O2 -fno-strict-aliasing -pipe -DHAVE_ALTQ=1 -DHAVE_SNPRINTF=1 -DHAVE_VSNPRINTF=1 -fstack-protector  -Wall -DOS_LEVEL=45 -std=gnu89  -fstack-protector  -c bpf_dump.c
bpf_filter.c: In function 'bpf_filter':
bpf_filter.c:150: error: argument 'pc' doesn't match prototype
/usr/include/pcap/pcap.h:412: error: prototype declaration
bpf_filter.c:150: error: argument 'p' doesn't match prototype
/usr/include/pcap/pcap.h:412: error: prototype declaration
*** [bpf_filter.o] Error code 1
1 error
===> Compilation failed unexpectedly.
Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
the maintainer.
*** [do-build] Error code 1

Stop in /usr/ports/sysutils/pftop.

===>>> make build failed for sysutils/pftop
===>>> Aborting update


===>>> You can restart from the point of failure with this command line:
       portmaster <flags> sysutils/pftop
Comment 1 Andrew Daugherity 2016-11-07 19:02:40 UTC
The problem is that files/patch-bpf_filter.c and files/patch-bpf_image.c (introduced in ports r422236) should only be applied to FreeBSD >= 11.0.  These patches are not correct for 10.x either, but whereas gcc aborts, clang only logs a warning:
====
--- bpf_filter.o ---
bpf_filter.c:146:25: warning: promoted type 'const struct bpf_insn *' of K&R function parameter is not compatible with the parameter type 'struct bpf_insn *' declared in a previous prototype [-Wknr-promoted-parameter]
        const struct bpf_insn *pc;
                               ^
/usr/include/pcap/pcap.h:412:35: note: previous declaration is here
u_int   bpf_filter(struct bpf_insn *, u_char *, u_int, u_int);
                                    ^
bpf_filter.c:147:16: warning: promoted type 'const u_char *' (aka 'const unsigned char *') of K&R function parameter is not compatible with the parameter type 'u_char *' (aka 'unsigned char *') declared in a previous prototype [-Wknr-promoted-parameter]
        const u_char *p;
                      ^
/usr/include/pcap/pcap.h:412:45: note: previous declaration is here
u_int   bpf_filter(struct bpf_insn *, u_char *, u_int, u_int);
                                              ^
2 warnings generated.
--- bpf_image.o ---
cc -O2 -pipe  -DHAVE_ALTQ=1 -DHAVE_SNPRINTF=1 -DHAVE_VSNPRINTF=1 -DHAVE_FINE_GRAINED_LOCKING=1 -fstack-protector -fno-strict-aliasing   -Wall -DOS_LEVEL=45 -std=gnu89 -Qunused-arguments  -fstack-protector   -c bpf_image.c -o bpf_image.o
bpf_image.c:39:25: warning: promoted type 'const struct bpf_insn *' of K&R function parameter is not compatible with the parameter type 'struct bpf_insn *' declared in a previous prototype [-Wknr-promoted-parameter]
        const struct bpf_insn *p;
                               ^
/usr/include/pcap/pcap.h:415:34: note: previous declaration is here
char    *bpf_image(struct bpf_insn *, int);
                                    ^
bpf_image.c:283:25: warning: data argument not used by format string [-Wformat-extra-args]
                      n, op, operand, n + 1 + p->jt, n + 1 + p->jf);
                                      ^
2 warnings generated.
====

On 9.x and 10.x, /usr/include/pcap/pcap.h (contrib/libpcap/pcap/pcap.h in the source tree) does not have the const declarations in the bpf_filter() and bpf_image() prototypes.  If I move those two patches out of the way (and comment out "BROKEN_FreeBSD_9" in the Makefile), it now builds fine on 9.3 and the warnings are gone on 10.3.

I don't know the proper ports incantation to say "only apply these patches on >= 11.0"; I could take a guess based on other parts of the Makefile, but I'll leave it to someone who knows what they're doing.
Comment 2 Martin Wilke freebsd_committer freebsd_triage 2017-05-04 03:48:41 UTC
FreeBSD 9 is no longer support.