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

Link multiple casse le système de types #4231

Closed
vicuna opened this issue Mar 15, 2007 · 5 comments

Comments

Projects
None yet
2 participants
@vicuna
Copy link

commented Mar 15, 2007

Original bug ID: 4231
Reporter: @alainfrisch
Assigned to: @lefessan
Status: closed (set by @xavierleroy on 2013-08-31T10:44:13Z)
Resolution: duplicate
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Duplicate of: #5461
Related to: #4229 #4839 #5473 #6462 #6950 #6957
Monitored by: @glondu jmeber "Julien Signoles" @Chris00 ertai @alainfrisch

Bug description

Variante de l'autre bug d'hier, cette fois sans Dynlink...

Steps to reproduce

abstract.mli = sub/abstract.mli:
type t
val x: t
val f: t -> unit

abstract.ml:
type t = int
let x = 10
let f x = Printf.printf "Abstract 1 : %i\n" x

api.ml:
let r : Abstract.t list ref = ref []

x.ml:
let () = Api.r := Abstract.x :: !Api.r; List.iter Abstract.f !Api.r

sub/abstract.ml:
type t = string
let x = "foo"
let f x = Printf.printf "Abstract 2 : %s\n" x

$ ocamlc -c abstract.mli abstract.ml sub/abstract.mli sub/abstract.ml api.ml x.ml
$ ocamlc -o main abstract.ml api.ml x.ml sub/abstract.ml x.ml
$ ./main
zsh: segmentation fault ./main

@vicuna

This comment has been minimized.

Copy link
Author

commented Mar 15, 2007

Comment author: @alainfrisch

On peut faire pareil avec ocamlopt, mais il faut ruser un peu plus à cause (grace?) au test "Files ... and ... both define a module named ...". Heureusement, -pack est là pour nous sauver !

abstract.mli = sub/abstract.mli:
type t
val x: t
val f: t -> unit

abstract.ml:
type t = int
let x = 10
let f x = Printf.printf "Abstract 1 : %i\n" x

sub/abstract.ml:
type t = string
let x = "foo"
let f x = Printf.printf "Abstract 2 : %s\n" x

api.ml:
let r : Abstract.t list ref = ref []

x.ml = sub/x.ml:
let () = Api.r := Abstract.x :: !Api.r; List.iter Abstract.f !Api.r

compilation:
$ ocamlopt -c abstract.mli abstract.ml api.ml x.ml
$ cd sub
$ ocamlopt -c -for-pack P -I .. x.ml
$ ocamlopt -c -for-pack P -I .. abstract.mli
$ ocamlopt -c -for-pack P -I .. abstract.ml
$ ocamlopt -pack -o p.cmx abstract.cmx x.cmx
$ cd ..
$ ocamlopt -o main api.cmx abstract.cmx x.cmx sub/p.cmx
$ ./main
zsh: segmentation fault ./main

@vicuna

This comment has been minimized.

Copy link
Author

commented Mar 15, 2007

Comment author: @alainfrisch

Après discussion avec Nicolas et Benoit, proposition:

(1) interdire (comme le fait déjà ocamlopt) de linker deux modules avec le même nom;

(2) interdire le -pack si un des modules packés dépend d'un .cmi d'un module non packé dont la signature mentionne un des modules packés (dans l'exemple, le x.cmo packé dépend de api.cmi, dont la signature mentionne Abstract; or on packe un module de nom Abstract, d'où risque de collision).

Je pense que ça suffit.

@vicuna

This comment has been minimized.

Copy link
Author

commented Jan 11, 2012

Comment author: @lefessan

Je ferme ce bug report, car il a été ressoumis en anglais comme #5461

@vicuna

This comment has been minimized.

Copy link
Author

commented Jan 12, 2012

Comment author: @alainfrisch

As far as I can see, #5461 fixes only the bytecode case. In one the notes here, I give an example with ocamlopt, using -pack.

@vicuna

This comment has been minimized.

Copy link
Author

commented Jan 12, 2012

Comment author: @lefessan

Je suis d'accord, mais tu parles dans les commentaires de #5461 du problème avec -pack aussi. Du coup, je préférerais que les deux aspects soient traités dans l'autre bug en anglais. Ou alors, qu'on soumette un nouveau bug report pour le problème avec -pack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.