SQLite3MultipleCiphers: `tvOS`/`watchOS` compilation errors

Trying to compile for watchOS and tvOS but keep running into the following errors related to usage of syscall

error: 'syscall' is unavailable: not available on tvOS
    if (syscall(SYS_getentropy, buf, n) == 0)
        ^
note: 'syscall' has been explicitly marked unavailable here
int        syscall(int, ...);
           ^

Everything’s working great though for iOS 👍

Seeing in the amalgamations that there is conditional arguments for macOS and iOS only. Would it be possible to also include tvOS and watchOS?

About this issue

  • Original URL
  • State: closed
  • Created 9 months ago
  • Comments: 24 (14 by maintainers)

Commits related to this issue

Most upvoted comments

Unfortunately, the CI run fails for macOS, see GitHub CI macOS. Probably it is necessary to specify a link library, but which one?

Need to add link flag -framework Security for apple

Thanks. I adjusted the autoconf build files and now it works.

Could you please test to change the code for function entropy as follows:

  1. Add include for Apple target conditionals (3 lines)
  2. Add check for tvOS and watchOS
#if defined(__APPLE__)
#include "TargetConditionals.h"
#endif

static size_t entropy(void* buf, size_t n)
{
#if defined(__APPLE__) && ((defined(__MAC_10_12) && __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_12) || TARGET_OS_TV || TARGET_OS_WATCH)
  if (getentropy(buf, n) == 0)
    return n;
#elif defined(__linux__) && defined(SYS_getrandom)
  if (syscall(SYS_getrandom, buf, n, 0) == n)
    return n;
#elif defined(SYS_getentropy)
  if (syscall(SYS_getentropy, buf, n) == 0)
    return n;
#endif
  return read_urandom(buf, n);
}

If that works for you please let me know.