[gnutls-devel] GnuTLS | Build failure on macOS Catalina 10.15.4 under Xcode 11.4. (#966)

Development of GNU's TLS library gnutls-devel at lists.gnutls.org
Sat May 16 05:11:48 CEST 2020




Siguza commented:


Running into the same issue. macOS 10.15.3, Xcode 11.4.1.  
It seems the Mono project ran into this as well not long ago: https://github.com/mono/mono/issues/19393

The issue traces back to this declaration in `$SDK/usr/include/sys/_types/_fd_def.h`:

```c
int __darwin_check_fd_set_overflow(int, const void *, int) __attribute__((__weak_import__));
```

And to provide some more context, from the same file:

```c
__BEGIN_DECLS
typedef struct fd_set {
	__int32_t       fds_bits[__DARWIN_howmany(__DARWIN_FD_SETSIZE, __DARWIN_NFDBITS)];
} fd_set;

int __darwin_check_fd_set_overflow(int, const void *, int) __attribute__((__weak_import__));
__END_DECLS

__header_always_inline int
__darwin_check_fd_set(int _a, const void *_b)
{
	if ((uintptr_t)&__darwin_check_fd_set_overflow != (uintptr_t) 0) {
#if defined(_DARWIN_UNLIMITED_SELECT) || defined(_DARWIN_C_SOURCE)
		return __darwin_check_fd_set_overflow(_a, _b, 1);
#else
		return __darwin_check_fd_set_overflow(_a, _b, 0);
#endif
	} else {
		return 1;
	}
}

/* This inline avoids argument side-effect issues with FD_ISSET() */
__header_always_inline int
__darwin_fd_isset(int _fd, const struct fd_set *_p)
{
	if (__darwin_check_fd_set(_fd, (const void *) _p)) {
		return _p->fds_bits[(unsigned long)_fd / __DARWIN_NFDBITS] & ((__int32_t)(((unsigned long)1) << ((unsigned long)_fd % __DARWIN_NFDBITS)));
	}

	return 0;
}

__header_always_inline void
__darwin_fd_set(int _fd, struct fd_set *const _p)
{
	if (__darwin_check_fd_set(_fd, (const void *) _p)) {
		(_p->fds_bits[(unsigned long)_fd / __DARWIN_NFDBITS] |= ((__int32_t)(((unsigned long)1) << ((unsigned long)_fd % __DARWIN_NFDBITS))));
	}
}

__header_always_inline void
__darwin_fd_clr(int _fd, struct fd_set *const _p)
{
	if (__darwin_check_fd_set(_fd, (const void *) _p)) {
		(_p->fds_bits[(unsigned long)_fd / __DARWIN_NFDBITS] &= ~((__int32_t)(((unsigned long)1) << ((unsigned long)_fd % __DARWIN_NFDBITS))));
	}
}


#define __DARWIN_FD_SET(n, p)   __darwin_fd_set((n), (p))
#define __DARWIN_FD_CLR(n, p)   __darwin_fd_clr((n), (p))
#define __DARWIN_FD_ISSET(n, p) __darwin_fd_isset((n), (p))
```

And then from `$SDK/usr/include/sys/_types/_fd_set.h`:

```c
#define FD_SET(n, p)    __DARWIN_FD_SET(n, p)
```

And if you grep through gnutls source, you'll find plenty of instances where `FD_SET` is used.

There's a changelog entry dated to `Thu Jun 14 12:36:10 2018 +0300` that seems to have introduced this behaviour, but I'm assuming that doesn't matter, as it looks like it was a change on the Xcode/SDK side that broke this.

-- 
Reply to this email directly or view it on GitLab: https://gitlab.com/gnutls/gnutls/-/issues/966#note_343664684
You're receiving this email because of your account on gitlab.com.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gnupg.org/pipermail/gnutls-devel/attachments/20200516/82b93faf/attachment-0001.html>


More information about the Gnutls-devel mailing list