Hi,I just realized that the CIL build chain does not support the native versions of the OCaml tools. The native tool versions often outperform the byte code versions, e.g. ocamlc.opt (the native version) can compile CIL much faster than ocamlc (the byte code version) can.
I consider supporting the native OCaml tools for building CIL a nice feature, so I added support for it to my configure script and makefiles. Now, the native tool versions are used automatically if present on the system. This speeds up building CIL by a factor of 2 to 3 for me. Native tool usage can also be manually controlled by defining or un-defining the makefile variable CAMLNATTL on the command line.
I attached a patch for my modifications. Feel free to use it if it's of any use for you.
Cheers Oliver
diff --git a/Makefile.in b/Makefile.in index c840398..64ed679 100644 --- a/Makefile.in +++ b/Makefile.in @@ -42,6 +42,12 @@ ifdef RELEASE UNSAFE := 1 endif +ifndef CAMLNATTL + ifeq (@HAS_OCAML_NATIVE_TOOLS@, 1) + CAMLNATTL := 1 + endif +endif + ifndef ARCHOS ARCHOS=@ARCHOS@ endif diff --git a/configure.in b/configure.in index 9532238..33688d1 100644 --- a/configure.in +++ b/configure.in @@ -34,6 +34,9 @@ CIL_VERSION_MINOR=5 CIL_VERSION_REV=0 CIL_VERSION=$CIL_VERSION_MAJOR.$CIL_VERSION_MINOR.$CIL_VERSION_REV +# Assume at first that no native versions of OCaml tools are available +HAS_OCAML_NATIVE_TOOLS=0 + # make sure I haven't forgotten to run autoconf if test configure -ot configure.in; then @@ -173,6 +176,23 @@ if binaryExists ocamlc; then in the path. ]) fi + + # check if native versions of OCaml tools are available + AC_MSG_CHECKING(availability of native ocaml tool versions) + if binaryExists ocamlc.opt && \ + binaryExists ocamllex.opt && \ + binaryExists ocamldep.opt && \ + binaryExists ocamlopt.opt; then + veropt=`ocamlc.opt -v | grep version | sed 's/^.*version //'` + if [[ "$ver" == "$veropt" ]]; then + AC_MSG_RESULT(ok) + HAS_OCAML_NATIVE_TOOLS=1 + else + AC_MSG_RESULT([no, version missmatch: $veropt]) + fi + else + AC_MSG_RESULT(no) + fi else AC_MSG_ERROR([ The "ocamlc" OCaml compiler was not found in the path: $PATH. @@ -555,6 +575,7 @@ AC_SUBST(THREAD_IS_KEYWORD) AC_SUBST(UNDERSCORE_NAME) AC_SUBST(EXTRAFEATURES) AC_SUBST(EXTRASRCDIRS) +AC_SUBST(HAS_OCAML_NATIVE_TOOLS) # finish the configure script and generate various files; ./configure # will apply variable substitutions to <filename>.in to generate <filename>; diff --git a/ocamlutil/Makefile.ocaml b/ocamlutil/Makefile.ocaml index bf63168..55cb602 100644 --- a/ocamlutil/Makefile.ocaml +++ b/ocamlutil/Makefile.ocaml @@ -43,7 +43,7 @@ # - you can use one Makefile for several Ocaml projects # # You must include this file in your Makefile. Before the include point - # you must defined the following variables (which are glob al for all Ocaml + # you must defined the following variables (which are global for all Ocaml # projects specified in one Makefile): # # CAMLDIR - the directory where to get the ocaml executables from. @@ -62,6 +62,7 @@ # STATIC - if set then it will compile and link statically # (NATIVECAML mode only) # PREPROC - the preprocessor command + # CAMLNATTL - if set then will use native versions of the OCaml tools # WIN32 - means that we are using the Windows native tools @@ -167,10 +168,19 @@ # $^ # +ifdef CAMLNATTL + CAMLLEX = ocamllex.opt + CAMLDEP = ocamldep.opt + CAMLCMPLR = ocamlc.opt + CAMLCMPLR_OPT = ocamlopt.opt +else + CAMLLEX = ocamllex + CAMLDEP = ocamldep + CAMLCMPLR = ocamlc + CAMLCMPLR_OPT = ocamlopt +endif -CAMLLEX = ocamllex -CAMLYACC= ocamlyacc -v -CAMLDEP = ocamldep +CAMLYACC = ocamlyacc -v CAMLP4 = camlp4 pa_o.cmo pa_op.cmo pr_o.cmo # Internal versions of COMPILEFLAGS and LINKFLAGS. We'll add additional flags @@ -252,8 +262,8 @@ ifdef NATIVECAML endif endif #foo := $(shell echo "I am in NATIVECAML mode" >&2; echo whatever) - CAMLC = $(CAMLDIR)ocamlopt $(COMPILE_FLAGS) - CAMLLINK = $(CAMLDIR)ocamlopt $(LINK_FLAGS) + CAMLC = $(CAMLDIR)$(CAMLCMPLR_OPT) $(COMPILE_FLAGS) + CAMLLINK = $(CAMLDIR)$(CAMLCMPLR_OPT) $(LINK_FLAGS) CMO = cmx CMC = opt.$(OBJ) # compiled (and optimized) C CMXA = cmxa @@ -263,7 +273,7 @@ ifdef NATIVECAML # sm: by adding -native in native mode, we prevent spurious # dependencies on .cmo files which were causing lots of # extra recompilation - CAMLDEP = $(CAMLDIR)ocamldep -native + CAMLDEP = $(CAMLDIR)$(CAMLDEP) -native # CAML_NOOPT maintains its value on entry (default, missing) else # Bytecode mode @@ -277,8 +287,8 @@ else CAMLC = $(CAMLDIR)ocamlcp -p a $(COMPILE_FLAGS) CAMLLINK = $(CAMLDIR)ocamlcp -p a -custom $(LINK_FLAGS) else - CAMLC = $(CAMLDIR)ocamlc $(COMPILE_FLAGS) - CAMLLINK = $(CAMLDIR)ocamlc -custom $(LINK_FLAGS) + CAMLC = $(CAMLDIR)$(CAMLCMPLR) $(COMPILE_FLAGS) + CAMLLINK = $(CAMLDIR)$(CAMLCMPLR) -custom $(LINK_FLAGS) endif CAML_NOOPT = 1 endif
------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________ CIL-users mailing list CIL-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/cil-users