mikebrady / shairport-sync

AirPlay and AirPlay 2 audio player
Other
7.02k stars 567 forks source link

[Problem]: Build fails on earlier macOS due to wrong header sequence and missing TCP_KEEPCNT / TCP_KEEPINTVL #1860

Open barracuda156 opened 4 weeks ago

barracuda156 commented 4 weeks ago

What happened?

Build fails on macOS < 10.9. One problem is a wrong include order: trivially fixable, and in fact already fixed earlier in https://github.com/mikebrady/shairport-sync/commit/8a6eb02d59f56b0f03f7dcf3626d96789c1f0671 but then broken again. Another is missing TCP_KEEPCNT / TCP_KEEPINTVL on macOS < 10.9.

Relevant log output

In file included from shairport.c:34:
/usr/include/net/if.h:264: error: field ‘ifru_addr’ has incomplete type
/usr/include/net/if.h:265: error: field ‘ifru_dstaddr’ has incomplete type
/usr/include/net/if.h:266: error: field ‘ifru_broadaddr’ has incomplete type
/usr/include/net/if.h:305: error: field ‘ifra_addr’ has incomplete type
/usr/include/net/if.h:306: error: field ‘ifra_broadaddr’ has incomplete type
/usr/include/net/if.h:307: error: field ‘ifra_mask’ has incomplete type
/usr/include/net/if.h:379: error: field ‘addr’ has incomplete type
/usr/include/net/if.h:380: error: field ‘dstaddr’ has incomplete type

rtsp.c: In function ‘rtsp_listen_loop’:
rtsp.c:5672: error: ‘TCP_KEEPCNT’ undeclared (first use in this function)
rtsp.c:5672: error: (Each undeclared identifier is reported only once
rtsp.c:5672: error: for each function it appears in.)
rtsp.c:5676: error: ‘TCP_KEEPINTVL’ undeclared (first use in this function)
make[1]: *** [rtsp.o] Error 1

System Information.

macOS 10.6 (locally) macOS 10.8 (buildbot): https://build.macports.org/builders/ports-10.8_x86_64-builder/builds/180717/steps/install-port/logs/stdio

Configuration Information.

36-174% uname -a
Darwin 36-174.wireless-city.scu.edu.tw 10.0.0d2 Darwin Kernel Version 10.0.0d2: Fri Oct 10 19:37:52 PDT 2008; root:xnu-1346.7~1/RELEASE_PPC Power Macintosh

See also: https://trac.macports.org/ticket/70148



### PulseAudio or PipeWire installed?

- [ ] Check if your system uses a Sound Server.

### How did you install Shairport Sync?

Built from source

### Check previous issues

- [X] Confirm
mikebrady commented 4 weeks ago

Thanks for the report. TBH it wouldn't have the highest priority at the present time...

mikebrady commented 4 weeks ago

Do you happen to know of any substitutes for TCP_KEEPCNT / TCP_KEEPINTVL in macOS < 10.9?

barracuda156 commented 4 weeks ago

@mikebrady Thank you for responding!

Apparently on 10.7 and earlier there is TCP_KEEPALIVE: https://lists.apple.com/archives/macnetworkprog/2012/Jul/msg00005.html

Curl had a patch back then: https://github.com/Khalian/kcurl/commit/29fdb2700f7979e71b8828c18e0e157a44b6db53

mikebrady commented 4 weeks ago

@barracuda156 Thanks! I'll take a look.

mikebrady commented 2 weeks ago

@barracuda156, are you using using HomeBrew on 10.8?

barracuda156 commented 2 weeks ago

@mikebrady I use MacPorts (and would like to fix the port after the recent update). Homebrew is broken for everything but recent systems.

mikebrady commented 2 weeks ago

So, an update in the development branch has just been pushed that addresses the two issues you raised. (Additionally a bug in the initialisation of the metadata system was uncovered, so thanks! 😊)

Just a note of caution about AirPlay 2 operation:

  1. For AirPlay 2 operation, NQPTP is needed. It uses ports 319 and 320, which are used on more recent macOS versions and may be in use on older Mac OS X versions.
  2. Shairport Sync almost certainly will not run in AirPlay 2 mode on a big-endian system. This is not likely to be fixed, I'm afraid, as at least one of the problems is in a library.
barracuda156 commented 2 weeks ago

Thank you!

I ran the build now. I think fixing headers was somehow lost in committing? It is mentioned, but not done:

In file included from shairport.c:34:
/usr/include/net/if.h:264: error: field ‘ifru_addr’ has incomplete type
/usr/include/net/if.h:265: error: field ‘ifru_dstaddr’ has incomplete type
/usr/include/net/if.h:266: error: field ‘ifru_broadaddr’ has incomplete type
/usr/include/net/if.h:305: error: field ‘ifra_addr’ has incomplete type
/usr/include/net/if.h:306: error: field ‘ifra_broadaddr’ has incomplete type
/usr/include/net/if.h:307: error: field ‘ifra_mask’ has incomplete type
/usr/include/net/if.h:379: error: field ‘addr’ has incomplete type
/usr/include/net/if.h:380: error: field ‘dstaddr’ has incomplete type
depbase=`echo alac.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
    /usr/bin/gcc-4.2 -std=gnu99 -DHAVE_CONFIG_H -I.   -I/opt/local/include -Wno-multichar -Wall -Wextra -Wno-deprecated-declarations -pthread -DSYSCONFDIR=\"/opt/local/etc/shairport-sync\" -DPIDDIR=\"/opt/local/var\" -I/opt/local/libexec/openssl3/include   -pipe -Os -arch ppc -MT alac.o -MD -MP -MF $depbase.Tpo -c -o alac.o alac.c &&\
    mv -f $depbase.Tpo $depbase.Po
make[1]: *** [shairport.o] Error 1

Specifically, we need #include <sys/socket.h> to come before #include <net/if.h>. With that fixed, next error is:

    /usr/bin/gcc-4.2 -std=gnu99 -DHAVE_CONFIG_H -I.   -I/opt/local/include -Wno-multichar -Wall -Wextra -Wno-deprecated-declarations -pthread -DSYSCONFDIR=\"/opt/local/etc/shairport-sync\" -DPIDDIR=\"/opt/local/var\" -I/opt/local/libexec/openssl3/include   -pipe -Os -arch ppc -MT mdns_dns_sd.o -MD -MP -MF $depbase.Tpo -c -o mdns_dns_sd.o mdns_dns_sd.c &&\
    mv -f $depbase.Tpo $depbase.Po
/usr/bin/g++-4.2 -I/usr/local/include -Wno-multichar -Wall -Wextra -Wno-deprecated-declarations -pthread -DSYSCONFDIR=\"/opt/local/etc/shairport-sync\"  -pipe -Os -arch ppc  -L/opt/local/lib -Wl,-headerpad_max_install_names -arch ppc -o shairport-sync shairport.o rtsp.o mdns.o common.o rtp.o player.o alac.o audio.o loudness.o activity_monitor.o          audio_stdout.o audio_pipe.o  audio_ao.o     mdns_dns_sd.o           -L/opt/local/lib -lao -L/opt/local/lib -lsoxr -L/opt/local/libexec/openssl3/lib -lssl -lcrypto -L/opt/local/lib -lconfig -L/opt/local/lib -lpopt -lm -lpthread 
Undefined symbols:
  "_dprintf", referenced from:
      _do_sps_log_to_fd in common.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make[1]: *** [shairport-sync] Error 1

However for this we can rely on MacPorts's legacy-support library, and once it is added, shairport-sync compiles successfully.

We should not use --with-airplay-2 with Big-endian archs, right?

mikebrady commented 2 weeks ago

Apologies -- I don't know how that happened. I'll fix it shortly.

So, yeah, best to omit the --with-airplay-2 with big-endian architectures. I don't expect it will ever work, sadly.

barracuda156 commented 2 weeks ago

@mikebrady Got it, thank you.

Could you make a tag which incorporates the fixes? If it’s not troublesome. (But we can survive with patches until the next release either.)

mikebrady commented 2 weeks ago

Just pushed it there now. Regarding that:

Undefined symbols:
  "_dprintf", referenced from:
      _do_sps_log_to_fd in common.o
...

I didn't get that error. I was working on Mac OS X 10.8.5 (Mountain Lion) and Xcode 5.1.1. It was as far back as I could easily go, TBH...

If it's okay with you, let me wait a few days and then, all going well, just I'll push the development branch into a new master release. Would that be okay?

barracuda156 commented 2 weeks ago

I didn't get that error.

This is perhaps relevant for < 10.7. But no worries, legacy-support has got us covered here, there is no need to do anything about that.

If it's okay with you, let me wait a few days and then, all going well, just I'll push the development branch into a new master release. Would that be okay?

Yeah, sure. Thank you!