Solved Can't compile lsof after upgrading 11.2 to 12.0

After upgrading a different machine from 11.2 to 12.0 I naturally got some issues recompiling ports. I managed to get all of them fixed exept lsof:

Code:
--- lib/liblsof.a ---
In file included from ckkv.c:43:
In file included from ./../lsof.h:58:
/usr/include/stdio.h:77:9: error: unknown type name '__va_list'
typedef __va_list       va_list;
        ^
In file included from ckkv.c:43:
In file included from ./../lsof.h:221:
In file included from ./../dlsof.h:41:
/usr/include/stdlib.h:95:7: error: expected function body after function declarator
             __alloc_size2(1, 2);
             ^
/usr/include/stdlib.h:305:6: error: expected function body after function declarator
            __alloc_size2(2, 3);
            ^
--- dmnt.o ---
In file included from dmnt.c:39:
In file included from ./lsof.h:58:
/usr/include/stdio.h:77:9: error: unknown type name '__va_list'
typedef __va_list       va_list;
        ^
In file included from dmnt.c:39:
In file included from ./lsof.h:221:
In file included from ./dlsof.h:41:
/usr/include/stdlib.h:95:7: error: expected function body after function declarator
             __alloc_size2(1, 2);
             ^
/usr/include/stdlib.h:305:6: error: expected function body after function declarator
            __alloc_size2(2, 3);
            ^
--- lib/liblsof.a ---
In file included from ckkv.c:43:
In file included from ./../lsof.h:221:
In file included from ./../dlsof.h:277:
/usr/include/kvm.h:67:2: error: unknown type name 'kvaddr_t'
        kvaddr_t n_value;
        ^
/usr/include/kvm.h:122:28: error: unknown type name 'kvaddr_t'
            int (*)(const char *, kvaddr_t *));
                                  ^
In file included from ckkv.c:43:
In file included from ./../lsof.h:221:
In file included from ./../dlsof.h:400:
In file included from /usr/src/sys/sys/file.h:42:
In file included from /usr/src/sys/sys/refcount.h:36:
/usr/src/sys/sys/systm.h:209:27: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
void    vpanic(const char *, __va_list) __dead2 __printflike(1, 0);
                             ^
/usr/src/sys/sys/systm.h:225:6: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
            __va_list) __printflike(1, 0);
            ^
--- dmnt.o ---
In file included from dmnt.c:39:
In file included from ./lsof.h:221:
In file included from ./dlsof.h:277:
/usr/include/kvm.h:67:2: error: unknown type name 'kvaddr_t'
        kvaddr_t n_value;
        ^
/usr/include/kvm.h:122:28: error: unknown type name 'kvaddr_t'
            int (*)(const char *, kvaddr_t *));
                                  ^
In file included from dmnt.c:39:
In file included from ./lsof.h:221:
In file included from ./dlsof.h:400:
In file included from /usr/src/sys/sys/file.h:42:
In file included from /usr/src/sys/sys/refcount.h:36:
/usr/src/sys/sys/systm.h:209:27: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
void    vpanic(const char *, __va_list) __dead2 __printflike(1, 0);
                             ^
/usr/src/sys/sys/systm.h:225:6: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
            __va_list) __printflike(1, 0);
            ^
/usr/src/sys/sys/systm.h:228:30: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
--- lib/liblsof.a ---
/usr/src/sys/sys/systm.h:228:30: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
void    vlog(int, const char *, __va_list) __printflike(2, 0);
                                ^
/usr/src/sys/sys/systm.h:235:27: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
int     vprintf(const char *, __va_list) __printflike(1, 0);
                              ^
/usr/src/sys/sys/systm.h:237:6: error: unknown type name '__va_list'
            __va_list ap) __printflike(3, 0);
            ^
/usr/src/sys/sys/systm.h:238:45: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
int     vsnprintf(char *, size_t, const char *, __va_list) __printflike(3, 0);
                                                ^
/usr/src/sys/sys/systm.h:239:51: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
int     vsnrprintf(char *, size_t, int, const char *, __va_list) __printflike(4, 0);
                                                      ^
--- dmnt.o ---
void    vlog(int, const char *, __va_list) __printflike(2, 0);
                                ^
/usr/src/sys/sys/systm.h:235:27: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
int     vprintf(const char *, __va_list) __printflike(1, 0);
                              ^
/usr/src/sys/sys/systm.h:237:6: error: unknown type name '__va_list'
            __va_list ap) __printflike(3, 0);
            ^
/usr/src/sys/sys/systm.h:238:45: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
int     vsnprintf(char *, size_t, const char *, __va_list) __printflike(3, 0);
                                                ^
/usr/src/sys/sys/systm.h:239:51: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
int     vsnrprintf(char *, size_t, int, const char *, __va_list) __printflike(4, 0);
                                                      ^
/usr/src/sys/sys/systm.h:240:39: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
--- lib/liblsof.a ---
/usr/src/sys/sys/systm.h:240:39: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
int     vsprintf(char *buf, const char *, __va_list) __printflike(2, 0);
                                          ^
/usr/src/sys/sys/systm.h:243:59: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
int     vsscanf(const char * _Nonnull, char const * _Nonnull, __va_list)  __scanflike(2, 0);
                                                              ^
/usr/src/sys/sys/systm.h:249:49: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
void    vtprintf(struct proc *, int, const char *, __va_list) __printflike(3, 0);
                                                   ^
--- dmnt.o ---
int     vsprintf(char *buf, const char *, __va_list) __printflike(2, 0);
                                          ^
/usr/src/sys/sys/systm.h:243:59: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
int     vsscanf(const char * _Nonnull, char const * _Nonnull, __va_list)  __scanflike(2, 0);
                                                              ^
/usr/src/sys/sys/systm.h:249:49: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
void    vtprintf(struct proc *, int, const char *, __va_list) __printflike(3, 0);
                                                   ^
9 warnings and 6 errors generated.
*** [dmnt.o] Error code 1

make[1]: stopped in /usr/ports/sysutils/lsof/work/lsof_4.92B.freebsd
--- lib/liblsof.a ---
9 warnings and 6 errors generated.
*** [ckkv.o] Error code 1

make[2]: stopped in /usr/ports/sysutils/lsof/work/lsof_4.92B.freebsd/lib
1 error

make[2]: stopped in /usr/ports/sysutils/lsof/work/lsof_4.92B.freebsd/lib
*** [lib/liblsof.a] Error code 2

make[1]: stopped in /usr/ports/sysutils/lsof/work/lsof_4.92B.freebsd
2 errors

make[1]: stopped in /usr/ports/sysutils/lsof/work/lsof_4.92B.freebsd
===> Compilation failed unexpectedly.
Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
the maintainer.
*** Error code 1

Stop.
make: stopped in /usr/ports/sysutils/lsof

Googling gave result for a completely different port:

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=226198

I understand it is a dependancy issue in stdio, but I have no idea how to proceed.

I have not yet tried portdowngrade to some older version...
 
I tried recompiling all ports again, but it went worse than last time:
1 unknown build error (lsof)
30 uninstall error
219 skipped

I guess I have to invest some time to get those uninstall errors fixed and see if this has fixed the lsof compile problem.
 
Is lsof a dependency or something you installed because of familiarity with the command itself? Because if it's the latter then fuser could also be a solid replacement.

Still, I think your best option would be to contact the port maintainer (see make maintainer).

However... What I often also try to do is: # portmaster `make build-depends-list | cut -d '/' -f4-` |& tee build.log. In other words: re-build all of the direct build dependencies to see if that somehow fixes the problem. Sometimes build problems can be caused by glitches (for example: a port which should have been rebuild but isn't just yet). Instead of rebuilding a whole chain of ports this sometimes also does the trick.

The other option is of course to go 'all out' and rebuild all dependencies: portmaster -f sysutils/lsof |& tee build.log.

Hope this can help.
 
lsof is needed for sysutils/htop that I like to use.

Anyway, will continue messing with the system in the evening/night. Original plan was to get the upgrade done on weekend... And I mostly succeeded.
 
It appears that this dependency is optional:
Code:
$ make showconfig                                                                
===> The following configuration options are available for htop-2.2.0:
     LSOF=on: LiSt Open Files utility support
===> Use 'make config' to modify these settings
So worst case scenario could be to build it without support until they fixed lsof.
 
As acheron already mentioned, /usr/src must contain the actual source tree of the FreeBSD version that you are running. This is very important because lsof requires certain parts of the kernel sources for compilation.

Other than that – Here are a few more generic hints.
  • Make sure you have a supported version of FreeBSD. (In this case, 12.0 is supported, of course.)
  • If you have built your base system yourself, make sure that it contains everything needed by the port in question. For example, you can disable Kerberos via /etc/src.conf, but there are ports that won't build without it. If in doubt, rebuild your base system with empty /etc/src.conf.
  • Update your ports tree (see portsnap(8)). You can also check the Subversion repository for any changes made to the port in question since you last updated your ports tree.
  • Check your /etc/make.conf. If in doubt, disable it (e.g. rename it).
  • Check your environment variables. I've had cases where Makefiles or scripts picked up variables from my environment that were meant for a completely different purpose. Building the port with env -i PATH=$PATH make … (or similar) fixed the problem.
  • Remove and rebuild all dependencies of the port.
  • If everything else fails, create a pristine jail that contains your base system (same version!), but no ports, then build the port in question inside that jail. If that succeeds, create a package inside the jail ( pkg create …), copy it to the host system and install it there ( pkg install -U yourpackage.txz). Note that, for lsof, /usr/src also needs to be present inside the jail. A read-only nullfs(5) mount from the host's /usr/src will suffice.
  • … And if that still fails, ask on an appropriate mailing list or web forum if anybody else can reproduce the problem. Or ask the maintainer of the port.
 
I did not build the system, I used binary upgrade as in guide:
https://www.freebsd.org/releases/12.0R/installation.html#upgrade-binary

And yes, seems /usr/src is old for some reason:
Code:
This file was last revised on:
$FreeBSD: releng/11.1/README 318447 2017-05-18 12:27:41Z gjb

While in another system that I also upgraded it is:
Code:
This file was last revised on:
$FreeBSD: releng/12.0/README 335299 2018-06-17 19:44:24Z eadler

Now I don't know what I did wrong - did I forget one of the steps in upgrade?
What is strange, that I upgraded from 11.2, but the file is 11.1 - seems i did not upgrade /usr/src last time either, 11.1 -> 11.2

This system started out as preinstalled 11.1 in provider virtual server, did not install it myself.
 
And yes, seems /usr/src is old for some reason
Well, that clearly explains the problems with building lsof.
Now I don't know what I did wrong - did I forget one of the steps in upgrade?
What is strange, that I upgraded from 11.2, but the file is 11.1 - seems i did not upgrade /usr/src last time either, 11.1 -> 11.2

This system started out as preinstalled 11.1 in provider virtual server, did not install it myself.
You can configure in /etc/freebsd-update.conf whether the system sources should be updated, too. See the freebsd-update.conf(5) manual page, in particular the “Components” setting.

By the way, the file sys/conf/newvers.sh is quite useful to find out which version a particular source tree belongs to. For example, it contains lines like these:
Code:
REVISION="11.2"
BRANCH="STABLE"
or:
Code:
REVISION="12.0"
BRANCH="RELEASE"
 
So, I deleted /usr/src and downloaded new one from SVN.

I modified /etc/freebsd-update.conf for the future:
Code:
Components src world kernel world/lib32

I recompiled ALL ports again (takes over 24h on this virtual server).

But still can't make sysutils/lsof to compile, now with different error:

Code:
--- dnode2.o ---
In file included from dnode2.c:56:
In file included from /usr/src/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_znode.h:33:
In file included from /usr/src/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu.h:47:
In file included from /usr/src/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_context.h:73:
In file included from /usr/src/sys/cddl/compat/opensolaris/sys/vfs.h:37:
/usr/src/sys/cddl/compat/opensolaris/sys/vnode.h:243:10: warning: implicit declaration of function 'VOP_FSYNC' is invalid in C99 [-Wimplicit-function-declaration]
        error = VOP_FSYNC(vp, MNT_WAIT, curthread);
                ^
/usr/src/sys/cddl/compat/opensolaris/sys/vnode.h:281:61: error: too many arguments to function call, expected 5, have 6
        return (kern_unlinkat(curthread, AT_FDCWD, fnamep, seg, 0, 0));
                ~~~~~~~~~~~~~                                      ^
/usr/include/sys/syscallsubr.h:288:1: note: 'kern_unlinkat' declared here
int     kern_unlinkat(struct thread *td, int fd, char *path,
^
--- lib/liblsof.a ---
--- ptti.o ---
cc   -pipe -march=core2 -fstack-protector -fno-strict-aliasing -DNEEDS_BOOL_TYPEDEF -DHASTASKS -DHAS_PAUSE_SBT -DHAS_DUP2 -DHAS_CLOSEFROM -DHASEFFNLINK=i_effnlink -DHASF_VNODE -DHAS_FILEDESCENT -DHAS_TMPFS -DHASWCTYPE_H -DHASSBSTATE -DHAS_KVM_VNODE -DHAS_UFS1_2 -DHAS_NO_IDEV -DHAS_VM_MEMATTR_T -DNEEDS_DEVICE_T -DHAS_CDEV2PRIV -DHAS_NO_SI_UDEV -DHAS_SYS_SX_H -DHASFUSEFS -DHAS_ZFS -DHAS_V_LOCKF -DHAS_LOCKF_ENTRY -DHAS_NO_6PORT -DHAS_NO_6PPCB -DNEEDS_BOOLEAN_T -DHAS_SB_CCC -DHAS_FDESCENTTBL -DFREEBSDV=12000 -DHASFDESCFS=2 -DHASPSEUDOFS -DHASNULLFS -DHASIPv6 -DHASUTMPX -DHAS_STRFTIME -DLSOF_VSTR="12.0-RELEASE" -I/usr/src/sys -O2 -c ptti.c -o ptti.o
--- dnode2.o ---
1 warning and 1 error generated.
*** [dnode2.o] Error code 1

make[2]: stopped in /usr/ports/sysutils/lsof/work/lsof_4.92B.freebsd
1 error

make[2]: stopped in /usr/ports/sysutils/lsof/work/lsof_4.92B.freebsd
*** [dnode2.o] Error code 2

make[1]: stopped in /usr/ports/sysutils/lsof/work/lsof_4.92B.freebsd
--- lib/liblsof.a ---
A failure has been detected in another branch of the parallel make

make[2]: stopped in /usr/ports/sysutils/lsof/work/lsof_4.92B.freebsd/lib
*** [lib/liblsof.a] Error code 2

make[1]: stopped in /usr/ports/sysutils/lsof/work/lsof_4.92B.freebsd
2 errors

make[1]: stopped in /usr/ports/sysutils/lsof/work/lsof_4.92B.freebsd
===> Compilation failed unexpectedly.
Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
the maintainer.
*** Error code 1

Stop.
make: stopped in /usr/ports/sysutils/lsof

Ports tree is updated with portsnap.

Renaming /etc/make.conf did not help
 
Code:
# svn info /usr/src
Path: /usr/src
Working Copy Root Path: /usr/src
URL: svn://svn.freebsd.org/base/head
Relative URL: ^/head
Repository Root: svn://svn.freebsd.org/base
Repository UUID: ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Revision: 342466
Node Kind: directory
Schedule: normal
Last Changed Author: kevans
Last Changed Rev: 342466
Last Changed Date: 2018-12-25 17:18:41 +0200 (Tue, 25 Dec 2018)
 
Ah, guess I followed some howto from another forum post, not understanding what i am doing...

EDIT: that fixed it, with right /usr/src was ablo to compile lsof and htop again. Now will just recompile all ports again, to be on the safe side...
 
Back
Top