Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005548OCaml-for ocamlbuild use 11:072017-03-03 15:26
Assigned Togasche 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0005548: ocamlbuild's ocamlfind integration doesn't support syntax extensions
DescriptionOCamlbuild's ocamlfind integration includes -I-options and stuff from ocamlfind in the "compile" and "link" ocamlbuild steps but, to my knowledge, does not include them during preprocessing ("pp"). This means that while ocamlfind libraries can be used, I don't know how to use their attached syntax extensions (ocamlfind's predicate "syntax"). It would be nice if that was fixed.
Steps To ReproduceWith some ocamlfind package "foo.syntax" that enables syntax extensions, and some file "" using the extension,

  ocamlfind ocamlc -syntax camlp4o -package foo.syntax

does not raise a syntax error, while for instance

  ocamlbuild -use-ocamlfind -tag "package(foo.syntax)"

does (because neither ocamlfind's -I-option nor the camlp4 extension archive name are included in the camlp4o invocation).
Additional InformationI have discussed this with Anil Madhavapeddy which mentioned a related need on the mailing list:!topic/fa.caml/y6VsobyJV0s/discussion [^]
TagsNo tags attached.
Attached Files

- Relationships
related to 0006102acknowledged ocaml{c,opt}: Provide command-line options to stop compilation after any stage 

-  Notes
gasche (administrator)
2012-03-20 11:09

I discussed this with xclerc and therefore mark this as "acknowledged".

If someone in the respected audience has a patch, please submit it! (Sane) contributions to fix ocamlbuild deficiencies are always welcome.
meyer (developer)
2012-09-10 05:16

So ocamlbuild just does not use ocamlfind in this case. This definetely needs fixing.
gasche (administrator)
2013-06-16 19:38

This PR has in fact seen invisible progress: in the SVN commit 13262, Wojciech implemented a "-syntax <foo>" command-line option for ocamlbuild, meant to be used exactly as for ocamlfind. It is equivalent to passing the tag "syntax(foo)".

You can therefore use

    ocamlbuild -use-ocamlfind -syntax camlp4o -package foo.syntax test.byte

to compile into test.byte.

For example for as such:
  IFDEF BLAH THEN print_endline "foo" END

You can use the two equivalent commands:

  ocamlbuild -use-ocamlfind -tag "syntax(camlp4o -DBLAH)" -package camlp4.macro test.byte
  ocamlbuild -use-ocamlfind -syntax "camlp4o -DBLAH" -package camlp4.macro test.byte

However, the target still does not work as expected. I know of no easy way to call ocamlfind for only the preprocessing phase, and get source code as a result (in particular there is no "ocamlfind camlp4* -package ..." invocation possible.

Options for implementing this would be to:

(1) re-implement the build-camlp4-invocation-command logic in ocamlbuild (reusing the ocamlfind-like logic that was present before -use-ocamlfind was implemented), by calling "ocamlfind query" to get the right option to pass to the preprocessor; painful and probably not the best solution

(2) work-around the issue the issue by internally calling "ocamlfind ocamlc -syntax camlp4o ... -dsource" to convince ocamlfind that he's invoking a compiler, but actually get the postprocessed source code from ocaml. Not satisfying right now as there is no "-stop-after-parsing" flag to feed to the compiler, and it would still e.g. fail on ill-typed files. It's still a credible option, and in particular could be the best one if we want to also perform -ppx rewritings.

(3) implement the "ocamlfind camlp4*" command. I have not contacted Gerd to know whether that would be possible, but I would suspect that if this (rather natural) feature is not present, he possibly has already considered that and has good reason not to do it.

In any case, none of those options are realistic during a feature freeze, so I'm moving the part of this bug (the rest I consider solved) to 4.02+dev.
doligez (administrator)
2017-03-03 15:26

ocamlbuild is now a separate project that lives on GitHub.
PR transferred to [^]

- Issue History
Date Modified Username Field Change
2012-03-20 11:07 gasche New Issue
2012-03-20 11:09 gasche Note Added: 0007112
2012-03-20 11:09 gasche Status new => acknowledged
2012-07-10 11:27 doligez Target Version => 4.01.0+dev
2012-07-31 13:36 doligez Target Version 4.01.0+dev => 4.00.1+dev
2012-09-10 05:16 meyer Note Added: 0008042
2012-09-10 05:16 meyer Assigned To => meyer
2012-09-10 05:16 meyer Status acknowledged => assigned
2012-09-21 13:50 doligez Target Version 4.00.1+dev => 4.01.0+dev
2013-06-16 19:38 gasche Note Added: 0009518
2013-06-16 19:38 gasche Assigned To meyer => gasche
2013-06-16 19:38 gasche Target Version 4.01.0+dev => 4.02.0+dev
2013-06-16 21:26 gasche Severity minor => feature
2013-07-12 18:15 doligez Target Version 4.02.0+dev => 4.01.1+dev
2013-07-29 18:36 gasche Relationship added related to 0006102
2014-05-25 20:24 doligez Target Version 4.01.1+dev => 4.02.0+dev
2014-08-21 11:52 doligez Target Version 4.02.0+dev =>
2017-02-23 16:34 doligez Category OCamlbuild (the tool) => for ocamlbuild use [^]
2017-02-23 16:44 doligez Category for ocamlbuild use [^] => -for ocamlbuild use [^]
2017-03-03 15:26 doligez Note Added: 0017544
2017-03-03 15:26 doligez Status assigned => resolved
2017-03-03 15:26 doligez Resolution open => suspended

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker