summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>2000-03-27 12:18:09 +0000
committerXavier Leroy <xavier.leroy@inria.fr>2000-03-27 12:18:09 +0000
commite0de38ba60c9d23cee1731d3fc3ecd278d19c47b (patch)
tree77ebf36dfdc45a76780a64a433c1b34b1d5acae0
parenta734dd4b75ddc4654e9619ae7df544508bb3dc0b (diff)
Adaptation au nouveau format de .cma, suite
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@2997 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r--bytecomp/bytelibrarian.ml32
-rw-r--r--tools/objinfo.ml16
-rw-r--r--tools/primreq.ml4
3 files changed, 41 insertions, 11 deletions
diff --git a/bytecomp/bytelibrarian.ml b/bytecomp/bytelibrarian.ml
index 25f463ac8..96708d5f6 100644
--- a/bytecomp/bytelibrarian.ml
+++ b/bytecomp/bytelibrarian.ml
@@ -24,6 +24,7 @@ type error =
exception Error of error
+(* Copy a compilation unit from a .cmo or .cma into the archive *)
let copy_compunit ic oc compunit =
seek_in ic compunit.cu_pos;
compunit.cu_pos <- pos_out oc;
@@ -35,6 +36,22 @@ let copy_compunit ic oc compunit =
copy_file_chunk ic oc compunit.cu_debugsize
end
+(* Add C objects and options and "custom" info from a library descriptor *)
+
+let lib_ccobjs = ref []
+let lib_ccopts = ref []
+
+(* See Bytelink.add_ccobjs for explanations on how options are ordered.
+ Notice that here we scan .cma files given on the command line from
+ left to right, hence options must be added after. *)
+
+let add_ccobjs l =
+ if not !Clflags.no_auto_link then begin
+ if l.lib_custom then Clflags.custom_runtime := true;
+ lib_ccobjs := !lib_ccobjs @ l.lib_ccobjs;
+ lib_ccopts := !lib_ccopts @ l.lib_ccopts
+ end
+
let copy_object_file oc name =
let file_name =
try
@@ -56,10 +73,11 @@ let copy_object_file oc name =
if buffer = cma_magic_number then begin
let toc_pos = input_binary_int ic in
seek_in ic toc_pos;
- let toc = (input_value ic : compilation_unit list) in
- List.iter (copy_compunit ic oc) toc;
+ let toc = (input_value ic : library) in
+ add_ccobjs toc;
+ List.iter (copy_compunit ic oc) toc.lib_units;
close_in ic;
- toc
+ toc.lib_units
end else
raise(Error(Not_an_object_file file_name))
with
@@ -72,12 +90,12 @@ let create_archive file_list lib_name =
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 toc =
- { lib_units =
- List.flatten(List.map (copy_object_file outchan) file_list);
+ { lib_units = units;
lib_custom = !Clflags.custom_runtime;
- lib_ccobjs = !Clflags.ccobjs;
- lib_ccopts = !Clflags.ccopts } in
+ lib_ccobjs = !Clflags.ccobjs @ !lib_ccobjs;
+ lib_ccopts = !Clflags.ccopts @ !lib_ccopts } in
let pos_toc = pos_out outchan in
output_value outchan toc;
seek_out outchan ofs_pos_toc;
diff --git a/tools/objinfo.ml b/tools/objinfo.ml
index b2ee3ee58..09f78b7f3 100644
--- a/tools/objinfo.ml
+++ b/tools/objinfo.ml
@@ -41,6 +41,18 @@ let print_info cu =
l
end
+let print_spaced_string s = print_char ' '; print_string s
+
+let print_library_info lib =
+ print_string " Force custom: ";
+ print_string (if lib.lib_custom then "YES" else "no");
+ print_newline();
+ print_string " Extra C object files:";
+ List.iter print_spaced_string lib.lib_ccobjs; print_newline();
+ print_string " Extra C options:";
+ List.iter print_spaced_string lib.lib_ccopts; print_newline();
+ List.iter print_info lib.lib_units
+
let print_intf_info name sign comps crcs =
print_string " Module name: "; print_string name; print_newline();
print_string " Interfaces imported:"; print_newline();
@@ -65,9 +77,9 @@ let dump_obj filename =
if buffer = cma_magic_number then begin
let toc_pos = input_binary_int ic in
seek_in ic toc_pos;
- let toc = (input_value ic : compilation_unit list) in
+ let toc = (input_value ic : library) in
close_in ic;
- List.iter print_info toc
+ print_library_info toc
end else
if buffer = cmi_magic_number then begin
let (name, sign, comps) = input_value ic in
diff --git a/tools/primreq.ml b/tools/primreq.ml
index 46aaf9463..cfd6e9af0 100644
--- a/tools/primreq.ml
+++ b/tools/primreq.ml
@@ -51,9 +51,9 @@ let scan_obj filename =
if buffer = cma_magic_number then begin
let toc_pos = input_binary_int ic in
seek_in ic toc_pos;
- let toc = (input_value ic : compilation_unit list) in
+ let toc = (input_value ic : library) in
close_in ic;
- List.iter scan_info toc
+ List.iter scan_info toc.lib_units
end else begin
prerr_endline "Not an object file"; exit 2
end