Skip to content

Conversation

@jonahbeckford
Copy link
Contributor

@jonahbeckford jonahbeckford commented Feb 14, 2022

This is an implementation of the cross-compiling design at #129 . It ended up being more complicated because I forgot that the include directories (-I/usr/include) in addition to the libraries (-L/usr/lib -luv) needed modifications.

Testing

Pending testing on Windows; only macOS has been tested

Native compiling on macOS

brew install libuv # 1.43.0
dune clean
unset LUV_USE_SYSTEM_LIBUV LUV_INCLUDE_LIBUV_DEFAULT LUV_LIB_LIBUV_DEFAULT LUV_INCLUDE_LIBUV_DEFAULT_DARWIN_X86_64 LUV_LIB_LIBUV_DEFAULT_DARWIN_X86_64
export LUV_USE_SYSTEM_LIBUV=yes
export LUV_INCLUDE_LIBUV_DEFAULT='-I;/opt/homebrew/include'
export LUV_LIB_LIBUV_DEFAULT='-L/opt/homebrew/lib;-luv'

LUV_USE_SYSTEM_LIBUV=yes LUV_INCLUDE_LIBUV_DEFAULT='-I;/opt/homebrew/include' LUV_LIB_LIBUV_DEFAULT='-L/opt/homebrew/lib;-luv' make test

Failing tests after PR are:

  [FAIL]        version              1   minor.
  [FAIL]        version              5   hex.
  [FAIL]        version              6   version.
  [FAIL]        version              7   string.

  [FAIL]        tty                  0   tty.
  [FAIL]        tty                  1   handle functions.

  # This stalls on macOS (Apple Silicon) so disabled
  ...           udp                  7   multicast.

  # This does SIGABRT so disabled
                thread                   mutex.

Failing tests without LUV_USE_SYSTEM_LIBUV=yes:

  [FAIL]        version              1   minor.
  [FAIL]        version              5   hex.
  [FAIL]        version              6   version.
  [FAIL]        version              7   string.

  [FAIL]        tty                  0   tty.
  [FAIL]        tty                  1   handle functions.

  # These stall on macOS so disabled
  ...           udp                  7   multicast.
  ...           fs_event             2   create.

Cross-compiling on macos

Host=darwin_arm64 Target=darwin_x86_64

Using Duniverse Opam repository at https://github.com/dune-universe/opam-overlays
with one extra patch for ctypes.0.17.1+dune at avsm/ocaml-ctypes#4

dune clean
unset LUV_USE_SYSTEM_LIBUV LUV_INCLUDE_LIBUV_DEFAULT LUV_LIB_LIBUV_DEFAULT LUV_INCLUDE_LIBUV_DEFAULT_DARWIN_X86_64 LUV_LIB_LIBUV_DEFAULT_DARWIN_X86_64
export LUV_USE_SYSTEM_LIBUV=yes
export LUV_INCLUDE_LIBUV_DEFAULT='-I;/opt/homebrew/include'
export LUV_LIB_LIBUV_DEFAULT='-L/opt/homebrew/lib;-luv'
export LUV_INCLUDE_LIBUV_DEFAULT_DARWIN_X86_64="-I;/tmp/dckbuild/darwin_x86_64/vcpkg_installed/x64-osx/include"
export LUV_LIB_LIBUV_DEFAULT_DARWIN_X86_64="-L/tmp/dckbuild/darwin_x86_64/vcpkg_installed/x64-osx/lib;-luv"
dune build @install
dune build -x darwin_x86_64 @install
$ tail -n20 _build/*/src/c/config/compile_c.sh _build/*/src/c/config/uv_lib.sexp
==> _build/default.darwin_x86_64/src/c/config/compile_c.sh <==
#!/bin/sh
# context=default.darwin_x86_64
set -euf
src=$1; shift
ctypes=$1; shift
target=$1; shift
"$@" "$src" -I "$ctypes" -I "/tmp/dckbuild/darwin_x86_64/Debug/dksdk/ocaml/opt/mlcross/darwin_x86_64/lib/ocaml" "-I" "/tmp/dckbuild/darwin_x86_64/vcpkg_installed/x64-osx/include" -o "$target"

==> _build/default/src/c/config/compile_c.sh <==
#!/bin/sh
# context=default
set -euf
src=$1; shift
ctypes=$1; shift
target=$1; shift
"$@" "$src" -I "$ctypes" -I "/tmp/dckbuild/darwin_x86_64/Debug/dksdk/ocaml/lib/ocaml" "-I" "/opt/homebrew/include" -o "$target"

==> _build/default.darwin_x86_64/src/c/config/uv_lib.sexp <==
("-L/tmp/dckbuild/darwin_x86_64/vcpkg_installed/x64-osx/lib" "-luv")
==> _build/default/src/c/config/uv_lib.sexp <==
("-L/opt/homebrew/lib" "-luv")
$ file _build/install/*/lib/stublibs/dllluv_unix_stubs.so
_build/install/default.darwin_x86_64/lib/stublibs/dllluv_unix_stubs.so: Mach-O 64-bit dynamically linked shared library x86_64
_build/install/default/lib/stublibs/dllluv_unix_stubs.so:               Mach-O 64-bit dynamically linked shared library arm64

@jonahbeckford
Copy link
Contributor Author

jonahbeckford commented Mar 8, 2022

Native Windows compiling has been tested as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant