Bug 260885 - games/openclonk: Fix build
Summary: games/openclonk: Fix build
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: Jan Beich
URL: http://beefy16.nyi.freebsd.org/data/1...
Keywords:
Depends on:
Blocks: 252371
  Show dependency treegraph
 
Reported: 2022-01-02 18:11 UTC by Kevin Zheng
Modified: 2022-01-03 21:48 UTC (History)
1 user (show)

See Also:
jbeich: merge-quarterly+


Attachments
Patch (1.23 KB, patch)
2022-01-02 18:11 UTC, Kevin Zheng
kevinz5000: maintainer-approval+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kevin Zheng 2022-01-02 18:11:11 UTC
Created attachment 230630 [details]
Patch

Due to a recent package update, a header somewhere leaks
HAVE_SYS_INOTIFY_H. This causes a build error with a missing 'fd'
variable because the header file conditionally defines 'fd' depending on
whether or not HAVE_SYS_INOTIFY_H is defined.
    
Hack around this for now by explicitly #undef'ing HAVE_SYS_INOTIFY_H in
the problem file.
Comment 1 Fernando Apesteguía freebsd_committer freebsd_triage 2022-01-03 08:12:21 UTC
^Triage: Please set the maintainer-approval attachment flag (to +) on patches for ports you maintain to signify approval.
--
Attachment -> Details -> maintainer-approval [+]
Comment 2 commit-hook freebsd_committer freebsd_triage 2022-01-03 21:45:00 UTC
A commit in branch main references this bug:

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

commit deb3482f019ce860b2998f0f55475900edd35b9e
Author:     Jan Beich <jbeich@FreeBSD.org>
AuthorDate: 2022-01-03 19:51:54 +0000
Commit:     Jan Beich <jbeich@FreeBSD.org>
CommitDate: 2022-01-03 21:43:31 +0000

    games/openclonk: unbreak build after 9cb3316ecd20

    sdl2 has a namespace pollution where <SDL.h> defines unprefixed HAVE_*
    macros often used by autotools, CMake, Meson. As sdl2 now depends on
    libinotify for joystick support HAVE_SYS_INOTIFY_H confuses openclonk
    which itself fails to detect <sys/inotify.h>. Due to inconsistent macro
    visibility and missing -linotify the build breaks. So, force-disable
    inotify code as it seems to be only used by editor (e.g., reload scenarios
    on changes) which since openclonk 8.0 requires Qt5.

    $ rg HAVE_SYS_INOTIFY_H /usr/local/include
    /usr/local/include/SDL2/SDL_config.h
    223:#define HAVE_SYS_INOTIFY_H 1

    $ make
    [...]
    -- Looking for C++ include sys/inotify.h
    -- Looking for C++ include sys/inotify.h - not found
    [...]
    src/platform/C4FileMonitor.cpp:29:2: error: use of undeclared identifier 'fd'
            fd = inotify_init1(IN_CLOEXEC);
            ^
    src/platform/C4FileMonitor.cpp:30:6: error: use of undeclared identifier 'fd'
            if (fd == -1) fd = inotify_init();
                ^
    src/platform/C4FileMonitor.cpp:30:16: error: use of undeclared identifier 'fd'
            if (fd == -1) fd = inotify_init();
                          ^
    src/platform/C4FileMonitor.cpp:31:6: error: use of undeclared identifier 'fd'
            if (fd == -1) LogF("inotify_init %s", strerror(errno));
                ^
    src/platform/C4FileMonitor.cpp:42:15: error: use of undeclared identifier 'fd'
            while (close(fd) == -1 && errno == EINTR) { }
                         ^
    src/platform/C4FileMonitor.cpp:57:29: error: use of undeclared identifier 'fd'
            int wd = inotify_add_watch(fd, file, IN_CREATE | IN_MODIFY | IN_MOVED_TO | IN_MOVE_SELF | IN_ONLYDIR);
                                       ^
    src/platform/C4FileMonitor.cpp:60:2: error: use of undeclared identifier 'watch_descriptors'
            watch_descriptors[wd] = file;
            ^
    src/platform/C4FileMonitor.cpp:65:59: error: use of undeclared identifier 'fd'
            if ((pfd->revents & pfd->events) != POLLIN || pfd->fd != fd)
                                                                     ^
    src/platform/C4FileMonitor.cpp:66:69: error: use of undeclared identifier 'fd'
              LogF("C4FileMonitor::Execute unexpectedly called %d %d %hd %hd", fd, pfd->fd, pfd->events, pfd->revents);
                                                                               ^
    src/platform/C4FileMonitor.cpp:69:11: error: use of undeclared identifier 'fd'
            if (read(fd, buf, sizeof(buf)) > 0)
                     ^
    src/platform/C4FileMonitor.cpp:71:23: error: use of undeclared identifier 'watch_descriptors'
                    const char * file = watch_descriptors[event->wd];
                                        ^
    src/platform/C4FileMonitor.cpp:99:17: error: use of undeclared identifier 'fd'
            pollfd pfd = { fd, POLLIN, 0 };
                           ^

    PR:             260885
    Reported by:    pkg-fallout
    Submitted by:   Kevin Zheng (maintainer, different commit message)

 .../files/patch-src_platform_C4FileMonitor.cpp (new)          | 11 +++++++++++
 1 file changed, 11 insertions(+)
Comment 3 commit-hook freebsd_committer freebsd_triage 2022-01-03 21:45:01 UTC
A commit in branch 2022Q1 references this bug:

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

commit d00fbf8fc3ef3f4dd37a7c58cc1d0b8fba62882d
Author:     Jan Beich <jbeich@FreeBSD.org>
AuthorDate: 2022-01-03 19:51:54 +0000
Commit:     Jan Beich <jbeich@FreeBSD.org>
CommitDate: 2022-01-03 21:44:09 +0000

    games/openclonk: unbreak build after 9cb3316ecd20

    sdl2 has a namespace pollution where <SDL.h> defines unprefixed HAVE_*
    macros often used by autotools, CMake, Meson. As sdl2 now depends on
    libinotify for joystick support HAVE_SYS_INOTIFY_H confuses openclonk
    which itself fails to detect <sys/inotify.h>. Due to inconsistent macro
    visibility and missing -linotify the build breaks. So, force-disable
    inotify code as it seems to be only used by editor (e.g., reload scenarios
    on changes) which since openclonk 8.0 requires Qt5.

    $ rg HAVE_SYS_INOTIFY_H /usr/local/include
    /usr/local/include/SDL2/SDL_config.h
    223:#define HAVE_SYS_INOTIFY_H 1

    $ make
    [...]
    -- Looking for C++ include sys/inotify.h
    -- Looking for C++ include sys/inotify.h - not found
    [...]
    src/platform/C4FileMonitor.cpp:29:2: error: use of undeclared identifier 'fd'
            fd = inotify_init1(IN_CLOEXEC);
            ^
    src/platform/C4FileMonitor.cpp:30:6: error: use of undeclared identifier 'fd'
            if (fd == -1) fd = inotify_init();
                ^
    src/platform/C4FileMonitor.cpp:30:16: error: use of undeclared identifier 'fd'
            if (fd == -1) fd = inotify_init();
                          ^
    src/platform/C4FileMonitor.cpp:31:6: error: use of undeclared identifier 'fd'
            if (fd == -1) LogF("inotify_init %s", strerror(errno));
                ^
    src/platform/C4FileMonitor.cpp:42:15: error: use of undeclared identifier 'fd'
            while (close(fd) == -1 && errno == EINTR) { }
                         ^
    src/platform/C4FileMonitor.cpp:57:29: error: use of undeclared identifier 'fd'
            int wd = inotify_add_watch(fd, file, IN_CREATE | IN_MODIFY | IN_MOVED_TO | IN_MOVE_SELF | IN_ONLYDIR);
                                       ^
    src/platform/C4FileMonitor.cpp:60:2: error: use of undeclared identifier 'watch_descriptors'
            watch_descriptors[wd] = file;
            ^
    src/platform/C4FileMonitor.cpp:65:59: error: use of undeclared identifier 'fd'
            if ((pfd->revents & pfd->events) != POLLIN || pfd->fd != fd)
                                                                     ^
    src/platform/C4FileMonitor.cpp:66:69: error: use of undeclared identifier 'fd'
              LogF("C4FileMonitor::Execute unexpectedly called %d %d %hd %hd", fd, pfd->fd, pfd->events, pfd->revents);
                                                                               ^
    src/platform/C4FileMonitor.cpp:69:11: error: use of undeclared identifier 'fd'
            if (read(fd, buf, sizeof(buf)) > 0)
                     ^
    src/platform/C4FileMonitor.cpp:71:23: error: use of undeclared identifier 'watch_descriptors'
                    const char * file = watch_descriptors[event->wd];
                                        ^
    src/platform/C4FileMonitor.cpp:99:17: error: use of undeclared identifier 'fd'
            pollfd pfd = { fd, POLLIN, 0 };
                           ^

    PR:             260885
    Reported by:    pkg-fallout
    Submitted by:   Kevin Zheng (maintainer, different commit message)

    (cherry picked from commit deb3482f019ce860b2998f0f55475900edd35b9e)

 .../files/patch-src_platform_C4FileMonitor.cpp (new)          | 11 +++++++++++
 1 file changed, 11 insertions(+)
Comment 4 Jan Beich freebsd_committer freebsd_triage 2022-01-03 21:48:32 UTC
Thanks. Sorry, I didn't noticed Assignee.

I've tried to enable inotify but "openclonk --editor" doesn't really work. According to https://github.com/openclonk/openclonk/issues/63#issuecomment-363034576 the non-Qt version of the editor is cruft.