Bug 265024 - multimedia/v4l-utils: fails to build with libepoll-shim 0.0.20220703
Summary: multimedia/v4l-utils: fails to build with libepoll-shim 0.0.20220703
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: Hans Petter Selasky
URL:
Keywords: needs-patch
Depends on:
Blocks: 265017
  Show dependency treegraph
 
Reported: 2022-07-04 07:52 UTC by Jan Beich
Modified: 2022-08-01 11:15 UTC (History)
3 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Beich freebsd_committer freebsd_triage 2022-07-04 07:52:21 UTC
Apply bug 265017 then try to build. See also 265021 comment 1.

$ make
[...]
In file included from v4l2-ctl.cpp:31:
In file included from ./v4l2-ctl.h:26:
In file included from ../../utils/common/cv4l-helpers.h:13:
../../utils/common/v4l-helpers.h:248:15: error: no member named 'epoll_shim_close' in 'v4l_fd'
        int res = f->close(f);
                  ~  ^
/usr/local/include/libepoll-shim/epoll-shim/detail/common.h:18:20: note: expanded from macro 'close'
#define close(...) epoll_shim_close(__VA_ARGS__)
                   ^
In file included from v4l2-ctl.cpp:31:
In file included from ./v4l2-ctl.h:26:
In file included from ../../utils/common/cv4l-helpers.h:13:
../../utils/common/v4l-helpers.h:462:6: error: no member named 'epoll_shim_close' in 'v4l_fd'
                f->close(f);
                ~  ^
/usr/local/include/libepoll-shim/epoll-shim/detail/common.h:18:20: note: expanded from macro 'close'
#define close(...) epoll_shim_close(__VA_ARGS__)
                   ^
In file included from v4l2-ctl.cpp:31:
In file included from ./v4l2-ctl.h:26:
In file included from ../../utils/common/cv4l-helpers.h:13:
../../utils/common/v4l-helpers.h:511:6: error: no member named 'epoll_shim_close' in 'v4l_fd'
                f->close(f);
                ~  ^
/usr/local/include/libepoll-shim/epoll-shim/detail/common.h:18:20: note: expanded from macro 'close'
#define close(...) epoll_shim_close(__VA_ARGS__)
                   ^
In file included from v4l2-ctl.cpp:31:
In file included from ./v4l2-ctl.h:26:
In file included from ../../utils/common/cv4l-helpers.h:13:
../../utils/common/v4l-helpers.h:544:6: error: no member named 'epoll_shim_close' in 'v4l_fd'
                f->close(f);
                ~  ^
/usr/local/include/libepoll-shim/epoll-shim/detail/common.h:18:20: note: expanded from macro 'close'
#define close(...) epoll_shim_close(__VA_ARGS__)
                   ^
In file included from v4l2-ctl.cpp:31:
In file included from ./v4l2-ctl.h:26:
In file included from ../../utils/common/cv4l-helpers.h:13:
../../utils/common/v4l-helpers.h:576:5: error: no member named 'epoll_shim_close' in 'v4l_fd'
        f->close(f);
        ~  ^
/usr/local/include/libepoll-shim/epoll-shim/detail/common.h:18:20: note: expanded from macro 'close'
#define close(...) epoll_shim_close(__VA_ARGS__)
                   ^
Comment 1 Hans Petter Selasky freebsd_committer freebsd_triage 2022-07-04 09:21:26 UTC
Hi Jan,

I think it is not a good idea to have a macro duped close().

Can you ask someone to replace all these macros open/close/read/write .... with static inline functions instead, in upstream?

/usr/local/include/libepoll-shim/epoll-shim/detail/common.h:18:20: note: expanded from macro 'close'
#define close(...) epoll_shim_close(__VA_ARGS__)

--HPS
Comment 2 Hans Petter Selasky freebsd_committer freebsd_triage 2022-07-04 09:22:55 UTC
If my suggestion is not possible, I will make a patch for the rshim, to avoid use of a function pointer named "close".

--HPS
Comment 3 Hans Petter Selasky freebsd_committer freebsd_triage 2022-07-04 09:33:18 UTC
Hi,

Can epollshim do like this, for "close" and all other similar functions:

#define close(...) close(__VA_ARGS__)
static inline int close(int fd)
{
epoll_shim_close(fd);
}
#undef close

Maybe you need a similar hack before including the global definition of close and friends too:

#define close(...) close_not_used(__VA_ARGS__)
#include <unistd.h>
#undef close

--HPS
Comment 4 Jan Kokemüller 2022-07-04 17:09:44 UTC
Would this also work? This replaces "f->close(f)" with "(f->close)(f)" similar to <https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=265021#c2>.


diff --git a/multimedia/libv4l/Makefile b/multimedia/libv4l/Makefile
index ff1a2d757e7..186f61d12ae 100644
--- a/multimedia/libv4l/Makefile
+++ b/multimedia/libv4l/Makefile
@@ -78,6 +78,11 @@ post-patch:
 # Don't build translation files for now
        @${REINPLACE_CMD} -e 's|v4l-utils-po libdvbv5-po||g' ${WRKSRC}/Makefile.am
 .endif
+.if ${PORTNAME} == v4l-utils
+       @${REINPLACE_CMD} -e 's|\([^[:space:]]*\->close\)(|(\1)(|g' \
+               ${WRKSRC}/utils/common/cv4l-helpers.h \
+               ${WRKSRC}/utils/common/v4l-helpers.h
+.endif
 # Remove old FreeBSD include files (to be removed upstream)
        @${RM} -r ${WRKSRC}/contrib/freebsd/include/*
 # Create symbolic link for Linux sources
Comment 5 Hans Petter Selasky freebsd_committer freebsd_triage 2022-07-05 08:55:36 UTC
This will be fixed in libepoll-shim. Working on upstream patch!
Comment 6 Hans Petter Selasky freebsd_committer freebsd_triage 2022-07-05 09:23:12 UTC
I see epoll-shim already has interpose support. So I guess that's what we need to use. Let me just set a build environment to test.
Comment 7 Alexis Praga 2022-08-01 07:29:12 UTC
(In reply to Hans Petter Selasky from comment #6)
Hi,

Did you manage to fix this issue ? We may have a similar problem in : https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=265393.

Thanks
Comment 8 Hans Petter Selasky freebsd_committer freebsd_triage 2022-08-01 11:15:31 UTC
(In reply to Alexis Praga from comment #7)

Hi,

Have a look at the diffs in this change:

https://cgit.freebsd.org/ports/commit/?id=04db4ece5bdc66c75c8c4ff557e20a06c99e8bf0

Basically the epoll shim now has two interfaces, one which uses the macros and one which use the interpose support (correct way).

--HPS