Bug 284004 - sysutils/lsof: Fails to build with "field has incomplete type 'struct sysctl_ctx_list'"
Summary: sysutils/lsof: Fails to build with "field has incomplete type 'struct sysctl_...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Larry Rosenman
URL:
Keywords:
: 284015 (view as bug list)
Depends on:
Blocks:
 
Reported: 2025-01-11 17:50 UTC by Dan Kotowski
Modified: 2025-01-14 17:26 UTC (History)
5 users (show)

See Also:
bugzilla: maintainer-feedback? (ler)


Attachments
poudriere bulk -j FreeBSD:15:amd64 -p latest (66.32 KB, text/plain)
2025-01-11 17:53 UTC, Dan Kotowski
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dan Kotowski 2025-01-11 17:50:27 UTC

    
Comment 1 Dan Kotowski 2025-01-11 17:52:06 UTC
--- store.o ---
In file included from store.c:31:
In file included from lib/common.h:253:
In file included from ./dlsof.h:171:
In file included from /usr/src/sys/rpc/rpc.h:68:
/usr/src/sys/rpc/svc.h:341:25: error: field has incomplete type 'struct sysctl_ctx_list'
--- util.o ---
In file included from util.c:37:
In file included from lib/common.h:253:
In file included from ./dlsof.h:171:
In file included from /usr/src/sys/rpc/rpc.h:68:
/usr/src/sys/rpc/svc.h:341:25: error: field has incomplete type 'struct sysctl_ctx_list'
  341 |         struct sysctl_ctx_list sp_sysctl;
      |                                ^
/usr/src/sys/rpc/svc.h:341:9: note: forward declaration of 'struct sysctl_ctx_list'
  341 |         struct sysctl_ctx_list sp_sysctl;
      |                ^
--- dmnt.o ---
In file included from dmnt.c:36:
In file included from lib/common.h:253:
In file included from ./dlsof.h:171:
In file included from /usr/src/sys/rpc/rpc.h:68:
/usr/src/sys/rpc/svc.h:341:25: error: field has incomplete type 'struct sysctl_ctx_list'
  341 |         struct sysctl_ctx_list sp_sysctl;
      |                                ^
/usr/src/sys/rpc/svc.h:341:9: note: forward declaration of 'struct sysctl_ctx_list'
  341 |         struct sysctl_ctx_list sp_sysctl;
      |                ^
Comment 2 Dan Kotowski 2025-01-11 17:53:49 UTC
Created attachment 256625 [details]
poudriere bulk -j FreeBSD:15:amd64 -p latest

=>> Building sysutils/lsof
build started at Sat Jan 11 16:04:53 UTC 2025
port directory: /usr/ports/sysutils/lsof
package name: lsof-4.99.4,8
building for: FreeBSD pkg1.a9development.com 15.0-CURRENT FreeBSD 15.0-CURRENT 1500030 amd64
maintained by: ler@FreeBSD.org
Makefile datestamp: -rw-r--r--  1 root wheel 1625 Dec 25 19:33 /usr/ports/sysutils/lsof/Makefile
Ports top last git commit: 51acd11ed5
Ports top unclean checkout: no
Port dir last git commit: 4821043f88
Port dir unclean checkout: no
Poudriere version: poudriere-git-3.4.2
Host OSVERSION: 1500030
Jail OSVERSION: 1500030
Job Id: 01
Comment 3 Larry Rosenman freebsd_committer freebsd_triage 2025-01-11 18:02:15 UTC
@glebius: I think you broke this?
Comment 4 Gleb Smirnoff freebsd_committer freebsd_triage 2025-01-11 18:15:51 UTC
On Sat Jan 11 18:02:15  2025 UTC, ler@FreeBSD.org wrote:
> @glebius: I think you broke this?

It was broken before me (as always with lsof). I exposed it.

It includes $SRC_BASE/rpc/rpc.h instead of /usr/include/rpc/rpc.h. Before it
was compilable, although it picked up declarations that aren't used anywhere.
Now it is not compilable.

I'll see if I can quickly find a solution.  But in general it should be task of
authors/maintainers of the software that violates all possible API conventions
both during build time and run time.
Comment 5 Gleb Smirnoff freebsd_committer freebsd_triage 2025-01-11 18:41:04 UTC
On Sat Jan 11 18:15:51  2025 UTC, glebius@FreeBSD.org wrote:
> It includes $SRC_BASE/rpc/rpc.h instead of /usr/include/rpc/rpc.h.

I tried to change '-I $SRC_BASE/sys' in the all Makefiles into
'-idirafter $SRC_BASE/sys', so that includes from /usr/include
are preferred over includes from the kernel sources.  This worked!

Hope this hint will help you to fix lsof.
Comment 6 Larry Rosenman freebsd_committer freebsd_triage 2025-01-11 20:09:04 UTC
What did you change and where?  I'm having a hard time finding it :)
Comment 7 Gleb Smirnoff freebsd_committer freebsd_triage 2025-01-11 20:36:03 UTC
On Sat Jan 11 20:09:04  2025 UTC, ler@FreeBSD.org wrote:
> What did you change and where?  I'm having a hard time finding it :)

After configure every Makefile has:

DINC=	-I/usr/src

(or whatever SRC_BASE you told the port)

If you change at least the ./Makefile and ./lib/Makefile to:

DINC=	-idirafter /usr/src

then it will prefer /usr/include/sys over /usr/src/sys/sys and
it will successfully build.  Of course better to fix all Makefiles.

I failed to quickly figure out how to fix that before configure
stage, but you got the idea.
Comment 8 commit-hook freebsd_committer freebsd_triage 2025-01-11 20:57:21 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=e16a8f7d71053d0074d26ce16593a8c284b22a82

commit e16a8f7d71053d0074d26ce16593a8c284b22a82
Author:     Larry Rosenman <ler@FreeBSD.org>
AuthorDate: 2025-01-11 20:56:33 +0000
Commit:     Larry Rosenman <ler@FreeBSD.org>
CommitDate: 2025-01-11 20:56:33 +0000

    sysutils/lsof: add PR

    PR: 284004

 sysutils/lsof/Makefile | 1 +
 1 file changed, 1 insertion(+)
Comment 9 Larry Rosenman freebsd_committer freebsd_triage 2025-01-11 20:59:23 UTC
Fix Committed -- Thanks!
Comment 10 Gleb Smirnoff freebsd_committer freebsd_triage 2025-01-11 21:06:00 UTC
On Sat Jan 11 20:59:23  2025 UTC, ler@FreeBSD.org wrote:
> Fix Committed -- Thanks!

But e16a8f7d71053d0074d26ce16593a8c284b22a82 didn't do any
meaningful change to the port.
Comment 12 Larry Rosenman freebsd_committer freebsd_triage 2025-01-12 01:27:19 UTC
Fix Failed -- Looking.
Comment 13 Larry Rosenman freebsd_committer freebsd_triage 2025-01-12 15:36:32 UTC
*** Bug 284015 has been marked as a duplicate of this bug. ***
Comment 14 Cy Schubert freebsd_committer freebsd_triage 2025-01-12 15:42:08 UTC
The patch does not fix the bug. Building with a recent (as of today) ports and src still fails to build.
Comment 15 Brad Davis freebsd_committer freebsd_triage 2025-01-13 22:21:12 UTC
This seems to have worked for me, at least it builds now..:

--- a/sysutils/lsof/Makefile
+++ b/sysutils/lsof/Makefile
@@ -40,7 +40,8 @@ BOOKE_CFLAGS= -DBOOKE
 CONFIGURE_SCRIPT=      Configure
 CONFIGURE_ARGS=                -n freebsd
 CONFIGURE_ENV=         FREEBSD_SYS="${SRC_BASE}/sys" \
-                       LSOF_CC="${CC}"
+                       LSOF_CC="${CC}" \
+                       LSOF_OPINC="-idirafter ${SRC_BASE}/sys"
Comment 16 Cy Schubert freebsd_committer freebsd_triage 2025-01-13 22:42:47 UTC
(In reply to Brad Davis from comment #15)

Confirmed. This is the correct patch.

There should also be a warning by the port to say that the sources (/usr/src), /usr/include, installed libraries and the running kernel must all be the same, i.e. the sources cannot be updated (git pull) ahead of the installed system: Make sure to do installworld before building lsof.

This of course wasn't my problem but considering src/ commit and this patch it stands to reason that any mismatch will be a source of breakage.
Comment 17 commit-hook freebsd_committer freebsd_triage 2025-01-13 23:52:43 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=efbb151650721f0dff7a761e08f7970951954ffa

commit efbb151650721f0dff7a761e08f7970951954ffa
Author:     Larry Rosenman <ler@FreeBSD.org>
AuthorDate: 2025-01-13 23:51:28 +0000
Commit:     Larry Rosenman <ler@FreeBSD.org>
CommitDate: 2025-01-13 23:52:23 +0000

    sysutils/lsof:  fix after recent breakage

    PR:     284004
    Patch By: brd, cy

 sysutils/lsof/Makefile | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
Comment 18 Larry Rosenman freebsd_committer freebsd_triage 2025-01-13 23:53:31 UTC
Committed for real.  Thanks brd and cy!
Comment 19 Brad Davis freebsd_committer freebsd_triage 2025-01-14 17:21:57 UTC
Thanks!  BTW, 'Submitted by' (or Patch by) has been deprecated by setting the author: https://docs.freebsd.org/en/articles/committers-guide/#_include_appropriate_metadata_in_a_footer
Comment 20 Cy Schubert freebsd_committer freebsd_triage 2025-01-14 17:26:13 UTC
(In reply to Brad Davis from comment #19)

Typically I git-am any patch that is submitted with a commit log message, either from git-format-patch or the person provides me with a commit log message. Otherwise, if I have to write the commit log message for the person I use the old standard.