Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0004460OCaml~DO NOT USE (was: OCaml general)public2007-11-30 17:042010-04-27 09:26
Assigned Togarrigue 
PlatformOSOS Version
Product Version3.10.0 
Target VersionFixed in Version3.11+dev 
Summary0004460: toplevels built with ocamlmktop do not support opening files compiled with -rectypes
DescriptionThis looks similar to bug report 4402 with ocamlmktop instead of ocamldebug.

The following script allows to reproduce the problem.
#ocamlc -c -rectypes
#ocamlmktop -o mytop
open Foo
Unit Foo imports from , which uses recursive types.
The compilation flag -rectypes is required

Adding option -rectypes to ocamlmktop does not change anything (maybe should it? or has to systematically set Clflags.recursive_types to true?)
TagsNo tags attached.
Attached Filesdiff file icon toprectypes.diff [^] (1,194 bytes) 2008-11-18 23:07 [Show Content]

- Relationships

-  Notes
jm (reporter)
2007-11-30 17:50

Try to add -rectypes to your custom toplevel:

% ./mytop -rectypes
        Objective Caml version 3.10.1+dev3 (2007-11-26)

# open Foo;;

herbelin (reporter)
2007-11-30 18:18
edited on: 2007-11-30 20:07

Adding -rectypes to the custom toplevel command line works for the simple problem mentioned above but not in the more general case (which is in fact our real case) where the custom toplevel has its own parser for the arguments of the command line .

Would it be possible though to do so that the custom toplevel has automatically the recursive_types flag set? I tried to add Clflags.recursive_types := true in but I couldn't get the Clflags module visible when compiling, even with toplevellib.cma loaded. Thanks in advance.

jm (reporter)
2007-11-30 19:51

> Would it be possible though to do so that the custom toplevel
> has automatically the recursive_types flag set?
I do not see anything that could help in topdirs.mli, topmain.mli or toploop.mli.
Neither any toplevel directive that would do the job.
And Sys.argv could not be extended.

So you may have to use a shell alias:
  alias mytop='mytop -rectypes'
Or a shell script
  mytop -rectypes

> I tried to add Clflags.recursive_types := true in
> but I couldn't get the Clflags module visible
> when compiling, even with toplevellib.cma loaded.
That's because you need clflags.cmi which is not inside
the binaries of ocaml (in `ocamlc -where` I mean),
but if you have the sources of your ocaml
in /usr/local/src/ocaml for instance, then you can do:
% ocamlc -c -rectypes
% cat
let _ =
        print_endline "Set rectypes.";
        Clflags.recursive_types := true

% ocamlmktop -o mytop_rectypes -I /usr/local/src/ocaml/utils
% ./mytop_rectypes
Set rectypes.
        Objective Caml version 3.10.1+dev3 (2007-11-26)

# open Foo;;
# type t = t -> t;;
type t = t -> t

garrigue (manager)
2007-12-16 07:08

I think that the original report is correct. Indeed,
ocamlmktop -rectypes should set the resulting toplevel to
use recursive types. This is because it is unsafe to use
an environment containing recursive types without the flag
correctly set. But I'm not sure of how it could be implemented.
One way to do it would be to put a "use_rectypes.cmo" file
in the library directory, and link it if the option was given,
but it looks a little hacky.
herbelin (reporter)
2008-11-14 13:22

Here is an update to the -rectypes issue with ocamlmktop that I submitted for ocaml 3.10.

For debugging purposes of the coq software, we do on-demand calls to the ocaml toplevel loop as in the following configuration:

% cat
(* parsing command line and doing some job with them, eventually leading to *)
Toploop.loop Format.std_formatter
% ocamlmktop -o foo -rectypes
% ./foo
# type t = t -> t;;

which fails since 3.10. We know about the Cflags-linking workaround but it requires the ocaml sources. We know another hack which is to cheat with Sys.argv, setting all arguments to "-rectypes" and using a call to Topmain.main to activate the Cflags.recursive_types option, but this needs to have at least one true argument in Sys.argv. Will there be cleaner alternatives with 3.11?

Thanks in advance.
glondu (reporter)
2008-11-18 23:07

Another possibility would be to add a new toplevel directive #rectypes. This seems to be a quite well-established way to alter command line options from within a toplevel. Attached is patch implementing this.
garrigue (manager)
2008-11-19 03:39

I've commited Stephane's patch (adding a #rectypes directive), since it seems a good thing
to have anyway. It is safe, since it only allows to set -rectypes, not to unset it.

Does it solve the problem for Coq?
glondu (reporter)
2008-11-19 15:31

Not exactly. But it is sufficient for our purposes.

Thank you.
garrigue (manager)
2010-04-27 09:26

The fix seems to be sufficient.

- Issue History
Date Modified Username Field Change
2007-11-30 17:04 herbelin New Issue
2007-11-30 17:50 jm Note Added: 0004369
2007-11-30 18:18 herbelin Note Added: 0004370
2007-11-30 19:51 jm Note Added: 0004371
2007-11-30 20:07 herbelin Note Edited: 0004370
2007-12-06 15:38 doligez Status new => acknowledged
2007-12-16 07:02 garrigue Status acknowledged => assigned
2007-12-16 07:02 garrigue Assigned To => garrigue
2007-12-16 07:08 garrigue Note Added: 0004390
2008-11-14 13:22 herbelin Note Added: 0004745
2008-11-18 23:07 glondu Note Added: 0004756
2008-11-18 23:07 glondu File Added: toprectypes.diff
2008-11-19 03:39 garrigue Note Added: 0004757
2008-11-19 03:39 garrigue Status assigned => acknowledged
2008-11-19 15:31 glondu Note Added: 0004763
2010-04-27 09:26 garrigue Note Added: 0005388
2010-04-27 09:26 garrigue Status acknowledged => closed
2010-04-27 09:26 garrigue Resolution open => fixed
2010-04-27 09:26 garrigue Fixed in Version => 3.11+dev
2017-02-23 16:36 doligez Category OCaml general => -OCaml general
2017-03-03 17:55 doligez Category -OCaml general => -(deprecated) general
2017-03-03 18:01 doligez Category -(deprecated) general => ~deprecated (was: OCaml general)
2017-03-06 17:04 doligez Category ~deprecated (was: OCaml general) => ~DO NOT USE (was: OCaml general)

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker