Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac: make Xcode optional for building libuv #31

Closed
idkjs opened this issue Jan 20, 2020 · 9 comments · Fixed by #45
Closed

Mac: make Xcode optional for building libuv #31

idkjs opened this issue Jan 20, 2020 · 9 comments · Fixed by #45

Comments

@idkjs
Copy link
Contributor

idkjs commented Jan 20, 2020

Brother @aantron! First, you are beast brother. This project is awesome. Thanks for taking the time to develop and share.

Question. Im on a mac with limited space so i regularly remove Xcode. Building failed because It was not on my machine. Is Xcode required to build this project? If so, is it not buildable in a docker container?

Thank you, sir.

@aantron
Copy link
Owner

aantron commented Jan 20, 2020

Without seeing more details, I assume what is happening is that OCaml itself (whether esy or opam) works fine in your environment, but the libuv build failed because of the internal build of the vendored libuv. If that's the case, then yes, Xcode may be required. That's not intentional - it's a consequence of the libuv build process, if true.

Can you confirm that this is what is happening? Alternatively, can you show the error message, and I should be able to confirm?

If so, we would have to look into the libuv build to see what can be done. IIRC there is an autotools-based build alternative for libuv, not sure if it is still maintained. That may be able to detect your C compiler even when Xcode is not installed. There may also be options for the gyp build (that is currently used) that can be used to achieve this.

@aantron
Copy link
Owner

aantron commented Jan 20, 2020

Also, in case it helps to debug in your environment, here are the build commands Luv issues for building vendored libuv:

luv/src/vendor/dune

Lines 4 to 10 in c73630f

(action (progn
(run ocaml link-gyp.ml)
(chdir libuv (run ./gyp_uv.py -f make))
(setenv CFLAGS -fPIC
(setenv BUILDTYPE Release
(run make -C libuv/out libuv)))
(run cp libuv/out/Release/libuv.a libuv.a))))

The link-gyp.ml script just links the vendored gyp as a subdirectory of libuv, as libuv expects:

#load "unix.cma"
let () =
if Sys.file_exists "libuv/build/gyp" then
exit 0;
(try Unix.mkdir "libuv/build" 0o755
with Unix.Unix_error (Unix.EEXIST, _, _) -> ());
Unix.symlink "../../gyp" "libuv/build/gyp"

This all runs in src/vendor (_build/default/src/vendor).

@aantron
Copy link
Owner

aantron commented Jan 20, 2020

..and the build instructions for libuv: https://github.com/libuv/libuv#build-instructions

Finally, I'm glad this project can be useful :)

@idkjs
Copy link
Contributor Author

idkjs commented Jan 20, 2020

Here is the output of make test which doesnt reference Xcode probably because i installed it after the last error. This error references future-syntax missing which i guess I will just add see what happens:

luvv [master]make test
dune build src/vendor/libuv.a
      gyp_uv src/vendor/libuv.a
['-f', 'make', '-I', 'common.gypi', 'test/test.gyp', '--depth=.', '-Goutput_dir=/Users/prisc_000/working/GitHub/luvv/_build/default/src/vendor/libuv/out', '--generator-output', '/Users/prisc_000/working/GitHub/luvv/_build/default/src/vendor/libuv/out', '-Dhost_arch=x64', '-Dtarget_arch=x64', '-Duv_library=static_library']
        make src/vendor/libuv.a
  CC(target) /Users/prisc_000/working/GitHub/luvv/_build/default/src/vendor/libuv/out/Release/obj.target/libuv/src/fs-poll.o
  CC(target) /Users/prisc_000/working/GitHub/luvv/_build/default/src/vendor/libuv/out/Release/obj.target/libuv/src/idna.o
  CC(target) /Users/prisc_000/working/GitHub/luvv/_build/default/src/vendor/libuv/out/Release/obj.target/libuv/src/inet.o
  CC(target) /Users/prisc_000/working/GitHub/luvv/_build/default/src/vendor/libuv/out/Release/obj.target/libuv/src/random.o
  CC(target) /Users/prisc_000/working/GitHub/luvv/_build/default/src/vendor/libuv/out/Release/obj.target/libuv/src/strscpy.o
  CC(target) /Users/prisc_000/working/GitHub/luvv/_build/default/src/vendor/libuv/out/Release/obj.target/libuv/src/threadpool.o
  CC(target) /Users/prisc_000/working/GitHub/luvv/_build/default/src/vendor/libuv/out/Release/obj.target/libuv/src/timer.o
  CC(target) /Users/prisc_000/working/GitHub/luvv/_build/default/src/vendor/libuv/out/Release/obj.target/libuv/src/uv-data-getter-setters.o
  CC(target) /Users/prisc_000/working/GitHub/luvv/_build/default/src/vendor/libuv/out/Release/obj.target/libuv/src/uv-common.o
  CC(target) /Users/prisc_000/working/GitHub/luvv/_build/default/src/vendor/libuv/out/Release/obj.target/libuv/src/version.o
  CC(target) /Users/prisc_000/working/GitHub/luvv/_build/default/src/vendor/libuv/out/Release/obj.target/libuv/src/unix/async.o
  CC(target) /Users/prisc_000/working/GitHub/luvv/_build/default/src/vendor/libuv/out/Release/obj.target/libuv/src/unix/core.o
  CC(target) /Users/prisc_000/working/GitHub/luvv/_build/default/src/vendor/libuv/out/Release/obj.target/libuv/src/unix/dl.o
  CC(target) /Users/prisc_000/working/GitHub/luvv/_build/default/src/vendor/libuv/out/Release/obj.target/libuv/src/unix/fs.o
  CC(target) /Users/prisc_000/working/GitHub/luvv/_build/default/src/vendor/libuv/out/Release/obj.target/libuv/src/unix/getaddrinfo.o
  CC(target) /Users/prisc_000/working/GitHub/luvv/_build/default/src/vendor/libuv/out/Release/obj.target/libuv/src/unix/getnameinfo.o
  CC(target) /Users/prisc_000/working/GitHub/luvv/_build/default/src/vendor/libuv/out/Release/obj.target/libuv/src/unix/loop.o
  CC(target) /Users/prisc_000/working/GitHub/luvv/_build/default/src/vendor/libuv/out/Release/obj.target/libuv/src/unix/loop-watcher.o
  CC(target) /Users/prisc_000/working/GitHub/luvv/_build/default/src/vendor/libuv/out/Release/obj.target/libuv/src/unix/pipe.o
  CC(target) /Users/prisc_000/working/GitHub/luvv/_build/default/src/vendor/libuv/out/Release/obj.target/libuv/src/unix/poll.o
  CC(target) /Users/prisc_000/working/GitHub/luvv/_build/default/src/vendor/libuv/out/Release/obj.target/libuv/src/unix/process.o
  CC(target) /Users/prisc_000/working/GitHub/luvv/_build/default/src/vendor/libuv/out/Release/obj.target/libuv/src/unix/random-devurandom.o
  CC(target) /Users/prisc_000/working/GitHub/luvv/_build/default/src/vendor/libuv/out/Release/obj.target/libuv/src/unix/signal.o
  CC(target) /Users/prisc_000/working/GitHub/luvv/_build/default/src/vendor/libuv/out/Release/obj.target/libuv/src/unix/stream.o
  CC(target) /Users/prisc_000/working/GitHub/luvv/_build/default/src/vendor/libuv/out/Release/obj.target/libuv/src/unix/tcp.o
  CC(target) /Users/prisc_000/working/GitHub/luvv/_build/default/src/vendor/libuv/out/Release/obj.target/libuv/src/unix/thread.o
  CC(target) /Users/prisc_000/working/GitHub/luvv/_build/default/src/vendor/libuv/out/Release/obj.target/libuv/src/unix/tty.o
  CC(target) /Users/prisc_000/working/GitHub/luvv/_build/default/src/vendor/libuv/out/Release/obj.target/libuv/src/unix/udp.o
  CC(target) /Users/prisc_000/working/GitHub/luvv/_build/default/src/vendor/libuv/out/Release/obj.target/libuv/src/unix/proctitle.o
  CC(target) /Users/prisc_000/working/GitHub/luvv/_build/default/src/vendor/libuv/out/Release/obj.target/libuv/src/unix/darwin.o
  CC(target) /Users/prisc_000/working/GitHub/luvv/_build/default/src/vendor/libuv/out/Release/obj.target/libuv/src/unix/fsevents.o
  CC(target) /Users/prisc_000/working/GitHub/luvv/_build/default/src/vendor/libuv/out/Release/obj.target/libuv/src/unix/darwin-proctitle.o
  CC(target) /Users/prisc_000/working/GitHub/luvv/_build/default/src/vendor/libuv/out/Release/obj.target/libuv/src/unix/random-getentropy.o
  CC(target) /Users/prisc_000/working/GitHub/luvv/_build/default/src/vendor/libuv/out/Release/obj.target/libuv/src/unix/bsd-ifaddrs.o
  CC(target) /Users/prisc_000/working/GitHub/luvv/_build/default/src/vendor/libuv/out/Release/obj.target/libuv/src/unix/kqueue.o
  LIBTOOL-STATIC /Users/prisc_000/working/GitHub/luvv/_build/default/src/vendor/libuv/out/Release/libuv.a
dune build test/tester.exe
File "src/syntax/dune", line 4, characters 13-28:
4 |  (preprocess (future_syntax)))
                 ^^^^^^^^^^^^^^^
Error: Program ocaml-syntax-shims not found in the tree or in PATH
 (context: default)
make: *** [test] Error 1
➜  luvv [master]

@idkjs
Copy link
Contributor Author

idkjs commented Jan 20, 2020

Adding ocaml-syntax-shims gets the test to run.

My ocaml version is:

luv2 [master]ocamlc -version
4.07.1
➜  luv2 [master]

So I am guessing that this line is supposed to install it if the version is greater than 4.08.0. Maybe it should be 4.07.*?.

luv/luv.opam

Line 20 in c73630f

("ocaml" {>= "4.08.0"} | "ocaml-syntax-shims")

Is that correct?

To the original question, Xcode is required then?

@aantron
Copy link
Owner

aantron commented Jan 20, 2020

The line should install ocaml-syntax-shims if the OCaml version is less than 4.08. I tested it on 4.02.3 locally, and it seemed to trigger the install. Could you remove ocaml-syntax-shims and show the command you use to install and the output of the changes to the package list it wants to make?

As for Xcode, looking at the libuv build instructions, it looks like it is required as long as Luv uses the gyp build process for libuv. We can work around this requirement by using autotools instead, but then autotools is required, and we will need detection code to find out what is present.

@aantron
Copy link
Owner

aantron commented Jan 20, 2020

Also, instead of ocaml -version, could you show opam switch output, or the output of any other command that shows the compiler installed in the switch? This is just in case the compiler in PATH does not match the switch being used by opam.

@aantron aantron changed the title building project on mac Mac: make Xcode optional for building libuv Feb 29, 2020
@aantron
Copy link
Owner

aantron commented Mar 11, 2020

#45 replaced the GYP build with a different process, so the libuv build no longer uses or looks for Xcode on Mac.

@idkjs
Copy link
Contributor Author

idkjs commented Mar 11, 2020

Sorry didn't get back to you. Lost track of it.

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 a pull request may close this issue.

2 participants