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 +26 −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. hebasto added the label Build system on Dec 14, 2024
  3. 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.

    Type Reviewers
    ACK fanquake

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

  4. fanquake commented at 10:55 am on December 17, 2024: member
    Can you link to the upstream issue / PR.
  5. 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.

  6. 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.

  7. depends: Fix compiling `libevent` package on NetBSD f89f16846e
  8. hebasto force-pushed on Feb 3, 2025
  9. hebasto commented at 9:22 am on February 3, 2025: 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: libevent/libevent#1768.

    The upstream changes have been merged. So this branch was rebased, and the upstream commit was mentioned.

  10. fanquake approved
  11. fanquake commented at 3:36 pm on February 12, 2025: member
    ACK f89f16846ec02942e7b81d24a85e3f40941e5426
  12. fanquake merged this on Feb 12, 2025
  13. fanquake closed this on Feb 12, 2025

  14. hebasto deleted the branch on Feb 12, 2025
  15. hebasto referenced this in commit 0829709c97 on Feb 12, 2025

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: 2025-02-22 06:12 UTC

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