Skip to content

Commit

Permalink
Fixes issue #48.
Browse files Browse the repository at this point in the history
This problem was due to the following issue in the OCaml compilers:

  http://caml.inria.fr/mantis/view.php?id=6661

This was actually already fixed by commits 33d2565, 4b27d7c and
b87e9ae. This previous fix was however incomplete (working
only for the byte-code versoin of Coccinelle) and hackish.

The current fix also works for the native-code version of
Coccinelle and does not rely on Makefile and sed tricks.
  • Loading branch information
shindere committed Feb 11, 2016
1 parent 892bf99 commit c7cf750
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 17 deletions.
1 change: 0 additions & 1 deletion ocaml/Makefile
Expand Up @@ -48,7 +48,6 @@ all.opt:

$(TARGET).cma: $(OBJS)
$(OCAMLC_CMD) -a -o $(TARGET).cma $(OBJS)
for i in `grep " (\*" exposed_modules.ml | sed "s/^.*(\* //" | sed "s/\..* \*)$$//"`; do cp ../$$i.cmi .; done

$(TARGET).cmxa: $(OPTOBJS) $(LIBS:.cma=.cmxa)
$(OCAMLOPT_CMD) -a -o $(TARGET).cmxa $(OPTOBJS)
Expand Down
42 changes: 26 additions & 16 deletions ocaml/exposed_modules.ml
@@ -1,22 +1,32 @@
(* Modules accessible by the ocaml scripts.
*)

module Ast_c = Ast_c (* parsing_c/ast_c.ml *)
module Parse_c = Parse_c (* parsing_c/parse_c.ml *)
module Parser_c = Parser_c (* parsing_c/parser_c.mly *)
module Lexer_c = Lexer_c (* parsing_c/lexer_c.mll *)
module Pretty_print_c = Pretty_print_c (* parsing_c/pretty_print_c.ml *)
module Lib_parsing_c = Lib_parsing_c (* parsing_c/lib_parsing_c.ml *)
module Visitor_c = Visitor_c (* parsing_c/visitor_c.ml *)
(*
We use
module Foo = struct include Bar end
rather than
module Foo = Bar
Because of an incompatible change in the interpretation of
module aliases introduced in OCaml 4.02.1.
See http://caml.inria.fr/mantis/view.php?id=6661
*)

module Regexp = Regexp (* globals/regexp.ml *)
module Config = Config (* globals/config.ml *)
module Flag = Flag (* globals/flag.ml *)
module Iteration = Iteration (* globals/iteration.ml *)
module Common = Common (* commons/common.ml *)
module Ast_c = struct include Ast_c end
module Parse_c = struct include Parse_c end
module Parser_c = struct include Parser_c end
module Lexer_c = struct include Lexer_c end
module Pretty_print_c = struct include Pretty_print_c end
module Lib_parsing_c = struct include Lib_parsing_c end
module Visitor_c = struct include Visitor_c end

module Ast_cocci = Ast_cocci (* parsing_cocci/ast_cocci.ml *)
module Ast0_cocci = Ast0_cocci (* parsing_cocci/ast0_cocci.ml *)
module Type_cocci = Type_cocci (* parsing_cocci/type_cocci.ml *)
module Regexp = struct include Regexp end
module Config = struct include Config end
module Flag = struct include Flag end
module Iteration = struct include Iteration end
module Common = struct include Common end

module Dumper = Dumper
module Ast_cocci = struct include Ast_cocci end
module Ast0_cocci = struct include Ast0_cocci end
module Type_cocci = struct include Type_cocci end

module Dumper = struct include Dumper end

1 comment on commit c7cf750

@elfring
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would appreciate a better commit title. Would you like to amend the commit message for this purpose?

It would also help to copy a bit of information from the referenced bug report "module alias breaks backward compatibility wrt separate compilation".

Please sign in to comment.