depends: Fix compiling libevent package on NetBSD #31500

pull hebasto wants to merge 1 commits into bitcoin:master from hebasto:241214-libevent-netbsd changing 2 files +23 −1
  1. hebasto commented at 3:41 pm on December 14, 2024: member

    Libevent introduced the typeof C language extension in the NetBSD-specific code, which was pulled into our depends in #21991.

    However, GCC states:

    the various -std options disable certain keywords.

    Due to our use of https://github.com/bitcoin/bitcoin/blob/b042c4f0538c6f9cdf8efbcef552796851e38a85/depends/hosts/netbsd.mk#L1

    the typeof keyword is disabled, resulting in a compilation error:

     0$ gmake -C depends libevent CC=/usr/pkg/gcc14/bin/gcc CXX=/usr/pkg/gcc14/bin/g++
     1<snip>
     2[ 37%] Building C object CMakeFiles/event_core_static.dir/kqueue.c.o
     3/home/hebasto/dev/bitcoin/depends/work/build/x86_64-unknown-netbsd10.0/libevent/2.1.12-stable-ca6b96ec97c/kqueue.c: In function 'kq_setup_kevent':
     4/home/hebasto/dev/bitcoin/depends/work/build/x86_64-unknown-netbsd10.0/libevent/2.1.12-stable-ca6b96ec97c/kqueue.c:56:27: error: implicit declaration of function 'typeof' [-Wimplicit-function-declaration]
     5   56 | #define INT_TO_UDATA(x) ((typeof(((struct kevent *)0)->udata))(intptr_t)(x))
     6      |                           ^~~~~~
     7/home/hebasto/dev/bitcoin/depends/work/build/x86_64-unknown-netbsd10.0/libevent/2.1.12-stable-ca6b96ec97c/kqueue.c:190:30: note: in expansion of macro 'INT_TO_UDATA'
     8  190 |                 out->udata = INT_TO_UDATA(ADD_UDATA);
     9      |                              ^~~~~~~~~~~~
    10/home/hebasto/dev/bitcoin/depends/work/build/x86_64-unknown-netbsd10.0/libevent/2.1.12-stable-ca6b96ec97c/kqueue.c:56:64: error: expected expression before 'intptr_t'
    11   56 | #define INT_TO_UDATA(x) ((typeof(((struct kevent *)0)->udata))(intptr_t)(x))
    12      |                                                                ^~~~~~~~
    13/home/hebasto/dev/bitcoin/depends/work/build/x86_64-unknown-netbsd10.0/libevent/2.1.12-stable-ca6b96ec97c/kqueue.c:190:30: note: in expansion of macro 'INT_TO_UDATA'
    14  190 |                 out->udata = INT_TO_UDATA(ADD_UDATA);
    15      |                              ^~~~~~~~~~~~
    16/home/hebasto/dev/bitcoin/depends/work/build/x86_64-unknown-netbsd10.0/libevent/2.1.12-stable-ca6b96ec97c/kqueue.c:56:27: error: called object is not a function or function pointer
    17   56 | #define INT_TO_UDATA(x) ((typeof(((struct kevent *)0)->udata))(intptr_t)(x))
    18      |                          ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    19/home/hebasto/dev/bitcoin/depends/work/build/x86_64-unknown-netbsd10.0/libevent/2.1.12-stable-ca6b96ec97c/kqueue.c:190:30: note: in expansion of macro 'INT_TO_UDATA'
    20  190 |                 out->udata = INT_TO_UDATA(ADD_UDATA);
    21      |                              ^~~~~~~~~~~~
    22gmake[3]: *** [CMakeFiles/event_core_static.dir/build.make:328: CMakeFiles/event_core_static.dir/kqueue.c.o] Error 1
    23<snip>
    

    This PR resolves this issue by following GCC’s recommendation:

    write __typeof__ instead of typeof.

  2. depends: Fix compiling `libevent` package on NetBSD 53ae319eee
  3. hebasto added the label Build system on Dec 14, 2024
  4. DrahtBot commented at 3:41 pm on December 14, 2024: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/31500.

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

  5. fanquake commented at 10:55 am on December 17, 2024: member
    Can you link to the upstream issue / PR.
  6. theuni commented at 5:08 pm on December 19, 2024: member

    LGTM, but yeah, it’d be helpful to upstream this.

    FWIW c23 adds typeof(), so technically guards for that could be added. Not worth the complexity though.

  7. hebasto commented at 4:08 pm on December 20, 2024: member

    Can you link to the upstream issue / PR.

    LGTM, but yeah, it’d be helpful to upstream this.

    Sure thing!

    Here is an upstream PR: https://github.com/libevent/libevent/pull/1768.


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-21 12:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me