sctplab/usrsctp

Broken build on macOS 13.4 (apple sillicon)

francisbonneau opened this issue · 1 comments

Hello! First off thank you for this library!

I'm trying to use it in Rust via datachannel-rs, which is based on libdatachannel which is using this library.

I noticed it doesn't build anymore on my apple m1 laptop, which is running macOS 13.4 - so I created this issue on datachannel-rs.

After some troubleshooting it seems that the build is failing because of warnings/errors in usrsctp:

make -j2
[  0%] Building C object deps/libjuice/CMakeFiles/juice-static.dir/src/addr.c.o
[  0%] Building C object deps/usrsctp/usrsctplib/CMakeFiles/usrsctp.dir/netinet/sctp_asconf.c.o
[  0%] Building C object deps/libjuice/CMakeFiles/juice-static.dir/src/agent.c.o
/Users/user/work/libdatachannel/deps/libjuice/src/agent.c:118:26: warning: macro 'ATOMIC_VAR_INIT' has been marked as deprecated [-Wdeprecated-pragma]
        agent->selected_entry = ATOMIC_VAR_INIT(NULL);
                                ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.3/include/stdatomic.h:51:41: note: macro marked 'deprecated' here
#pragma clang deprecated(ATOMIC_VAR_INIT)
                                        ^
[  1%] Building C object deps/usrsctp/usrsctplib/CMakeFiles/usrsctp.dir/netinet/sctp_auth.c.o
1 warning generated.
[  3%] Building C object deps/libjuice/CMakeFiles/juice-static.dir/src/crc32.c.o
[  3%] Building C object deps/usrsctp/usrsctplib/CMakeFiles/usrsctp.dir/netinet/sctp_bsd_addr.c.o
[  3%] Building C object deps/libjuice/CMakeFiles/juice-static.dir/src/const_time.c.o
[  5%] Building C object deps/usrsctp/usrsctplib/CMakeFiles/usrsctp.dir/netinet/sctp_callout.c.o
[  7%] Building C object deps/libjuice/CMakeFiles/juice-static.dir/src/conn.c.o
[  7%] Building C object deps/libjuice/CMakeFiles/juice-static.dir/src/conn_poll.c.o
[  7%] Building C object deps/usrsctp/usrsctplib/CMakeFiles/usrsctp.dir/netinet/sctp_cc_functions.c.o
[  7%] Building C object deps/libjuice/CMakeFiles/juice-static.dir/src/conn_thread.c.o
[  8%] Building C object deps/libjuice/CMakeFiles/juice-static.dir/src/conn_mux.c.o
[  8%] Building C object deps/usrsctp/usrsctplib/CMakeFiles/usrsctp.dir/netinet/sctp_crc32.c.o
[ 10%] Building C object deps/usrsctp/usrsctplib/CMakeFiles/usrsctp.dir/netinet/sctp_indata.c.o
[ 10%] Building C object deps/libjuice/CMakeFiles/juice-static.dir/src/base64.c.o
[ 10%] Building C object deps/libjuice/CMakeFiles/juice-static.dir/src/hash.c.o
/Users/user/work/libdatachannel/deps/usrsctp/usrsctplib/netinet/sctp_indata.c:3323:6: error: variable 'tot_retrans' set but not used [-Werror,-Wunused-but-set-variable]
        int tot_retrans = 0;
            ^
1 error generated.
make[2]: *** [deps/usrsctp/usrsctplib/CMakeFiles/usrsctp.dir/netinet/sctp_indata.c.o] Error 1
make[1]: *** [deps/usrsctp/usrsctplib/CMakeFiles/usrsctp.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 12%] Building C object deps/libjuice/CMakeFiles/juice-static.dir/src/hmac.c.o
[ 12%] Building C object deps/libjuice/CMakeFiles/juice-static.dir/src/ice.c.o
[ 12%] Building C object deps/libjuice/CMakeFiles/juice-static.dir/src/juice.c.o
[ 14%] Building C object deps/libjuice/CMakeFiles/juice-static.dir/src/log.c.o
[ 14%] Building C object deps/libjuice/CMakeFiles/juice-static.dir/src/random.c.o
/Users/user/work/libdatachannel/deps/libjuice/src/log.c:36:46: warning: macro 'ATOMIC_VAR_INIT' has been marked as deprecated [-Wdeprecated-pragma]
static atomic(juice_log_level_t) log_level = ATOMIC_VAR_INIT(JUICE_LOG_LEVEL_WARN);
                                             ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.3/include/stdatomic.h:51:41: note: macro marked 'deprecated' here
#pragma clang deprecated(ATOMIC_VAR_INIT)
                                        ^
1 warning generated.
[ 14%] Building C object deps/libjuice/CMakeFiles/juice-static.dir/src/server.c.o
[ 16%] Building C object deps/libjuice/CMakeFiles/juice-static.dir/src/stun.c.o
[ 16%] Building C object deps/libjuice/CMakeFiles/juice-static.dir/src/timestamp.c.o
[ 16%] Building C object deps/libjuice/CMakeFiles/juice-static.dir/src/turn.c.o
[ 17%] Building C object deps/libjuice/CMakeFiles/juice-static.dir/src/udp.c.o
[ 17%] Linking C static library libjuice-static.a
[ 17%] Built target juice-static
make: *** [all] Error 2

I'm a novice in C, but I removed the unused tot_retrans variable and made a few other changes it now it compiles just fine!

Here are the changes (sorry I didn't have time to create a PR)

diff --git a/usrsctplib/netinet/sctp_indata.c b/usrsctplib/netinet/sctp_indata.c
index 64e4d0b..081e9ac 100755
--- a/usrsctplib/netinet/sctp_indata.c
+++ b/usrsctplib/netinet/sctp_indata.c
@@ -3320,7 +3320,6 @@ sctp_strike_gap_ack_chunks(struct sctp_tcb *stcb, struct sctp_association *asoc,
        struct sctp_tmit_chunk *tp1;
        int strike_flag = 0;
        struct timeval now;
-       int tot_retrans = 0;
        uint32_t sending_seq;
        struct sctp_nets *net;
        int num_dests_sacked = 0;
@@ -3691,7 +3690,6 @@ sctp_strike_gap_ack_chunks(struct sctp_tcb *stcb, struct sctp_association *asoc,
                        }

                        tp1->rec.data.doing_fast_retransmit = 1;
-                       tot_retrans++;
                        /* mark the sending seq for possible subsequent FR's */
                        /*
                         * SCTP_PRINTF("Marking TSN for FR new value %x\n",
diff --git a/usrsctplib/netinet/sctp_output.c b/usrsctplib/netinet/sctp_output.c
index c4942ef..70af1f6 100755
--- a/usrsctplib/netinet/sctp_output.c
+++ b/usrsctplib/netinet/sctp_output.c
@@ -10015,7 +10015,7 @@ sctp_chunk_retransmission(struct sctp_inpcb *inp,
        struct mbuf *m, *endofchain;
        struct sctp_nets *net = NULL;
        uint32_t tsns_sent = 0;
-       int no_fragmentflg, bundle_at, cnt_thru;
+       int no_fragmentflg, bundle_at;
        unsigned int mtu;
        int error, i, one_chunk, fwd_tsn, ctl_cnt, tmr_started;
        struct sctp_auth_chunk *auth = NULL;
@@ -10091,7 +10091,6 @@ sctp_chunk_retransmission(struct sctp_inpcb *inp,
                }
        }
        one_chunk = 0;
-       cnt_thru = 0;
        /* do we have control chunks to retransmit? */
        if (m != NULL) {
                /* Start a timer no matter if we succeed or fail */
@@ -10413,7 +10412,6 @@ sctp_chunk_retransmission(struct sctp_inpcb *inp,
                        /* (void)SCTP_GETTIME_TIMEVAL(&net->last_sent_time); */

                        /* For auto-close */
-                       cnt_thru++;
                        if (*now_filled == 0) {
                                (void)SCTP_GETTIME_TIMEVAL(&asoc->time_last_sent);
                                *now = asoc->time_last_sent;
diff --git a/usrsctplib/netinet/sctp_pcb.c b/usrsctplib/netinet/sctp_pcb.c
index 663d10d..89ab125 100755
--- a/usrsctplib/netinet/sctp_pcb.c
+++ b/usrsctplib/netinet/sctp_pcb.c
@@ -7936,7 +7936,7 @@ sctp_drain_mbufs(struct sctp_tcb *stcb)
 }

 void
-sctp_drain()
+sctp_drain(void)
 {
        /*
         * We must walk the PCB lists for ALL associations here. The system
diff --git a/usrsctplib/netinet/sctp_sysctl.c b/usrsctplib/netinet/sctp_sysctl.c
index bb49e17..8b77f7e 100755
--- a/usrsctplib/netinet/sctp_sysctl.c
+++ b/usrsctplib/netinet/sctp_sysctl.c
@@ -61,7 +61,7 @@ FEATURE(sctp, "Stream Control Transmission Protocol");
  */

 void
-sctp_init_sysctls()
+sctp_init_sysctls(void)
 {
        SCTP_BASE_SYSCTL(sctp_sendspace) = SCTPCTL_MAXDGRAM_DEFAULT;
        SCTP_BASE_SYSCTL(sctp_recvspace) = SCTPCTL_RECVSPACE_DEFAULT;

After updating the libdatachannel submodules to the latest version of usrsctp I realized that this was fixed in the master branch by the commit e19d122c.

For more context -> lerouxrgd/datachannel-rs#35 (comment)

Thanks!