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

+30-1
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

-53
This file was deleted.

jscomp/core/js_cmj_load.ml

+3-1
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 jscomp/main/builtin_cmi_datasets.ml

+162-162
Large diffs are not rendered by default.
File renamed without changes.
File renamed without changes.
File renamed without changes.

jscomp/main/cmij_main.ml

+2-2
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

+1-1
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

+4-1
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

jscomp/syntax/ast_exp_extension.ml

+4-9
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,12 @@ let rec unroll_function_aux
5252
type t = { args : string list ; block : string }
5353

5454
let toString (x : t) =
55-
Bs_version.version ^ Marshal.to_string x []
55+
Marshal.to_string x []
5656

5757
(* exception handling*)
58-
let fromString (x : string) : t =
59-
if Ext_string.starts_with x Bs_version.version then
60-
Marshal.from_string x (String.length Bs_version.version)
61-
else
62-
Ext_fmt.failwithf
63-
~loc:__LOC__
64-
"Compiler version mismatch. The project might have been built with one version of BuckleScript, and then with another. Please wipe the artifacts and do a clean build."
65-
58+
let fromString (x : string) : t =
59+
Marshal.from_string x 0
60+
6661
let handle_extension record_as_js_object e (self : Bs_ast_mapper.mapper)
6762
(({txt ; loc} as lid , payload) : Parsetree.extension) =
6863
begin match txt with

jscomp/syntax/external_ffi_types.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ let bs_prefix_length = String.length bs_prefix
257257
1. fixed length
258258
2. non-prefix approach
259259
*)
260-
let bs_external = bs_prefix ^ Bs_version.version
260+
let bs_external = bs_prefix
261261

262262

263263
let bs_external_length = String.length bs_external

lib/4.06.1/bsdep.ml

+42,094-38,737
Large diffs are not rendered by default.

lib/4.06.1/bsdep.ml.d

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../lib/4.06.1/bsdep.ml: ../ocaml/driver/compdynlink.mli ../ocaml/driver/compenv.ml ../ocaml/driver/compenv.mli ../ocaml/driver/compmisc.ml ../ocaml/driver/compmisc.mli ../ocaml/driver/compplugin.ml ../ocaml/driver/compplugin.mli ../ocaml/driver/makedepend.ml ../ocaml/driver/makedepend.mli ../ocaml/driver/pparse.ml ../ocaml/driver/pparse.mli ../ocaml/parsing/ast_helper.ml ../ocaml/parsing/ast_helper.mli ../ocaml/parsing/ast_invariants.ml ../ocaml/parsing/ast_invariants.mli ../ocaml/parsing/ast_iterator.ml ../ocaml/parsing/ast_iterator.mli ../ocaml/parsing/ast_mapper.ml ../ocaml/parsing/ast_mapper.mli ../ocaml/parsing/asttypes.mli ../ocaml/parsing/builtin_attributes.ml ../ocaml/parsing/builtin_attributes.mli ../ocaml/parsing/depend.ml ../ocaml/parsing/depend.mli ../ocaml/parsing/docstrings.ml ../ocaml/parsing/docstrings.mli ../ocaml/parsing/lexer.ml ../ocaml/parsing/lexer.mli ../ocaml/parsing/location.ml ../ocaml/parsing/location.mli ../ocaml/parsing/longident.ml ../ocaml/parsing/longident.mli ../ocaml/parsing/parse.ml ../ocaml/parsing/parse.mli ../ocaml/parsing/parser.ml ../ocaml/parsing/parser.mli ../ocaml/parsing/parsetree.mli ../ocaml/parsing/syntaxerr.ml ../ocaml/parsing/syntaxerr.mli ../ocaml/tools/ocamldep.ml ../ocaml/utils/arg_helper.ml ../ocaml/utils/arg_helper.mli ../ocaml/utils/ccomp.ml ../ocaml/utils/ccomp.mli ../ocaml/utils/clflags.ml ../ocaml/utils/clflags.mli ../ocaml/utils/identifiable.ml ../ocaml/utils/identifiable.mli ../ocaml/utils/misc.ml ../ocaml/utils/misc.mli ../ocaml/utils/numbers.ml ../ocaml/utils/numbers.mli ../ocaml/utils/profile.ml ../ocaml/utils/profile.mli ../ocaml/utils/terminfo.ml ../ocaml/utils/terminfo.mli ../ocaml/utils/warnings.ml ../ocaml/utils/warnings.mli ./common/bs_loc.ml ./common/bs_loc.mli ./common/bs_version.ml ./common/bs_version.mli ./common/bs_warnings.ml ./common/bs_warnings.mli ./common/js_config.ml ./common/js_config.mli ./common/lam_methname.ml ./common/lam_methname.mli ./core/bs_cmi_load.ml ./core/bs_conditional_initial.ml ./core/bs_conditional_initial.mli ./core/builtin_cmi_datasets.ml ./core/builtin_cmi_datasets.mli ./core/config_util.ml ./core/config_util.mli ./core/config_whole_compiler.ml ./core/config_whole_compiler.mli ./core/js_raw_info.ml ./core/lam_constant.ml ./core/lam_constant.mli ./core/lam_pointer_info.ml ./core/lam_pointer_info.mli ./core/lam_tag_info.ml ./core/matching_polyfill.ml ./core/matching_polyfill.mli ./core/record_attributes_check.ml ./ext/bsc_warnings.ml ./ext/ext_array.ml ./ext/ext_array.mli ./ext/ext_bytes.ml ./ext/ext_bytes.mli ./ext/ext_char.ml ./ext/ext_char.mli ./ext/ext_filename.ml ./ext/ext_filename.mli ./ext/ext_fmt.ml ./ext/ext_json_parse.ml ./ext/ext_json_parse.mli ./ext/ext_json_types.ml ./ext/ext_list.ml ./ext/ext_list.mli ./ext/ext_option.ml ./ext/ext_option.mli ./ext/ext_pervasives.ml ./ext/ext_pervasives.mli ./ext/ext_position.ml ./ext/ext_position.mli ./ext/ext_ref.ml ./ext/ext_ref.mli ./ext/ext_string.ml ./ext/ext_string.mli ./ext/ext_string_array.ml ./ext/ext_string_array.mli ./ext/ext_utf8.ml ./ext/ext_utf8.mli ./ext/ext_util.ml ./ext/ext_util.mli ./ext/hash_set_gen.ml ./ext/hash_set_poly.ml ./ext/hash_set_poly.mli ./ext/hash_set_string.ml ./ext/hash_set_string.mli ./ext/literals.ml ./ext/literals.mli ./ext/map_gen.ml ./ext/map_string.ml ./ext/map_string.mli ./ext/set_gen.ml ./ext/set_string.ml ./ext/set_string.mli ./stubs/bs_hash_stubs.ml ./syntax/ast_attributes.ml ./syntax/ast_attributes.mli ./syntax/ast_bs_open.ml ./syntax/ast_bs_open.mli ./syntax/ast_comb.ml ./syntax/ast_comb.mli ./syntax/ast_compatible.ml ./syntax/ast_compatible.mli ./syntax/ast_core_type.ml ./syntax/ast_core_type.mli ./syntax/ast_core_type_class_type.ml ./syntax/ast_core_type_class_type.mli ./syntax/ast_derive.ml ./syntax/ast_derive.mli ./syntax/ast_derive_abstract.ml ./syntax/ast_derive_abstract.mli ./syntax/ast_derive_js_mapper.ml ./syntax/ast_derive_js_mapper.mli ./syntax/ast_derive_projector.ml ./syntax/ast_derive_projector.mli ./syntax/ast_derive_util.ml ./syntax/ast_derive_util.mli ./syntax/ast_exp.ml ./syntax/ast_exp.mli ./syntax/ast_exp_apply.ml ./syntax/ast_exp_apply.mli ./syntax/ast_exp_extension.ml ./syntax/ast_exp_extension.mli ./syntax/ast_exp_handle_external.ml ./syntax/ast_exp_handle_external.mli ./syntax/ast_external.ml ./syntax/ast_external.mli ./syntax/ast_external_mk.ml ./syntax/ast_external_mk.mli ./syntax/ast_external_process.ml ./syntax/ast_external_process.mli ./syntax/ast_literal.ml ./syntax/ast_literal.mli ./syntax/ast_open_cxt.ml ./syntax/ast_open_cxt.mli ./syntax/ast_pat.ml ./syntax/ast_pat.mli ./syntax/ast_payload.ml ./syntax/ast_payload.mli ./syntax/ast_polyvar.ml ./syntax/ast_polyvar.mli ./syntax/ast_signature.ml ./syntax/ast_signature.mli ./syntax/ast_structure.ml ./syntax/ast_structure.mli ./syntax/ast_tdcls.ml ./syntax/ast_tdcls.mli ./syntax/ast_tuple_pattern_flatten.ml ./syntax/ast_tuple_pattern_flatten.mli ./syntax/ast_typ_uncurry.ml ./syntax/ast_typ_uncurry.mli ./syntax/ast_utf8_string.ml ./syntax/ast_utf8_string.mli ./syntax/ast_utf8_string_interp.ml ./syntax/ast_utf8_string_interp.mli ./syntax/ast_util.ml ./syntax/ast_util.mli ./syntax/bs_ast_invariant.ml ./syntax/bs_ast_invariant.mli ./syntax/bs_ast_mapper.ml ./syntax/bs_ast_mapper.mli ./syntax/bs_builtin_ppx.ml ./syntax/bs_builtin_ppx.mli ./syntax/bs_syntaxerr.ml ./syntax/bs_syntaxerr.mli ./syntax/external_arg_spec.ml ./syntax/external_arg_spec.mli ./syntax/external_ffi_types.ml ./syntax/external_ffi_types.mli ./syntax/ppx_entry.ml ./syntax/reactjs_jsx_ppx_v2.ml ./syntax/reactjs_jsx_ppx_v3.ml
1+
../lib/4.06.1/bsdep.ml: ../ocaml/driver/compdynlink.mli ../ocaml/driver/compenv.ml ../ocaml/driver/compenv.mli ../ocaml/driver/compmisc.ml ../ocaml/driver/compmisc.mli ../ocaml/driver/compplugin.ml ../ocaml/driver/compplugin.mli ../ocaml/driver/makedepend.ml ../ocaml/driver/makedepend.mli ../ocaml/driver/pparse.ml ../ocaml/driver/pparse.mli ../ocaml/parsing/ast_helper.ml ../ocaml/parsing/ast_helper.mli ../ocaml/parsing/ast_invariants.ml ../ocaml/parsing/ast_invariants.mli ../ocaml/parsing/ast_iterator.ml ../ocaml/parsing/ast_iterator.mli ../ocaml/parsing/ast_mapper.ml ../ocaml/parsing/ast_mapper.mli ../ocaml/parsing/asttypes.mli ../ocaml/parsing/builtin_attributes.ml ../ocaml/parsing/builtin_attributes.mli ../ocaml/parsing/depend.ml ../ocaml/parsing/depend.mli ../ocaml/parsing/docstrings.ml ../ocaml/parsing/docstrings.mli ../ocaml/parsing/lexer.ml ../ocaml/parsing/lexer.mli ../ocaml/parsing/location.ml ../ocaml/parsing/location.mli ../ocaml/parsing/longident.ml ../ocaml/parsing/longident.mli ../ocaml/parsing/parse.ml ../ocaml/parsing/parse.mli ../ocaml/parsing/parser.ml ../ocaml/parsing/parser.mli ../ocaml/parsing/parsetree.mli ../ocaml/parsing/syntaxerr.ml ../ocaml/parsing/syntaxerr.mli ../ocaml/tools/ocamldep.ml ../ocaml/utils/arg_helper.ml ../ocaml/utils/arg_helper.mli ../ocaml/utils/ccomp.ml ../ocaml/utils/ccomp.mli ../ocaml/utils/clflags.ml ../ocaml/utils/clflags.mli ../ocaml/utils/identifiable.ml ../ocaml/utils/identifiable.mli ../ocaml/utils/misc.ml ../ocaml/utils/misc.mli ../ocaml/utils/numbers.ml ../ocaml/utils/numbers.mli ../ocaml/utils/profile.ml ../ocaml/utils/profile.mli ../ocaml/utils/terminfo.ml ../ocaml/utils/terminfo.mli ../ocaml/utils/warnings.ml ../ocaml/utils/warnings.mli ./common/bs_loc.ml ./common/bs_loc.mli ./common/bs_version.ml ./common/bs_version.mli ./common/bs_warnings.ml ./common/bs_warnings.mli ./common/js_config.ml ./common/js_config.mli ./common/lam_methname.ml ./common/lam_methname.mli ./core/bs_cmi_load.ml ./core/bs_conditional_initial.ml ./core/bs_conditional_initial.mli ./core/config_util.ml ./core/config_util.mli ./core/config_whole_compiler.ml ./core/config_whole_compiler.mli ./core/js_cmj_format.ml ./core/js_cmj_format.mli ./core/js_packages_info.ml ./core/js_packages_info.mli ./core/js_raw_info.ml ./core/lam.ml ./core/lam.mli ./core/lam_arity.ml ./core/lam_arity.mli ./core/lam_compat.ml ./core/lam_compat.mli ./core/lam_constant.ml ./core/lam_constant.mli ./core/lam_pointer_info.ml ./core/lam_pointer_info.mli ./core/lam_primitive.ml ./core/lam_primitive.mli ./core/lam_tag_info.ml ./core/matching_polyfill.ml ./core/matching_polyfill.mli ./core/primitive_compat.ml ./core/primitive_compat.mli ./core/record_attributes_check.ml ./ext/bsc_warnings.ml ./ext/ext_arg.ml ./ext/ext_arg.mli ./ext/ext_array.ml ./ext/ext_array.mli ./ext/ext_bytes.ml ./ext/ext_bytes.mli ./ext/ext_char.ml ./ext/ext_char.mli ./ext/ext_cmj_magic.ml ./ext/ext_filename.ml ./ext/ext_filename.mli ./ext/ext_fmt.ml ./ext/ext_js_file_kind.ml ./ext/ext_json_parse.ml ./ext/ext_json_parse.mli ./ext/ext_json_types.ml ./ext/ext_list.ml ./ext/ext_list.mli ./ext/ext_option.ml ./ext/ext_option.mli ./ext/ext_pervasives.ml ./ext/ext_pervasives.mli ./ext/ext_position.ml ./ext/ext_position.mli ./ext/ext_ref.ml ./ext/ext_ref.mli ./ext/ext_string.ml ./ext/ext_string.mli ./ext/ext_string_array.ml ./ext/ext_string_array.mli ./ext/ext_utf8.ml ./ext/ext_utf8.mli ./ext/ext_util.ml ./ext/ext_util.mli ./ext/hash_set_gen.ml ./ext/hash_set_poly.ml ./ext/hash_set_poly.mli ./ext/hash_set_string.ml ./ext/hash_set_string.mli ./ext/literals.ml ./ext/literals.mli ./ext/map_gen.ml ./ext/map_string.ml ./ext/map_string.mli ./ext/set_gen.ml ./ext/set_string.ml ./ext/set_string.mli ./main/builtin_cmi_datasets.ml ./main/builtin_cmi_datasets.mli ./main/builtin_cmj_datasets.ml ./main/builtin_cmj_datasets.mli ./stubs/bs_hash_stubs.ml ./syntax/ast_attributes.ml ./syntax/ast_attributes.mli ./syntax/ast_bs_open.ml ./syntax/ast_bs_open.mli ./syntax/ast_comb.ml ./syntax/ast_comb.mli ./syntax/ast_compatible.ml ./syntax/ast_compatible.mli ./syntax/ast_core_type.ml ./syntax/ast_core_type.mli ./syntax/ast_core_type_class_type.ml ./syntax/ast_core_type_class_type.mli ./syntax/ast_derive.ml ./syntax/ast_derive.mli ./syntax/ast_derive_abstract.ml ./syntax/ast_derive_abstract.mli ./syntax/ast_derive_js_mapper.ml ./syntax/ast_derive_js_mapper.mli ./syntax/ast_derive_projector.ml ./syntax/ast_derive_projector.mli ./syntax/ast_derive_util.ml ./syntax/ast_derive_util.mli ./syntax/ast_exp.ml ./syntax/ast_exp.mli ./syntax/ast_exp_apply.ml ./syntax/ast_exp_apply.mli ./syntax/ast_exp_extension.ml ./syntax/ast_exp_extension.mli ./syntax/ast_exp_handle_external.ml ./syntax/ast_exp_handle_external.mli ./syntax/ast_external.ml ./syntax/ast_external.mli ./syntax/ast_external_mk.ml ./syntax/ast_external_mk.mli ./syntax/ast_external_process.ml ./syntax/ast_external_process.mli ./syntax/ast_literal.ml ./syntax/ast_literal.mli ./syntax/ast_open_cxt.ml ./syntax/ast_open_cxt.mli ./syntax/ast_pat.ml ./syntax/ast_pat.mli ./syntax/ast_payload.ml ./syntax/ast_payload.mli ./syntax/ast_polyvar.ml ./syntax/ast_polyvar.mli ./syntax/ast_signature.ml ./syntax/ast_signature.mli ./syntax/ast_structure.ml ./syntax/ast_structure.mli ./syntax/ast_tdcls.ml ./syntax/ast_tdcls.mli ./syntax/ast_tuple_pattern_flatten.ml ./syntax/ast_tuple_pattern_flatten.mli ./syntax/ast_typ_uncurry.ml ./syntax/ast_typ_uncurry.mli ./syntax/ast_utf8_string.ml ./syntax/ast_utf8_string.mli ./syntax/ast_utf8_string_interp.ml ./syntax/ast_utf8_string_interp.mli ./syntax/ast_util.ml ./syntax/ast_util.mli ./syntax/bs_ast_invariant.ml ./syntax/bs_ast_invariant.mli ./syntax/bs_ast_mapper.ml ./syntax/bs_ast_mapper.mli ./syntax/bs_builtin_ppx.ml ./syntax/bs_builtin_ppx.mli ./syntax/bs_syntaxerr.ml ./syntax/bs_syntaxerr.mli ./syntax/external_arg_spec.ml ./syntax/external_arg_spec.mli ./syntax/external_ffi_types.ml ./syntax/external_ffi_types.mli ./syntax/ppx_entry.ml ./syntax/reactjs_jsx_ppx_v2.ml ./syntax/reactjs_jsx_ppx_v3.ml

0 commit comments

Comments
 (0)