[vlc-commits] contrib: gnutls: fix 3.6 compilation with an older macOS SDK

Steve Lhomme git at videolan.org
Fri Jun 26 12:35:03 CEST 2020


vlc/vlc-3.0 | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Mon Jun 15 15:31:59 2020 +0200| [46ca0178a25bd392e057193975612200b1c871b7] | committer: Steve Lhomme

contrib: gnutls: fix 3.6 compilation with an older macOS SDK

Fixes this compilation error:
system/fastopen.c:134:9: error: 'connectx' is only available on macOS 10.11 or newer [-Werror,-Wunguarded-availability]
                ret = connectx(fd, &endpoints, SAE_ASSOCID_ANY, CONNECT_RESUME_ON_READ_WRITE | CONNECT_DATA_IDEMPOTENT, NULL, 0, NULL, NULL);
                      ^~~~~~~~
/Applications/Xcode9.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/sys/socket.h:713:5:
note: 'connectx' has been marked as being introduced in macOS 10.11 here, but the deployment target is macOS 10.7.0

In this patch __builtin_available() is assumed to be avalaible in the toolchain
which is the case in our 3.0 and 4.0 toolchains. A cleaner patch should detect
it in configure.ac. But we can't do autoconf changes in gnutls as it never
works properly.

The OS values match exactly the values found in
https://opensource.apple.com/source/xnu/xnu-4570.41.2/bsd/sys/socket.h

(cherry picked from commit c4a23f4cd0e5370d1b5f6f8a6a9302b35c3a8ea4)

Signed-off-by: Steve Lhomme <robux4 at ycbcr.xyz>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=46ca0178a25bd392e057193975612200b1c871b7
---

 ...connectx-not-available-on-older-macOS-SDK.patch | 46 ++++++++++++++++++++++
 contrib/src/gnutls/rules.mak                       |  3 ++
 2 files changed, 49 insertions(+)

diff --git a/contrib/src/gnutls/0001-fix-connectx-not-available-on-older-macOS-SDK.patch b/contrib/src/gnutls/0001-fix-connectx-not-available-on-older-macOS-SDK.patch
new file mode 100644
index 0000000000..300437a232
--- /dev/null
+++ b/contrib/src/gnutls/0001-fix-connectx-not-available-on-older-macOS-SDK.patch
@@ -0,0 +1,46 @@
+From 3faffe77fd5cb15cb132ebaf4bfef6dc579f25e2 Mon Sep 17 00:00:00 2001
+From: Steve Lhomme <robux4 at ycbcr.xyz>
+Date: Fri, 19 Jun 2020 15:11:00 +0200
+Subject: [PATCH] fix connectx not available on older macOS SDK
+
+Fixes this compilation error:
+system/fastopen.c:134:9: error: 'connectx' is only available on macOS 10.11 or newer [-Werror,-Wunguarded-availability]
+                ret = connectx(fd, &endpoints, SAE_ASSOCID_ANY, CONNECT_RESUME_ON_READ_WRITE | CONNECT_DATA_IDEMPOTENT, NULL, 0, NULL, NULL);
+                      ^~~~~~~~
+/Applications/Xcode9.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/sys/socket.h:713:5: note: 'connectx' has been marked as being introduced in macOS 10.11 here, but the deployment target is macOS 10.7.0
+
+The detection is the same as found in curl [1].
+
+If HAVE_BUILTIN_AVAILABLE is not available we fallback to the code without
+TCP_FASTOPEN_OSX.
+
+[1] https://github.com/curl/curl/commit/870d849d48a26b8eeb0d4bb1f4655367a4a191ca
+---
+ lib/system/fastopen.c | 10 ++++++++--
+ 1 file changed, 8 insertions(+), 2 deletions(-)
+
+diff --git a/lib/system/fastopen.c b/lib/system/fastopen.c
+index 8d8409e48..b816decff 100644
+--- a/lib/system/fastopen.c
++++ b/lib/system/fastopen.c
+@@ -129,9 +129,15 @@ tfo_writev(gnutls_transport_ptr_t ptr, const giovec_t * iovec, int iovec_cnt)
+ 	}
+ # elif defined(TCP_FASTOPEN_OSX)
+ 	{
+-		sa_endpoints_t endpoints = { .sae_dstaddr = (struct sockaddr*)&p->connect_addr, .sae_dstaddrlen = p->connect_addrlen };
++		if(__builtin_available(macOS 10.11, iOS 9.0, tvOS 9.0, watchOS 2.0, *)) {
++			sa_endpoints_t endpoints = { .sae_dstaddr = (struct sockaddr*)&p->connect_addr, .sae_dstaddrlen = p->connect_addrlen };
+ 
+-		ret = connectx(fd, &endpoints, SAE_ASSOCID_ANY, CONNECT_RESUME_ON_READ_WRITE | CONNECT_DATA_IDEMPOTENT, NULL, 0, NULL, NULL);
++			ret = connectx(fd, &endpoints, SAE_ASSOCID_ANY, CONNECT_RESUME_ON_READ_WRITE | CONNECT_DATA_IDEMPOTENT, NULL, 0, NULL, NULL);
++		}
++		else
++		{
++			ret = connect(fd, (struct sockaddr*)&p->connect_addr, p->connect_addrlen);
++		}
+ 		if (errno == ENOTCONN || errno == EINPROGRESS) {
+ 			gnutls_assert();
+ 			errno = EAGAIN;
+-- 
+2.26.0.windows.1
+
diff --git a/contrib/src/gnutls/rules.mak b/contrib/src/gnutls/rules.mak
index 5f35140ea4..d22e63a168 100644
--- a/contrib/src/gnutls/rules.mak
+++ b/contrib/src/gnutls/rules.mak
@@ -33,6 +33,9 @@ gnutls: gnutls-$(GNUTLS_VERSION).tar.xz .sum-gnutls
 
 	# disable the dllimport in static linking (pkg-config --static doesn't handle Cflags.private)
 	cd $(UNPACK_DIR) && sed -i.orig -e s/"_SYM_EXPORT __declspec(dllimport)"/"_SYM_EXPORT"/g lib/includes/gnutls/gnutls.h.in
+
+	# don't use connectx on macOS versions where it's not available
+	$(APPLY) $(SRC)/gnutls/0001-fix-connectx-not-available-on-older-macOS-SDK.patch
 ifdef HAVE_ANDROID
 	$(APPLY) $(SRC)/gnutls/no-create-time-h.patch
 endif



More information about the vlc-commits mailing list