Skip to content

Commit d37de27

Browse files
committed
improve the robustness of devbuild
- no cycle for cmi/cmj data sets - not encoding version into cmi/cmj, when reading internals, it is already too late to detect
1 parent a094cdb commit d37de27

27 files changed

+241723
-238499
lines changed

jscomp/core/bs_cmi_load.ml

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* along with this program; if not, write to the Free Software
2323
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2424

25-
25+
#if BS_RELEASE_BUILD then
2626

2727
let load_cmi ~unit_name : Env.Persistent_signature.t option =
2828
match Config_util.find_opt (unit_name ^".cmi") with
@@ -40,3 +40,32 @@ let load_cmi ~unit_name : Env.Persistent_signature.t option =
4040
Some {filename = Sys.executable_name ;
4141
cmi }
4242
| None -> None
43+
44+
let check () =
45+
Ext_array.iter
46+
Builtin_cmi_datasets.module_sets_cmi
47+
(fun (name,l) ->
48+
prerr_endline (">checking " ^ name);
49+
let cmi = Lazy.force l in
50+
(match cmi.cmi_crcs with
51+
| (unit , Some digest) :: _ ->
52+
Format.fprintf Format.err_formatter "%s -> %s@." unit (Digest.to_hex digest)
53+
| _ -> ());
54+
prerr_endline ("<checking " ^ name);
55+
);
56+
Ext_array.iter
57+
Builtin_cmj_datasets.module_sets
58+
(fun (name,l) ->
59+
prerr_endline (">checking " ^ name);
60+
let cmj = Lazy.force l in
61+
Format.fprintf Format.err_formatter "%b@." cmj.pure;
62+
prerr_endline ("<checking " ^ name);
63+
)
64+
#else
65+
66+
let check () = ()
67+
let load_cmi ~unit_name : Env.Persistent_signature.t option =
68+
match Config_util.find_opt (unit_name ^".cmi") with
69+
| Some filename -> Some {filename; cmi = Cmi_format.read_cmi filename}
70+
| None -> None
71+
#end

jscomp/core/builtin_check.ml

Lines changed: 0 additions & 53 deletions
This file was deleted.

jscomp/core/js_cmj_load.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131

3232
let load_builin_unit unit_name : Js_cmj_format.cmj_load_info =
33+
#if BS_RELEASE_BUILD then
3334
match Ext_string_array.find_sorted_assoc
3435
Builtin_cmj_datasets.module_sets
3536
unit_name with
@@ -43,7 +44,8 @@ let load_builin_unit unit_name : Js_cmj_format.cmj_load_info =
4344
{package_path =
4445
Filename.dirname (Filename.dirname Sys.executable_name); cmj_table}
4546
| None
46-
->
47+
->
48+
#end
4749
Bs_exception.error (Cmj_not_found unit_name)
4850
(*
4951
let load_unit_no_file unit_name : Js_cmj_format.cmj_load_info =

jscomp/core/builtin_cmi_datasets.ml renamed to jscomp/main/builtin_cmi_datasets.ml

Lines changed: 162 additions & 162 deletions
Large diffs are not rendered by default.

jscomp/main/cmij_main.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ let () =
132132
get_files Literals.suffix_cmj stdlib @
133133
get_files Literals.suffix_cmj "others") in
134134
from_cmj cmj_files
135-
(Filename.concat "core" "builtin_cmj_datasets.ml");
135+
(Filename.concat "main" "builtin_cmj_datasets.ml");
136136
let cmi_files =
137137
"runtime" // "js.cmi" ::
138138
(get_files Literals.suffix_cmi stdlib @
@@ -143,5 +143,5 @@ let () =
143143
not (x |~ "internal"))
144144
in
145145
from_cmi cmi_files
146-
(Filename.concat "core" "builtin_cmi_datasets.ml")
146+
(Filename.concat "main" "builtin_cmi_datasets.ml")
147147

jscomp/main/js_main.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ let buckle_script_flags : (string * Arg.spec * string) list =
209209
("-nostdlib", Arg.Set Js_config.no_stdlib,
210210
" Don't use stdlib")
211211
::
212-
("-bs-internal-check", Arg.Unit (Builtin_check.check ),
212+
("-bs-internal-check", Arg.Unit (Bs_cmi_load.check ),
213213
" Built in check corrupted data"
214214
)
215215
::

jscomp/snapshot.ninja

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ rule bspack
33
command = ./bin/bspack.exe $flags -bs-main $main -o $out $post_process
44
depfile = $out.d
55
generator = true
6-
6+
native_ocaml_path = ../ocaml/
7+
snapshot_path = 4.06.1
78
LTO= ../scripts/buckle_lto.js
89
OCAML_SRC_UTILS=$native_ocaml_path/utils
910
OCAML_SRC_PARSING=$native_ocaml_path/parsing
@@ -67,6 +68,8 @@ build $SNAP/unstable/js_compiler.ml: bspack | ./bin/bspack.exe
6768
build $SNAP/unstable/js_refmt_compiler.ml: bspack | ./bin/bspack.exe
6869
flags = -D BS_BROWSER=true -D BS_RELEASE_BUILD=true -bs-MD -module-alias Config=Config_whole_compiler -bs-exclude-I config -I $OCAML_SRC_UTILS -I $OCAML_SRC_PARSING -I $OCAML_SRC_TYPING -I $OCAML_SRC_BYTECOMP -I $OCAML_SRC_DRIVER -I js_parser -I stubs -I ext -I syntax -I depends -I common -I core -I super_errors -I bsb -I outcome_printer -I js_parser -I main -I refmt
6970
main = Jsoo_refmt_main
71+
72+
subninja build.ninja
7073
# -o $@
7174
# Check it later
7275
# rule bsbnative

0 commit comments

Comments
 (0)