summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@college-de-france.fr>2023-02-11 14:35:36 +0100
committerXavier Leroy <xavier.leroy@college-de-france.fr>2023-02-26 15:58:40 +0100
commit3f59e2e66fa40fe6a49ce65fc520aef6ea44ea7b (patch)
treef3d8d86ba7a70014949966b3de73f988603f0fec
parentd1d0d85c67cfa2478476a31d43c3f962f38e13b9 (diff)
downloadocaml-3f59e2e66fa40fe6a49ce65fc520aef6ea44ea7b.tar.gz
Use compressed marshaling to write .cmt, .cmti, .cmi, .cmo, .cma files
For .cmi, .cmt and .cmti files, the resulting files are 35-40% the size of the uncompressed files. For .cmo and .cma files, we compress only the debug info; this gives 50% space savings for files with full debug info.
-rw-r--r--bytecomp/bytepackager.ml5
-rw-r--r--bytecomp/emitcode.ml5
-rw-r--r--file_formats/cmi_format.ml2
-rw-r--r--file_formats/cmt_format.ml2
4 files changed, 8 insertions, 6 deletions
diff --git a/bytecomp/bytepackager.ml b/bytecomp/bytepackager.ml
index 449d423252..4ff00f2967 100644
--- a/bytecomp/bytepackager.ml
+++ b/bytecomp/bytepackager.ml
@@ -272,8 +272,9 @@ let package_object_files ~ppf_dump files targetfile targetname coercion =
build_global_target ~ppf_dump oc targetname state components coercion in
let pos_debug = pos_out oc in
if !Clflags.debug && state.events <> [] then begin
- output_value oc (List.rev state.events);
- output_value oc (String.Set.elements state.debug_dirs);
+ Marshal.(to_channel oc (List.rev state.events) [Compression]);
+ Marshal.(to_channel oc (String.Set.elements state.debug_dirs)
+ [Compression]);
end;
let force_link =
List.exists (function
diff --git a/bytecomp/emitcode.ml b/bytecomp/emitcode.ml
index 9e70bebd9c..bd3c3f2fb5 100644
--- a/bytecomp/emitcode.ml
+++ b/bytecomp/emitcode.ml
@@ -416,8 +416,9 @@ let to_file outchan unit_name objfile ~required_globals code =
(Filename.dirname (Location.absolute_path objfile))
!debug_dirs;
let p = pos_out outchan in
- output_value outchan !events;
- output_value outchan (String.Set.elements !debug_dirs);
+ Marshal.(to_channel outchan !events [Compression]);
+ Marshal.(to_channel outchan (String.Set.elements !debug_dirs)
+ [Compression]);
(p, pos_out outchan - p)
end else
(0, 0) in
diff --git a/file_formats/cmi_format.ml b/file_formats/cmi_format.ml
index bd82cc3761..aa3d6777a0 100644
--- a/file_formats/cmi_format.ml
+++ b/file_formats/cmi_format.ml
@@ -84,7 +84,7 @@ let read_cmi filename =
let output_cmi filename oc cmi =
(* beware: the provided signature must have been substituted for saving *)
output_string oc Config.cmi_magic_number;
- output_value oc ((cmi.cmi_name, cmi.cmi_sign) : header);
+ Marshal.(to_channel oc ((cmi.cmi_name, cmi.cmi_sign) : header) [Compression]);
flush oc;
let crc = Digest.file filename in
let crcs = (cmi.cmi_name, Some crc) :: cmi.cmi_crcs in
diff --git a/file_formats/cmt_format.ml b/file_formats/cmt_format.ml
index a493780e5a..8fa01e525b 100644
--- a/file_formats/cmt_format.ml
+++ b/file_formats/cmt_format.ml
@@ -109,7 +109,7 @@ let input_cmt ic = (input_value ic : cmt_infos)
let output_cmt oc cmt =
output_string oc Config.cmt_magic_number;
- output_value oc (cmt : cmt_infos)
+ Marshal.(to_channel oc (cmt : cmt_infos) [Compression])
let read filename =
(* Printf.fprintf stderr "Cmt_format.read %s\n%!" filename; *)