Bug 269406 - x11-wm/plasma5-kwin: fails on FreeBSD < 13 after Plasma 5.26 update
Summary: x11-wm/plasma5-kwin: fails on FreeBSD < 13 after Plasma 5.26 update
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: freebsd-kde (group)
URL:
Keywords: needs-patch
Depends on:
Blocks:
 
Reported: 2023-02-08 11:34 UTC by Jan Beich
Modified: 2023-02-16 00:43 UTC (History)
4 users (show)

See Also:
tcberner: maintainer-feedback+


Attachments
v1 (apply via "git am") (4.81 KB, patch)
2023-02-08 12:45 UTC, Jan Beich
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Beich freebsd_committer freebsd_triage 2023-02-08 11:34:54 UTC
Regressed by ports d06d26f8c45e

FreeBSD < 13, DragonFly, NetBSD, OpenBSD don't support sealing. Neither Linux nor FreeBSD support sealing regular files.

https://elixir.bootlin.com/linux/latest/A/ident/F_SEAL_WRITE
https://cgit.freebsd.org/src/commit/?id=af755d3e4859

src/utils/ramfile.cpp:80:17: error: use of undeclared identifier 'F_SEAL_SHRINK'
    int seals = F_SEAL_SHRINK | F_SEAL_GROW | F_SEAL_SEAL;
                ^
src/utils/ramfile.cpp:80:33: error: use of undeclared identifier 'F_SEAL_GROW'
    int seals = F_SEAL_SHRINK | F_SEAL_GROW | F_SEAL_SEAL;
                                ^
src/utils/ramfile.cpp:80:47: error: use of undeclared identifier 'F_SEAL_SEAL'
    int seals = F_SEAL_SHRINK | F_SEAL_GROW | F_SEAL_SEAL;
                                              ^
src/utils/ramfile.cpp:82:18: error: use of undeclared identifier 'F_SEAL_WRITE'
        seals |= F_SEAL_WRITE;
                 ^
src/utils/ramfile.cpp:85:21: error: use of undeclared identifier 'F_ADD_SEALS'
    if (fcntl(fd(), F_ADD_SEALS, seals) != 0) {
                    ^
src/utils/ramfile.cpp:139:35: error: use of undeclared identifier 'F_GET_SEALS'
    const int seals = fcntl(fd(), F_GET_SEALS);
                                  ^
src/utils/ramfile.cpp:141:21: error: use of undeclared identifier 'F_SEAL_WRITE'
        if (seals & F_SEAL_WRITE) {
                    ^
7 errors generated.
Comment 1 Martin Birgmeier 2023-02-08 11:53:27 UTC
Yes, this seems to be a bug in kwin. The file src/plugins/screencast/screencaststream.cpp guards against using F_SEAL if it is not available, but src/utils/ramfile.* does not.

Most likely this can be fixed by a few well-placed #ifdef F_SEAL_SEAL or similar.

That being said, thank you very much to the FreeBSD KDE team to have managed to bring plasma 5.26 to FreeBSD!

-- Martin
Comment 2 Jan Beich freebsd_committer freebsd_triage 2023-02-08 12:45:27 UTC
Created attachment 239996 [details]
v1 (apply via "git am")

Why "#ifdef F_SEAL_SEAL" instead of "#if HAVE_MEMFD" ? When memfd_create() isn't available KWin falls back to QTemporaryFile which on Linux uses O_TMPFILE aka "unnamed temporary regular file" under TMPDIR. Does it actually work? Do any other projects use sealing outside of memfd_create() ?

Note, FreeBSD 12.3 (unlike 12.4) had more errors:

src/utils/ramfile.cpp:57:117: error: use of undeclared identifier 'errno'
        qCWarning(KWIN_CORE).nospace() << name << ": Failed to remove temporary file from filesystem: " << strerror(errno);
                                                                                                                    ^
src/backends/drm/drm_qpainter_layer.cpp:54:79: error: use of undeclared identifier 'errno'
        qCWarning(KWIN_DRM, "Failed to create dumb framebuffer: %s", strerror(errno));
                                                                              ^
src/backends/drm/drm_qpainter_layer.cpp:66:87: error: use of undeclared identifier 'errno'
                qCWarning(KWIN_DRM, "Failed to create dumb framebuffer: %s", strerror(errno));
                                                                                      ^
src/backends/drm/drm_qpainter_layer.cpp:121:94: error: use of undeclared identifier 'errno'
        qCWarning(KWIN_DRM, "Failed to create dumb framebuffer for the cursor: %s", strerror(errno));
                                                                                             ^
Comment 3 Robert 2023-02-09 23:57:30 UTC
Just applied the changes suggested in the patch provided, using FBSD 12.4, and Plasma5-kein compiles successfully! Now the rest of the Plasma5 that depend on that to update properly can be run. Thanks very much for your expert assistance!
Comment 4 Tobias C. Berner freebsd_committer freebsd_triage 2023-02-11 04:52:22 UTC
lgtm
Comment 5 Robert 2023-02-15 17:17:48 UTC
The latest version of this port, 5.27, also fails at the same point if the FBSD version is less than 13. Making the same changes as @Jan posted in attachment 239996 [details] works perfectly in that newer version to get the compile job finished snd complete.
Thanks again, Jan Beich, for posting the patch.
Comment 6 Jan Beich freebsd_committer freebsd_triage 2023-02-16 00:43:11 UTC
I don't like #ifdef F_SEAL_SEAL but if kde@ is fine then whatever. Upstreaming is not my problem (note: kwinft isn't affected).

5.27 (unlike 5.26) needed one more fix on 12.3 (unlike 12.4):

src/backends/x11/windowed/x11_windowed_qpainter_backend.cpp:47:71: error: use of undeclared identifier 'errno'
        qCWarning(KWIN_X11WINDOWED) << "shmget() failed:" << strerror(errno);
                                                                      ^
src/backends/x11/windowed/x11_windowed_qpainter_backend.cpp:54:70: error: use of undeclared identifier 'errno'
        qCWarning(KWIN_X11WINDOWED) << "shmat() failed:" << strerror(errno);
                                                                     ^
Comment 7 commit-hook freebsd_committer freebsd_triage 2023-02-16 00:43:53 UTC
A commit in branch main references this bug:

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

commit 46c2184d862f3344afdea9d9a203929b80243535
Author:     Jan Beich <jbeich@FreeBSD.org>
AuthorDate: 2023-02-08 11:22:24 +0000
Commit:     Jan Beich <jbeich@FreeBSD.org>
CommitDate: 2023-02-16 00:36:18 +0000

    x11-wm/plasma5-kwin: unbreak on FreeBSD < 13 after d06d26f8c45e

    PR:             269406
    Approved by:    tcberner

 ...src_backends_drm_drm__qpainter__layer.cpp (new) | 20 +++++++
 ...owed_x11__windowed__qpainter__backend.cpp (new) | 17 ++++++
 .../files/patch-src_utils_ramfile.cpp (new)        | 68 ++++++++++++++++++++++
 3 files changed, 105 insertions(+)