Jump to content


Photo

ocamlopt vs. C compiler


  • Please log in to reply
1 reply to this topic

#1 FredSRichardson

FredSRichardson

    WeiDU Meddler

  • Member
  • 258 posts

Posted 02 June 2003 - 07:33 AM

I noticed that ocamlopt is used to compile C code in the WeiDU makefile as well. Is there any difference between using ocamlopt instead of the C compiler in terms of the object code it produces? Does ocamlopt just run the native C compiler (with some flags)?

I'm just curious. I looked through the ocaml docs briefly but I didn't see an answer there.
I gotta get rid of this friggin idiotic signature...

#2 weimer

weimer
  • Member
  • 1569 posts

Posted 02 June 2003 - 08:26 AM

When you configure and compile ocaml itself for your system, you have to specify whether you are going to use MSVC or GCC. It uses this information to know what sort of object files and libraries to expect when linking in C code with OCaml (cf. JNI). For example, ocaml atop MSVC will pass things like "/lib wsock32.lib" or whatnot.

There isn't really any difference and you could call the underlying C compiler yourself. You can pass -verbose to ocamlc to see what it is doing under the hood. For example, when you use ocamlopt to build zlib.c in WeiDU it's really doing:

+ cl /nologo /Ox /MT -c  "-Iobj/x86_WIN32" "-Izlib" -I"C:\ocaml-3.06-msvc\lib" "zlib/zlib.c"