aantron / luv

Cross-platform asynchronous I/O and system calls
https://aantron.github.io/luv
MIT License
275 stars 26 forks source link

Failing to build on macOS #3

Closed andreypopp closed 5 years ago

andreypopp commented 5 years ago

Hi! I'm looking into luv and it fails building for me:

    (cd /Users/andreypopp/Workspace/fibe/luv2/_esy/default/store/b/opam__s__luv-a8869f62/default/src/c && /bin/bash -e -u -o pipefail -c 'gcc -O2 -fno-strict-aliasing -fwrapv generate_types_step_2.c -I `dirname /Users/andreypopp/.esy/3______________________________________________________________/i/opam__s__ctypes-opam__c__0.14.0-3de84ab9/lib/ctypes/ctypes_cstubs_internals.h` -I /Users/andreypopp/.esy/3______________________________________________________________/i/ocaml-4.6.9-4708df4c/lib/ocaml -I ../../../../src/vendor/libuv/include -o generate_types_step_2.exe')
    generate_types_step_2.c:826:37: error: use of undeclared identifier 'X_OK'
         enum { check_X_OK_const = (int)X_OK };
                                        ^
    generate_types_step_2.c:827:15: error: use of undeclared identifier 'X_OK'
         int v = (X_OK);
                  ^
    generate_types_step_2.c:833:37: error: use of undeclared identifier 'W_OK'
         enum { check_W_OK_const = (int)W_OK };
                                        ^
    generate_types_step_2.c:834:15: error: use of undeclared identifier 'W_OK'
         int v = (W_OK);
                  ^
    generate_types_step_2.c:840:37: error: use of undeclared identifier 'R_OK'
         enum { check_R_OK_const = (int)R_OK };
                                        ^
    generate_types_step_2.c:841:15: error: use of undeclared identifier 'R_OK'
         int v = (R_OK);
                  ^
    generate_types_step_2.c:847:37: error: use of undeclared identifier 'F_OK'
         enum { check_F_OK_const = (int)F_OK };
                                        ^
    generate_types_step_2.c:848:15: error: use of undeclared identifier 'F_OK'
         int v = (F_OK);
                  ^
    8 errors generated.
          ocamlc src/c/helpers.o (exit 2)
    (cd /Users/andreypopp/Workspace/fibe/luv2/_esy/default/store/b/opam__s__luv-a8869f62/default/src/c && /Users/andreypopp/.esy/3______________________________________________________________/i/ocaml-4.6.9-4708df4c/bin/ocamlc.opt -g -I /Users/andreypopp/.esy/3______________________________________________________________/i/ocaml-4.6.9-4708df4c/lib/ocaml/threads -I /Users/andreypopp/.esy/3______________________________________________________________/i/opam__s__ctypes-opam__c__0.14.0-3de84ab9/lib/ctypes -I /Users/andreypopp/.esy/3______________________________________________________________/i/opam__s__integers-opam__c__0.2.2-b5636484/lib/integers -I /Users/andreypopp/.esy/3______________________________________________________________/i/opam__s__ocamlfind-opam__c__1.8.0-3159ddf0/lib/bytes -I . -ccopt -g -ccopt '-I ../../../../src/vendor/libuv/include' -o helpers.o helpers.c)
    helpers.c:493:14: error: expected expression
        *guard = UV_ONCE_INIT;
                 ^
    /usr/local/include/uv/unix.h:128:22: note: expanded from macro 'UV_ONCE_INIT'
    #define UV_ONCE_INIT PTHREAD_ONCE_INIT
                         ^
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/pthread.h:216:27: note: expanded from macro 'PTHREAD_ONCE_INIT'
    #define PTHREAD_ONCE_INIT {_PTHREAD_ONCE_SIG_init, {0}}
                              ^
    1 error generated.
    error: command failed: 'dune' 'build' '--only-packages' 'luv' '--root' '.' (exited with 1)
    esy-build-package: exiting with errors above...

Looking at helpers.c issue it seems like UV_OCE_INIT isn't applied to a static variable while the docs here state:

The guard should be initialized statically with the UV_ONCE_INIT macro.

andreypopp commented 5 years ago

It's macOS of course!

andreypopp commented 5 years ago

Similar issue: https://stackoverflow.com/questions/12484664/what-am-i-doing-wrong-when-installing-lxml-on-mac-os-x-10-8-1

andreypopp commented 5 years ago

The F_OK, ... is resolved by

// needed only for F_OK, R_OK, W_OK, X_OK
#ifndef _WIN32
#include <unistd.h>
#endif

in helpers.h

aantron commented 5 years ago

Thanks @andreypopp , I'll make that change. I haven't set up the macOS build properly yet. I'm surprised it worked at all, in fact :p So, I can't immediately promise that it will work, and will remain working during near-term development, but we should have a proper setup at some point.

aantron commented 5 years ago

Fixed in the attached commit. The build succeeds in Travis on macOS, but luv is currently failing its own tests in Travis on both macOS and Linux, so working that out next.

aantron commented 5 years ago

All now looks good on macOS.