From 3f59e2e66fa40fe6a49ce65fc520aef6ea44ea7b Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Sat, 11 Feb 2023 14:35:36 +0100 Subject: 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. --- bytecomp/bytepackager.ml | 5 +++-- bytecomp/emitcode.ml | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'bytecomp') 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 -- cgit v1.2.1