jart / blink

tiniest x86-64-linux emulator
ISC License
7k stars 224 forks source link

Static build not working on macOS #139

Closed wvdschel closed 1 year ago

wvdschel commented 1 year ago

Building blink on macOS works fine, but it fails when configured with --static:

$ ./configure --static
...
$ gmake -j10
...
cc -g -O2 -U_FORTIFY_SOURCE -isystem tool/stdatomic -D_FILE_OFFSET_BITS=64 -D_DARWIN_C_SOURCE -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_GNU_SOURCE -iquote. -isystem third_party/libz -D_DARWIN_C_SOURCE  -c -o o//blink/jit.o blink/jit.c
blink/jit.c:223:7: error: call to undeclared function 'pthread_jit_write_protect_np'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
      pthread_jit_write_protect_np(enabled);
      ^
blink/jit.c:1361:9: error: call to undeclared function 'pthread_jit_write_protect_supported_np'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    if (pthread_jit_write_protect_supported_np()) {
        ^
blink/jit.c:1361:9: note: did you mean 'pthread_jit_write_protect_np_workaround'?
blink/jit.c:172:13: note: 'pthread_jit_write_protect_np_workaround' declared here
static void pthread_jit_write_protect_np_workaround(int enabled) {
            ^
blink/jit.c:1722:7: error: call to undeclared function 'pthread_jit_write_protect_supported_np'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  if (pthread_jit_write_protect_supported_np()) {
      ^
blink/jit.c:1743:7: error: call to undeclared function 'pthread_jit_write_protect_supported_np'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  if (pthread_jit_write_protect_supported_np()) {
      ^
4 errors generated.
jart commented 1 year ago

Apple doesn't entirely support static linking. Especially if you're using Arm64 where I think it's explicitly forbidden. I'd consider contributions working around this, but this probably isn't worth focusing on too much, due to the way Apple is.