| Attached Files | 0001-PR-5461-an-incorrect-patch-to-fail-when-a-bytecode-c.patch [^] (3,450 bytes) 2012-01-03 14:28 [Show Content] [Hide Content]From d59eeca12744c098b5708375cc449b4a8b1b7b30 Mon Sep 17 00:00:00 2001
From: Gabriel Scherer <gabriel.scherer@inria.fr>
Date: Tue, 3 Jan 2012 14:18:49 +0100
Subject: [PATCH] PR#5461: an *incorrect* patch to fail when a bytecode comp.
unit is linked twice
This patches reproduces the `Multiple_definition` error from asmlink.ml into bytelink.ml.
It errors when multiple .cmo files claim to provide an implementation for the same module name.
However, it should not be accepted as is: when this error is
activated, compilation of OCaml itself fails. Indeed, at several
points of the build system, and .cmo is provided along with a .cma
archive that also contains it. This fails with this patch.
I'm not sure why this fails for bytecode compilation and not for the
native compiler. I think that the difference lies in the "is this
module necessary" detection logic. The native compiler relies on
implementation dependencies name (.cmx dependencies are recorded in
each .cmx), while the .cmo have access to no name information, so
infer the "is_required" property from the provided globals.
It might happen that, when a .cmo (respectively .cmx) is provided
along with a .cma (resp. .cmxa) that contains it, the native compiler
code only links the .cmx (the other not being "required"), while the
bytecode compiler, with its faulty "is_required" detection logic, try
to link both.
---
bytecomp/bytelink.ml | 16 +++++++++++++++-
bytecomp/bytelink.mli | 1 +
2 files changed, 16 insertions(+), 1 deletions(-)
diff --git a/bytecomp/bytelink.ml b/bytecomp/bytelink.ml
index 794a0ac..2834c82 100644
--- a/bytecomp/bytelink.ml
+++ b/bytecomp/bytelink.ml
@@ -28,6 +28,7 @@ type error =
| Custom_runtime
| File_exists of string
| Cannot_open_dll of string
+ | Multiple_definition of string * string * string
exception Error of error
@@ -161,9 +162,10 @@ let scan_file obj_name tolink =
(* Consistency check between interfaces *)
let crc_interfaces = Consistbl.create ()
+let implementations_defined = ref ([] : (string * string) list)
let check_consistency file_name cu =
- try
+ begin try
List.iter
(fun (name, crc) ->
if name = cu.cu_name
@@ -172,6 +174,14 @@ let check_consistency file_name cu =
cu.cu_imports
with Consistbl.Inconsistency(name, user, auth) ->
raise(Error(Inconsistent_import(name, user, auth)))
+ end;
+ begin try
+ let source = List.assoc cu.cu_name !implementations_defined in
+ raise (Error(Multiple_definition(cu.cu_name, file_name, source)))
+ with Not_found -> ()
+ end;
+ implementations_defined :=
+ (cu.cu_name, file_name) :: !implementations_defined
let extract_crc_interfaces () =
Consistbl.extract crc_interfaces
@@ -583,3 +593,7 @@ let report_error ppf = function
fprintf ppf "Cannot overwrite existing file %s" file
| Cannot_open_dll file ->
fprintf ppf "Error on dynamically loaded library: %s" file
+ | Multiple_definition(modname, file1, file2) ->
+ fprintf ppf
+ "@[<hov>Files %s@ and %s@ both define a module named %s@]"
+ file1 file2 modname
diff --git a/bytecomp/bytelink.mli b/bytecomp/bytelink.mli
index 375bde0..46bac58 100644
--- a/bytecomp/bytelink.mli
+++ b/bytecomp/bytelink.mli
@@ -28,6 +28,7 @@ type error =
| Custom_runtime
| File_exists of string
| Cannot_open_dll of string
+ | Multiple_definition of string * string * string
exception Error of error
--
1.7.7.3
2012-01-11-updated-patch-to-prevent-double-link-with-ocamlbuild.patch [^] (3,942 bytes) 2012-01-11 19:16 [Show Content] [Hide Content]Index: boot/ocamldep
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: boot/ocamllex
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: boot/ocamlc
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: bytecomp/bytelink.ml
===================================================================
--- bytecomp/bytelink.ml (revision 12007)
+++ bytecomp/bytelink.ml (working copy)
@@ -28,6 +28,7 @@
| Custom_runtime
| File_exists of string
| Cannot_open_dll of string
+ | Multiple_definition of string * string * string
exception Error of error
@@ -161,9 +162,10 @@
(* Consistency check between interfaces *)
let crc_interfaces = Consistbl.create ()
+let implementations_defined = ref ([] : (string * string) list)
let check_consistency file_name cu =
- try
+ begin try
List.iter
(fun (name, crc) ->
if name = cu.cu_name
@@ -172,6 +174,14 @@
cu.cu_imports
with Consistbl.Inconsistency(name, user, auth) ->
raise(Error(Inconsistent_import(name, user, auth)))
+ end;
+ begin try
+ let source = List.assoc cu.cu_name !implementations_defined in
+ raise (Error(Multiple_definition(cu.cu_name, file_name, source)))
+ with Not_found -> ()
+ end;
+ implementations_defined :=
+ (cu.cu_name, file_name) :: !implementations_defined
let extract_crc_interfaces () =
Consistbl.extract crc_interfaces
@@ -587,3 +597,7 @@
fprintf ppf "Cannot overwrite existing file %s" file
| Cannot_open_dll file ->
fprintf ppf "Error on dynamically loaded library: %s" file
+ | Multiple_definition(modname, file1, file2) ->
+ fprintf ppf
+ "@[<hov>Files %s@ and %s@ both define a module named %s@]"
+ file1 file2 modname
Index: bytecomp/bytelink.mli
===================================================================
--- bytecomp/bytelink.mli (revision 12007)
+++ bytecomp/bytelink.mli (working copy)
@@ -28,6 +28,7 @@
| Custom_runtime
| File_exists of string
| Cannot_open_dll of string
+ | Multiple_definition of string * string * string
exception Error of error
Index: build/camlp4-native-only.sh
===================================================================
--- build/camlp4-native-only.sh (revision 12007)
+++ build/camlp4-native-only.sh (working copy)
@@ -18,4 +18,8 @@
cd `dirname $0`/..
. build/targets.sh
set -x
-$OCAMLBUILD $@ native_stdlib_mixed_mode $OCAMLOPT_BYTE $OCAMLLEX_BYTE $CAMLP4_NATIVE
+
+# If you modify this list, modify it also in boot.sh
+STDLIB_MODULES='Pervasives,Arg,Array,Buffer,Char,Digest,Filename,Format,Hashtbl,Lazy,Lexing,List,Map,Printexc,Printf,Scanf,Set,String,Sys,Parsing,Int32,Int64,Nativeint,Obj,Queue,Sort,Stream,Stack'
+
+$OCAMLBUILD -ignore "$STDLIB_MODULES" $@ native_stdlib_mixed_mode $OCAMLOPT_BYTE $OCAMLLEX_BYTE $CAMLP4_NATIVE
Index: build/boot.sh
===================================================================
--- build/boot.sh (revision 12007)
+++ build/boot.sh (working copy)
@@ -16,11 +16,17 @@
cd `dirname $0`/..
set -ex
TAG_LINE='true: -use_stdlib'
+
+# If you modify this list, modify it also in camlp4-native-only.sh
+STDLIB_MODULES='Pervasives,Arg,Array,Buffer,Char,Digest,Filename,Format,Hashtbl,Lazy,Lexing,List,Map,Printexc,Printf,Scanf,Set,String,Sys,Parsing,Int32,Int64,Nativeint,Obj,Queue,Sort,Stream,Stack'
+
./boot/ocamlrun boot/myocamlbuild.boot \
+ -ignore "$STDLIB_MODULES" \
-tag-line "$TAG_LINE" \
boot/stdlib.cma boot/std_exit.cmo
boot/ocamlrun boot/myocamlbuild.boot \
+ -ignore "$STDLIB_MODULES" \
-tag-line "$TAG_LINE" -log _boot_log1 \
ocamlbuild/ocamlbuildlightlib.cma ocamlbuild/ocamlbuildlight.byte
2012-01-11-updated-patch-to-use-warning-31.patch [^] (30,507 bytes) 2012-01-11 20:07 [Show Content] [Hide Content]Index: driver/main.ml
===================================================================
--- driver/main.ml (revision 12007)
+++ driver/main.ml (working copy)
@@ -75,10 +75,12 @@
let usage = "Usage: ocamlc <options> <files>\nOptions are:"
+let ppf = Format.err_formatter
+
(* Error messages to standard error formatter *)
-let anonymous = process_file Format.err_formatter;;
-let impl = process_implementation_file Format.err_formatter;;
-let intf = process_interface_file Format.err_formatter;;
+let anonymous = process_file ppf;;
+let impl = process_implementation_file ppf;;
+let intf = process_interface_file ppf;;
let show_config () =
Config.print_config stdout;
@@ -170,14 +172,14 @@
if !make_archive then begin
Compile.init_path();
- Bytelibrarian.create_archive (List.rev !objfiles)
+ Bytelibrarian.create_archive ppf (List.rev !objfiles)
(extract_output !output_name)
end
else if !make_package then begin
Compile.init_path();
- let exctracted_output = extract_output !output_name in
- let revd = List.rev !objfiles in
- Bytepackager.package_files (revd)
+ let exctracted_output = extract_output !output_name in
+ let revd = List.rev !objfiles in
+ Bytepackager.package_files ppf (revd)
(exctracted_output)
end
else if not !compile_only && !objfiles <> [] then begin
@@ -198,11 +200,11 @@
default_output !output_name
in
Compile.init_path();
- Bytelink.link (List.rev !objfiles) target
+ Bytelink.link ppf (List.rev !objfiles) target
end;
exit 0
with x ->
- Errors.report_error Format.err_formatter x;
+ Errors.report_error ppf x;
exit 2
let _ = main ()
Index: boot/myocamlbuild.boot
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: boot/ocamldep
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: boot/ocamllex
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: boot/ocamlc
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: .depend
===================================================================
--- .depend (revision 12007)
+++ .depend (working copy)
@@ -101,8 +101,8 @@
typing/typemod.cmi: typing/types.cmi typing/typedtree.cmi \
parsing/parsetree.cmi parsing/longident.cmi parsing/location.cmi \
typing/includemod.cmi typing/ident.cmi typing/env.cmi
-typing/types.cmi: typing/primitive.cmi typing/path.cmi parsing/location.cmi \
- typing/ident.cmi parsing/asttypes.cmi
+typing/types.cmi: typing/primitive.cmi typing/path.cmi parsing/longident.cmi \
+ parsing/location.cmi typing/ident.cmi parsing/asttypes.cmi
typing/typetexp.cmi: typing/types.cmi typing/path.cmi parsing/parsetree.cmi \
parsing/longident.cmi parsing/location.cmi typing/env.cmi
typing/unused_var.cmi: parsing/parsetree.cmi
@@ -124,14 +124,14 @@
typing/btype.cmx parsing/asttypes.cmi typing/datarepr.cmi
typing/env.cmo: typing/types.cmi utils/tbl.cmi typing/subst.cmi \
typing/predef.cmi typing/path.cmi utils/misc.cmi parsing/longident.cmi \
- typing/ident.cmi typing/datarepr.cmi utils/consistbl.cmi utils/config.cmi \
- utils/clflags.cmi typing/btype.cmi parsing/asttypes.cmi typing/annot.cmi \
- typing/env.cmi
+ parsing/location.cmi typing/ident.cmi typing/datarepr.cmi \
+ utils/consistbl.cmi utils/config.cmi utils/clflags.cmi typing/btype.cmi \
+ parsing/asttypes.cmi typing/annot.cmi typing/env.cmi
typing/env.cmx: typing/types.cmx utils/tbl.cmx typing/subst.cmx \
typing/predef.cmx typing/path.cmx utils/misc.cmx parsing/longident.cmx \
- typing/ident.cmx typing/datarepr.cmx utils/consistbl.cmx utils/config.cmx \
- utils/clflags.cmx typing/btype.cmx parsing/asttypes.cmi typing/annot.cmi \
- typing/env.cmi
+ parsing/location.cmx typing/ident.cmx typing/datarepr.cmx \
+ utils/consistbl.cmx utils/config.cmx utils/clflags.cmx typing/btype.cmx \
+ parsing/asttypes.cmi typing/annot.cmi typing/env.cmi
typing/ident.cmo: typing/ident.cmi
typing/ident.cmx: typing/ident.cmi
typing/includeclass.cmo: typing/types.cmi typing/printtyp.cmi \
@@ -216,21 +216,23 @@
parsing/longident.cmx parsing/location.cmx typing/includeclass.cmx \
typing/ident.cmx typing/env.cmx typing/ctype.cmx utils/clflags.cmx \
typing/btype.cmx parsing/asttypes.cmi typing/typeclass.cmi
-typing/typecore.cmo: utils/warnings.cmi typing/typetexp.cmi typing/types.cmi \
- typing/typedtree.cmi typing/subst.cmi typing/stypes.cmi \
- typing/printtyp.cmi typing/primitive.cmi typing/predef.cmi \
- typing/path.cmi parsing/parsetree.cmi typing/parmatch.cmi \
- typing/oprint.cmi utils/misc.cmi parsing/longident.cmi \
- parsing/location.cmi typing/ident.cmi typing/env.cmi typing/ctype.cmi \
- utils/clflags.cmi typing/btype.cmi parsing/asttypes.cmi typing/annot.cmi \
+typing/typecore.cmo: utils/warnings.cmi typing/unused_var.cmi \
+ typing/typetexp.cmi typing/types.cmi typing/typedtree.cmi \
+ typing/subst.cmi typing/stypes.cmi typing/printtyp.cmi \
+ typing/primitive.cmi typing/predef.cmi typing/path.cmi \
+ parsing/parsetree.cmi typing/parmatch.cmi typing/oprint.cmi \
+ utils/misc.cmi parsing/longident.cmi parsing/location.cmi \
+ typing/ident.cmi typing/env.cmi typing/ctype.cmi utils/clflags.cmi \
+ typing/btype.cmi parsing/asttypes.cmi typing/annot.cmi \
typing/typecore.cmi
-typing/typecore.cmx: utils/warnings.cmx typing/typetexp.cmx typing/types.cmx \
- typing/typedtree.cmx typing/subst.cmx typing/stypes.cmx \
- typing/printtyp.cmx typing/primitive.cmx typing/predef.cmx \
- typing/path.cmx parsing/parsetree.cmi typing/parmatch.cmx \
- typing/oprint.cmx utils/misc.cmx parsing/longident.cmx \
- parsing/location.cmx typing/ident.cmx typing/env.cmx typing/ctype.cmx \
- utils/clflags.cmx typing/btype.cmx parsing/asttypes.cmi typing/annot.cmi \
+typing/typecore.cmx: utils/warnings.cmx typing/unused_var.cmx \
+ typing/typetexp.cmx typing/types.cmx typing/typedtree.cmx \
+ typing/subst.cmx typing/stypes.cmx typing/printtyp.cmx \
+ typing/primitive.cmx typing/predef.cmx typing/path.cmx \
+ parsing/parsetree.cmi typing/parmatch.cmx typing/oprint.cmx \
+ utils/misc.cmx parsing/longident.cmx parsing/location.cmx \
+ typing/ident.cmx typing/env.cmx typing/ctype.cmx utils/clflags.cmx \
+ typing/btype.cmx parsing/asttypes.cmi typing/annot.cmi \
typing/typecore.cmi
typing/typedecl.cmo: utils/warnings.cmi typing/typetexp.cmi typing/types.cmi \
typing/typedtree.cmi typing/subst.cmi typing/printtyp.cmi \
@@ -269,11 +271,11 @@
typing/env.cmx typing/ctype.cmx utils/config.cmx utils/clflags.cmx \
typing/btype.cmx parsing/asttypes.cmi typing/annot.cmi typing/typemod.cmi
typing/types.cmo: typing/primitive.cmi typing/path.cmi utils/misc.cmi \
- parsing/location.cmi typing/ident.cmi parsing/asttypes.cmi \
- typing/types.cmi
+ parsing/longident.cmi parsing/location.cmi typing/ident.cmi \
+ parsing/asttypes.cmi typing/types.cmi
typing/types.cmx: typing/primitive.cmx typing/path.cmx utils/misc.cmx \
- parsing/location.cmx typing/ident.cmx parsing/asttypes.cmi \
- typing/types.cmi
+ parsing/longident.cmx parsing/location.cmx typing/ident.cmx \
+ parsing/asttypes.cmi typing/types.cmi
typing/typetexp.cmo: utils/warnings.cmi typing/types.cmi utils/tbl.cmi \
typing/printtyp.cmi typing/path.cmi parsing/parsetree.cmi utils/misc.cmi \
parsing/longident.cmi parsing/location.cmi typing/env.cmi \
@@ -335,13 +337,15 @@
bytecomp/bytelibrarian.cmx: utils/misc.cmx utils/config.cmx \
bytecomp/cmo_format.cmi utils/clflags.cmx bytecomp/bytelink.cmx \
bytecomp/bytelibrarian.cmi
-bytecomp/bytelink.cmo: bytecomp/symtable.cmi bytecomp/opcodes.cmo \
- utils/misc.cmi bytecomp/instruct.cmi typing/ident.cmi bytecomp/dll.cmi \
+bytecomp/bytelink.cmo: utils/warnings.cmi bytecomp/symtable.cmi \
+ bytecomp/opcodes.cmo utils/misc.cmi parsing/location.cmi \
+ bytecomp/instruct.cmi typing/ident.cmi bytecomp/dll.cmi \
utils/consistbl.cmi utils/config.cmi bytecomp/cmo_format.cmi \
utils/clflags.cmi utils/ccomp.cmi bytecomp/bytesections.cmi \
bytecomp/bytelink.cmi
-bytecomp/bytelink.cmx: bytecomp/symtable.cmx bytecomp/opcodes.cmx \
- utils/misc.cmx bytecomp/instruct.cmx typing/ident.cmx bytecomp/dll.cmx \
+bytecomp/bytelink.cmx: utils/warnings.cmx bytecomp/symtable.cmx \
+ bytecomp/opcodes.cmx utils/misc.cmx parsing/location.cmx \
+ bytecomp/instruct.cmx typing/ident.cmx bytecomp/dll.cmx \
utils/consistbl.cmx utils/config.cmx bytecomp/cmo_format.cmi \
utils/clflags.cmx utils/ccomp.cmx bytecomp/bytesections.cmx \
bytecomp/bytelink.cmi
@@ -668,11 +672,11 @@
asmcomp/mach.cmx asmcomp/debuginfo.cmx asmcomp/cmm.cmx asmcomp/arch.cmx \
asmcomp/printmach.cmi
asmcomp/proc.cmo: asmcomp/reg.cmi utils/misc.cmi asmcomp/mach.cmi \
- utils/config.cmi asmcomp/cmm.cmi utils/ccomp.cmi asmcomp/arch.cmo \
- asmcomp/proc.cmi
+ utils/config.cmi asmcomp/cmm.cmi utils/clflags.cmi utils/ccomp.cmi \
+ asmcomp/arch.cmo asmcomp/proc.cmi
asmcomp/proc.cmx: asmcomp/reg.cmx utils/misc.cmx asmcomp/mach.cmx \
- utils/config.cmx asmcomp/cmm.cmx utils/ccomp.cmx asmcomp/arch.cmx \
- asmcomp/proc.cmi
+ utils/config.cmx asmcomp/cmm.cmx utils/clflags.cmx utils/ccomp.cmx \
+ asmcomp/arch.cmx asmcomp/proc.cmi
asmcomp/reg.cmo: asmcomp/cmm.cmi asmcomp/reg.cmi
asmcomp/reg.cmx: asmcomp/cmm.cmx asmcomp/reg.cmi
asmcomp/reload.cmo: asmcomp/reloadgen.cmi asmcomp/reg.cmi asmcomp/mach.cmi \
@@ -750,13 +754,13 @@
typing/env.cmx typing/ctype.cmx bytecomp/bytepackager.cmx \
bytecomp/bytelink.cmx bytecomp/bytelibrarian.cmx driver/errors.cmi
driver/main.cmo: utils/warnings.cmi utils/misc.cmi driver/main_args.cmi \
- driver/errors.cmi utils/config.cmi driver/compile.cmi utils/clflags.cmi \
- bytecomp/bytepackager.cmi bytecomp/bytelink.cmi \
- bytecomp/bytelibrarian.cmi driver/main.cmi
+ parsing/location.cmi driver/errors.cmi utils/config.cmi \
+ driver/compile.cmi utils/clflags.cmi bytecomp/bytepackager.cmi \
+ bytecomp/bytelink.cmi bytecomp/bytelibrarian.cmi driver/main.cmi
driver/main.cmx: utils/warnings.cmx utils/misc.cmx driver/main_args.cmx \
- driver/errors.cmx utils/config.cmx driver/compile.cmx utils/clflags.cmx \
- bytecomp/bytepackager.cmx bytecomp/bytelink.cmx \
- bytecomp/bytelibrarian.cmx driver/main.cmi
+ parsing/location.cmx driver/errors.cmx utils/config.cmx \
+ driver/compile.cmx utils/clflags.cmx bytecomp/bytepackager.cmx \
+ bytecomp/bytelink.cmx bytecomp/bytelibrarian.cmx driver/main.cmi
driver/main_args.cmo: utils/warnings.cmi driver/main_args.cmi
driver/main_args.cmx: utils/warnings.cmx driver/main_args.cmi
driver/optcompile.cmo: utils/warnings.cmi typing/unused_var.cmi \
@@ -791,14 +795,14 @@
asmcomp/asmgen.cmx driver/opterrors.cmi
driver/optmain.cmo: utils/warnings.cmi asmcomp/printmach.cmi \
driver/opterrors.cmi driver/optcompile.cmi utils/misc.cmi \
- driver/main_args.cmi utils/config.cmi utils/clflags.cmi \
- asmcomp/asmpackager.cmi asmcomp/asmlink.cmi asmcomp/asmlibrarian.cmi \
- asmcomp/arch.cmo driver/optmain.cmi
+ driver/main_args.cmi parsing/location.cmi utils/config.cmi \
+ utils/clflags.cmi asmcomp/asmpackager.cmi asmcomp/asmlink.cmi \
+ asmcomp/asmlibrarian.cmi asmcomp/arch.cmo driver/optmain.cmi
driver/optmain.cmx: utils/warnings.cmx asmcomp/printmach.cmx \
driver/opterrors.cmx driver/optcompile.cmx utils/misc.cmx \
- driver/main_args.cmx utils/config.cmx utils/clflags.cmx \
- asmcomp/asmpackager.cmx asmcomp/asmlink.cmx asmcomp/asmlibrarian.cmx \
- asmcomp/arch.cmx driver/optmain.cmi
+ driver/main_args.cmx parsing/location.cmx utils/config.cmx \
+ utils/clflags.cmx asmcomp/asmpackager.cmx asmcomp/asmlink.cmx \
+ asmcomp/asmlibrarian.cmx asmcomp/arch.cmx driver/optmain.cmi
driver/pparse.cmo: utils/misc.cmi parsing/location.cmi utils/clflags.cmi \
utils/ccomp.cmi driver/pparse.cmi
driver/pparse.cmx: utils/misc.cmx parsing/location.cmx utils/clflags.cmx \
@@ -863,12 +867,12 @@
asmcomp/asmlink.cmx asmcomp/asmgen.cmx toplevel/opttoploop.cmi
toplevel/opttopmain.cmo: utils/warnings.cmi asmcomp/printmach.cmi \
toplevel/opttoploop.cmi toplevel/opttopdirs.cmi driver/opterrors.cmi \
- utils/misc.cmi driver/main_args.cmi utils/config.cmi utils/clflags.cmi \
- toplevel/opttopmain.cmi
+ utils/misc.cmi driver/main_args.cmi parsing/location.cmi utils/config.cmi \
+ utils/clflags.cmi toplevel/opttopmain.cmi
toplevel/opttopmain.cmx: utils/warnings.cmx asmcomp/printmach.cmx \
toplevel/opttoploop.cmx toplevel/opttopdirs.cmx driver/opterrors.cmx \
- utils/misc.cmx driver/main_args.cmx utils/config.cmx utils/clflags.cmx \
- toplevel/opttopmain.cmi
+ utils/misc.cmx driver/main_args.cmx parsing/location.cmx utils/config.cmx \
+ utils/clflags.cmx toplevel/opttopmain.cmi
toplevel/opttopstart.cmo: toplevel/opttopmain.cmi
toplevel/opttopstart.cmx: toplevel/opttopmain.cmx
toplevel/topdirs.cmo: utils/warnings.cmi typing/types.cmi toplevel/trace.cmi \
@@ -909,10 +913,12 @@
bytecomp/bytegen.cmx typing/btype.cmx toplevel/toploop.cmi
toplevel/topmain.cmo: utils/warnings.cmi toplevel/toploop.cmi \
toplevel/topdirs.cmi utils/misc.cmi driver/main_args.cmi \
- driver/errors.cmi utils/config.cmi utils/clflags.cmi toplevel/topmain.cmi
+ parsing/location.cmi driver/errors.cmi utils/config.cmi utils/clflags.cmi \
+ toplevel/topmain.cmi
toplevel/topmain.cmx: utils/warnings.cmx toplevel/toploop.cmx \
toplevel/topdirs.cmx utils/misc.cmx driver/main_args.cmx \
- driver/errors.cmx utils/config.cmx utils/clflags.cmx toplevel/topmain.cmi
+ parsing/location.cmx driver/errors.cmx utils/config.cmx utils/clflags.cmx \
+ toplevel/topmain.cmi
toplevel/topstart.cmo: toplevel/topmain.cmi
toplevel/topstart.cmx: toplevel/topmain.cmx
toplevel/trace.cmo: typing/types.cmi toplevel/toploop.cmi typing/printtyp.cmi \
Index: bytecomp/bytepackager.mli
===================================================================
--- bytecomp/bytepackager.mli (revision 12007)
+++ bytecomp/bytepackager.mli (working copy)
@@ -15,7 +15,7 @@
(* "Package" a set of .cmo files into one .cmo file having the
original compilation units as sub-modules. *)
-val package_files: string list -> string -> unit
+val package_files: Format.formatter -> string list -> string -> unit
type error =
Forward_reference of string * Ident.t
Index: bytecomp/bytelink.ml
===================================================================
--- bytecomp/bytelink.ml (revision 12007)
+++ bytecomp/bytelink.ml (working copy)
@@ -29,6 +29,7 @@
| File_exists of string
| Cannot_open_dll of string
+
exception Error of error
type link_action =
@@ -161,9 +162,10 @@
(* Consistency check between interfaces *)
let crc_interfaces = Consistbl.create ()
+let implementations_defined = ref ([] : (string * string) list)
-let check_consistency file_name cu =
- try
+let check_consistency ppf file_name cu =
+ begin try
List.iter
(fun (name, crc) ->
if name = cu.cu_name
@@ -172,6 +174,15 @@
cu.cu_imports
with Consistbl.Inconsistency(name, user, auth) ->
raise(Error(Inconsistent_import(name, user, auth)))
+ end;
+ begin try
+ let source = List.assoc cu.cu_name !implementations_defined in
+ Location.print_warning (Location.in_file file_name) ppf
+ (Warnings.Multiple_definition(cu.cu_name, file_name, source))
+ with Not_found -> ()
+ end;
+ implementations_defined :=
+ (cu.cu_name, file_name) :: !implementations_defined
let extract_crc_interfaces () =
Consistbl.extract crc_interfaces
@@ -182,8 +193,8 @@
(* Link in a compilation unit *)
-let link_compunit output_fun currpos_fun inchan file_name compunit =
- check_consistency file_name compunit;
+let link_compunit ppf output_fun currpos_fun inchan file_name compunit =
+ check_consistency ppf file_name compunit;
seek_in inchan compunit.cu_pos;
let code_block = String.create compunit.cu_codesize in
really_input inchan code_block 0 compunit.cu_codesize;
@@ -200,10 +211,10 @@
(* Link in a .cmo file *)
-let link_object output_fun currpos_fun file_name compunit =
+let link_object ppf output_fun currpos_fun file_name compunit =
let inchan = open_in_bin file_name in
try
- link_compunit output_fun currpos_fun inchan file_name compunit;
+ link_compunit ppf output_fun currpos_fun inchan file_name compunit;
close_in inchan
with
Symtable.Error msg ->
@@ -213,14 +224,14 @@
(* Link in a .cma file *)
-let link_archive output_fun currpos_fun file_name units_required =
+let link_archive ppf output_fun currpos_fun file_name units_required =
let inchan = open_in_bin file_name in
try
List.iter
(fun cu ->
let name = file_name ^ "(" ^ cu.cu_name ^ ")" in
try
- link_compunit output_fun currpos_fun inchan name cu
+ link_compunit ppf output_fun currpos_fun inchan name cu
with Symtable.Error msg ->
raise(Error(Symbol_error(name, msg))))
units_required;
@@ -229,11 +240,11 @@
(* Link in a .cmo or .cma file *)
-let link_file output_fun currpos_fun = function
+let link_file ppf output_fun currpos_fun = function
Link_object(file_name, unit) ->
- link_object output_fun currpos_fun file_name unit
+ link_object ppf output_fun currpos_fun file_name unit
| Link_archive(file_name, units) ->
- link_archive output_fun currpos_fun file_name units
+ link_archive ppf output_fun currpos_fun file_name units
(* Output the debugging information *)
(* Format is:
@@ -265,7 +276,7 @@
(* Create a bytecode executable file *)
-let link_bytecode tolink exec_name standalone =
+let link_bytecode ppf tolink exec_name standalone =
Misc.remove_file exec_name; (* avoid permission problems, cf PR#1911 *)
let outchan =
open_out_gen [Open_wronly; Open_trunc; Open_creat; Open_binary]
@@ -303,7 +314,7 @@
end;
let output_fun = output_string outchan
and currpos_fun () = pos_out outchan - start_code in
- List.iter (link_file output_fun currpos_fun) tolink;
+ List.iter (link_file ppf output_fun currpos_fun) tolink;
if standalone then Dll.close_all_dlls();
(* The final STOP instruction *)
output_byte outchan Opcodes.opSTOP;
@@ -402,7 +413,7 @@
(* Output a bytecode executable as a C file *)
-let link_bytecode_as_c tolink outfile =
+let link_bytecode_as_c ppf tolink outfile =
let outchan = open_out outfile in
begin try
(* The bytecode *)
@@ -424,7 +435,7 @@
output_code_string outchan code;
currpos := !currpos + String.length code
and currpos_fun () = !currpos in
- List.iter (link_file output_fun currpos_fun) tolink;
+ List.iter (link_file ppf output_fun currpos_fun) tolink;
(* The final STOP instruction *)
Printf.fprintf outchan "\n0x%x};\n\n" Opcodes.opSTOP;
(* The table of global data *)
@@ -491,7 +502,7 @@
(* Main entry point (build a custom runtime if needed) *)
-let link objfiles output_name =
+let link ppf objfiles output_name =
let objfiles =
if !Clflags.nopervasives then objfiles
else if !Clflags.output_c_object then "stdlib.cma" :: objfiles
@@ -501,12 +512,12 @@
Clflags.ccopts := !lib_ccopts @ !Clflags.ccopts; (* put user's opts first *)
Clflags.dllibs := !lib_dllibs @ !Clflags.dllibs; (* put user's DLLs first *)
if not !Clflags.custom_runtime then
- link_bytecode tolink output_name true
+ link_bytecode ppf tolink output_name true
else if not !Clflags.output_c_object then begin
let bytecode_name = Filename.temp_file "camlcode" "" in
let prim_name = Filename.temp_file "camlprim" ".c" in
try
- link_bytecode tolink bytecode_name false;
+ link_bytecode ppf tolink bytecode_name false;
let poc = open_out prim_name in
output_string poc "\
#ifdef __cplusplus\n\
@@ -544,7 +555,7 @@
if Sys.file_exists c_file then raise(Error(File_exists c_file));
let temps = ref [] in
try
- link_bytecode_as_c tolink c_file;
+ link_bytecode_as_c ppf tolink c_file;
if not (Filename.check_suffix output_name ".c") then begin
temps := c_file :: !temps;
if Ccomp.compile_file c_file <> 0 then raise(Error Custom_runtime);
Index: bytecomp/bytelibrarian.ml
===================================================================
--- bytecomp/bytelibrarian.ml (revision 12007)
+++ bytecomp/bytelibrarian.ml (working copy)
@@ -55,7 +55,7 @@
lib_dllibs := !lib_dllibs @ l.lib_dllibs
end
-let copy_object_file oc name =
+let copy_object_file ppf oc name =
let file_name =
try
find_in_path !load_path name
@@ -69,7 +69,7 @@
let compunit_pos = input_binary_int ic in
seek_in ic compunit_pos;
let compunit = (input_value ic : compilation_unit) in
- Bytelink.check_consistency file_name compunit;
+ Bytelink.check_consistency ppf file_name compunit;
copy_compunit ic oc compunit;
close_in ic;
[compunit]
@@ -78,7 +78,7 @@
let toc_pos = input_binary_int ic in
seek_in ic toc_pos;
let toc = (input_value ic : library) in
- List.iter (Bytelink.check_consistency file_name) toc.lib_units;
+ List.iter (Bytelink.check_consistency ppf file_name) toc.lib_units;
add_ccobjs toc;
List.iter (copy_compunit ic oc) toc.lib_units;
close_in ic;
@@ -89,13 +89,13 @@
End_of_file -> close_in ic; raise(Error(Not_an_object_file file_name))
| x -> close_in ic; raise x
-let create_archive file_list lib_name =
+let create_archive ppf file_list lib_name =
let outchan = open_out_bin lib_name in
try
output_string outchan cma_magic_number;
let ofs_pos_toc = pos_out outchan in
output_binary_int outchan 0;
- let units = List.flatten(List.map (copy_object_file outchan) file_list) in
+ let units = List.flatten(List.map (copy_object_file ppf outchan) file_list) in
let toc =
{ lib_units = units;
lib_custom = !Clflags.custom_runtime;
Index: bytecomp/bytelink.mli
===================================================================
--- bytecomp/bytelink.mli (revision 12007)
+++ bytecomp/bytelink.mli (working copy)
@@ -14,9 +14,9 @@
(* Link .cmo files and produce a bytecode executable. *)
-val link: string list -> string -> unit
+val link : Format.formatter -> string list -> string -> unit
-val check_consistency: string -> Cmo_format.compilation_unit -> unit
+val check_consistency: Format.formatter -> string -> Cmo_format.compilation_unit -> unit
val extract_crc_interfaces: unit -> (string * Digest.t) list
Index: bytecomp/bytelibrarian.mli
===================================================================
--- bytecomp/bytelibrarian.mli (revision 12007)
+++ bytecomp/bytelibrarian.mli (working copy)
@@ -21,7 +21,7 @@
content table = list of compilation units
*)
-val create_archive: string list -> string -> unit
+val create_archive: Format.formatter -> string list -> string -> unit
type error =
File_not_found of string
Index: bytecomp/bytepackager.ml
===================================================================
--- bytecomp/bytepackager.ml (revision 12007)
+++ bytecomp/bytepackager.ml (working copy)
@@ -124,10 +124,10 @@
Accumulate relocs, debug info, etc.
Return size of bytecode. *)
-let rename_append_bytecode packagename oc mapping defined ofs prefix subst objfile compunit =
+let rename_append_bytecode ppf packagename oc mapping defined ofs prefix subst objfile compunit =
let ic = open_in_bin objfile in
try
- Bytelink.check_consistency objfile compunit;
+ Bytelink.check_consistency ppf objfile compunit;
List.iter
(rename_relocation packagename objfile mapping defined ofs)
compunit.cu_reloc;
@@ -148,20 +148,20 @@
(* Same, for a list of .cmo and .cmi files.
Return total size of bytecode. *)
-let rec rename_append_bytecode_list packagename oc mapping defined ofs prefix subst = function
+let rec rename_append_bytecode_list ppf packagename oc mapping defined ofs prefix subst = function
[] ->
ofs
| m :: rem ->
match m.pm_kind with
| PM_intf ->
- rename_append_bytecode_list packagename oc mapping defined ofs prefix subst rem
+ rename_append_bytecode_list ppf packagename oc mapping defined ofs prefix subst rem
| PM_impl compunit ->
let size =
- rename_append_bytecode packagename oc mapping defined ofs prefix subst
+ rename_append_bytecode ppf packagename oc mapping defined ofs prefix subst
m.pm_file compunit in
let id = Ident.create_persistent m.pm_name in
let root = Path.Pident (Ident.create_persistent prefix) in
- rename_append_bytecode_list packagename
+ rename_append_bytecode_list ppf packagename
oc mapping (id :: defined)
(ofs + size) prefix (Subst.add_module id (Path.Pdot (root, Ident.name id, Path.nopos)) subst) rem
@@ -186,7 +186,7 @@
(* Build the .cmo file obtained by packaging the given .cmo files. *)
-let package_object_files files targetfile targetname coercion =
+let package_object_files ppf files targetfile targetname coercion =
let members =
map_left_right read_member_info files in
let unit_names =
@@ -203,7 +203,7 @@
let pos_depl = pos_out oc in
output_binary_int oc 0;
let pos_code = pos_out oc in
- let ofs = rename_append_bytecode_list targetname oc mapping [] 0 targetname Subst.identity members in
+ let ofs = rename_append_bytecode_list ppf targetname oc mapping [] 0 targetname Subst.identity members in
build_global_target oc targetname members mapping ofs coercion;
let pos_debug = pos_out oc in
if !Clflags.debug && !events <> [] then
@@ -233,7 +233,7 @@
(* The entry point *)
-let package_files files targetfile =
+let package_files ppf files targetfile =
let files =
List.map
(fun f ->
@@ -245,7 +245,7 @@
let targetname = String.capitalize(Filename.basename prefix) in
try
let coercion = Typemod.package_units files targetcmi targetname in
- let ret = package_object_files files targetfile targetname coercion in
+ let ret = package_object_files ppf files targetfile targetname coercion in
ret
with x ->
remove_file targetfile; raise x
Index: build/camlp4-native-only.sh
===================================================================
--- build/camlp4-native-only.sh (revision 12007)
+++ build/camlp4-native-only.sh (working copy)
@@ -18,4 +18,8 @@
cd `dirname $0`/..
. build/targets.sh
set -x
-$OCAMLBUILD $@ native_stdlib_mixed_mode $OCAMLOPT_BYTE $OCAMLLEX_BYTE $CAMLP4_NATIVE
+
+# If you modify this list, modify it also in boot.sh
+STDLIB_MODULES='Pervasives,Arg,Array,Buffer,Char,Digest,Filename,Format,Hashtbl,Lazy,Lexing,List,Map,Printexc,Printf,Scanf,Set,String,Sys,Parsing,Int32,Int64,Nativeint,Obj,Queue,Sort,Stream,Stack'
+
+$OCAMLBUILD -ignore "$STDLIB_MODULES" $@ native_stdlib_mixed_mode $OCAMLOPT_BYTE $OCAMLLEX_BYTE $CAMLP4_NATIVE
Index: build/boot.sh
===================================================================
--- build/boot.sh (revision 12007)
+++ build/boot.sh (working copy)
@@ -16,11 +16,17 @@
cd `dirname $0`/..
set -ex
TAG_LINE='true: -use_stdlib'
+
+# If you modify this list, modify it also in camlp4-native-only.sh
+STDLIB_MODULES='Pervasives,Arg,Array,Buffer,Char,Digest,Filename,Format,Hashtbl,Lazy,Lexing,List,Map,Printexc,Printf,Scanf,Set,String,Sys,Parsing,Int32,Int64,Nativeint,Obj,Queue,Sort,Stream,Stack'
+
./boot/ocamlrun boot/myocamlbuild.boot \
+ -ignore "$STDLIB_MODULES" \
-tag-line "$TAG_LINE" \
boot/stdlib.cma boot/std_exit.cmo
boot/ocamlrun boot/myocamlbuild.boot \
+ -ignore "$STDLIB_MODULES" \
-tag-line "$TAG_LINE" -log _boot_log1 \
ocamlbuild/ocamlbuildlightlib.cma ocamlbuild/ocamlbuildlight.byte
Index: utils/warnings.ml
===================================================================
--- utils/warnings.ml (revision 12007)
+++ utils/warnings.ml (working copy)
@@ -50,6 +50,7 @@
| Wildcard_arg_to_constant_constr (* 28 *)
| Eol_in_string (* 29 *)
| Duplicate_definitions of string * string * string * string (*30 *)
+ | Multiple_definition of string * string * string (* 31 *)
;;
(* If you remove a warning, leave a hole in the numbering. NEVER change
@@ -89,9 +90,10 @@
| Wildcard_arg_to_constant_constr -> 28
| Eol_in_string -> 29
| Duplicate_definitions _ -> 30
+ | Multiple_definition _ -> 31
;;
-let last_warning_number = 30;;
+let last_warning_number = 31;;
(* Must be the max number returned by the [number] function. *)
let letter = function
@@ -260,6 +262,10 @@
| Duplicate_definitions (kind, cname, tc1, tc2) ->
Printf.sprintf "the %s %s is defined in both types %s and %s."
kind cname tc1 tc2
+ | Multiple_definition(modname, file1, file2) ->
+ Printf.sprintf
+ "files %s and %s both define a module named %s"
+ file1 file2 modname
;;
let nerrors = ref 0;;
@@ -334,6 +340,7 @@
29, "Unescaped end-of-line in a string constant (non-portable code).";
30, "Two labels or constructors of the same name are defined in two\n\
\ mutually recursive types.";
+ 31, "A module is linked twice in the same executable";
]
;;
Index: utils/warnings.mli
===================================================================
--- utils/warnings.mli (revision 12007)
+++ utils/warnings.mli (working copy)
@@ -45,6 +45,7 @@
| Wildcard_arg_to_constant_constr (* 28 *)
| Eol_in_string (* 29 *)
| Duplicate_definitions of string * string * string * string (*30 *)
+ | Multiple_definition of string * string * string (* 31 *)
;;
val parse_options : bool -> string -> unit;;
warning_31.log [^] (4,021 bytes) 2012-02-10 15:29 |