Skip to content

Commit e29843b

Browse files
authored
Revert "Magic numbers" (#360)
* Revert "Bootstrap" This reverts commit afe3ee5. * Revert "Change prefix of all magic numbers to avoid clashes with upstream." This reverts commit be3627b.
1 parent 41b0078 commit e29843b

File tree

5 files changed

+34
-27
lines changed

5 files changed

+34
-27
lines changed

ocaml/boot/ocamlc

-7.47 KB
Binary file not shown.

ocaml/boot/ocamllex

0 Bytes
Binary file not shown.

ocaml/runtime/caml/exec.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ struct exec_trailer {
6060

6161
/* Magic number for this release */
6262

63-
#define EXEC_MAGIC "Caml2021X029"
63+
#define EXEC_MAGIC "Caml1999X029"
6464

6565
#endif /* CAML_INTERNALS */
6666

ocaml/utils/config.mlp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@ let function_sections = %%FUNCTION_SECTIONS%%
9191
let probes = %%PROBES%%
9292
let afl_instrument = %%AFL_INSTRUMENT%%
9393

94-
let exec_magic_number = "Caml2021X029"
94+
let exec_magic_number = "Caml1999X029"
9595
(* exec_magic_number is duplicated in runtime/caml/exec.h *)
96-
and cmi_magic_number = "Caml2021I029"
97-
and cmo_magic_number = "Caml2021O029"
98-
and cma_magic_number = "Caml2021A029"
96+
and cmi_magic_number = "Caml1999I029"
97+
and cmo_magic_number = "Caml1999O029"
98+
and cma_magic_number = "Caml1999A029"
9999
and cmx_magic_number =
100100
if flambda || flambda2 then
101101
"Caml2021y029"
@@ -106,11 +106,11 @@ and cmxa_magic_number =
106106
"Caml2021z029"
107107
else
108108
"Caml2021Z029"
109-
and ast_impl_magic_number = "Caml2021M029"
110-
and ast_intf_magic_number = "Caml2021N029"
111-
and cmxs_magic_number = "Caml2021D029"
112-
and cmt_magic_number = "Caml2021T029"
113-
and linear_magic_number = "Caml2021L029"
109+
and ast_impl_magic_number = "Caml1999M029"
110+
and ast_intf_magic_number = "Caml1999N029"
111+
and cmxs_magic_number = "Caml1999D029"
112+
and cmt_magic_number = "Caml1999T029"
113+
and linear_magic_number = "Caml1999L029"
114114
and cfg_magic_number = "Caml2021G029"
115115

116116
let interface_suffix = ref ".mli"

ocaml/utils/misc.ml

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -982,30 +982,37 @@ module Magic_number = struct
982982

983983
type raw_kind = string
984984

985-
(* We do not accept Caml1999 prefixes. *)
986985
let parse_kind : raw_kind -> kind option = function
987-
| "Caml2021X" -> Some Exec
988-
| "Caml2021I" -> Some Cmi
989-
| "Caml2021O" -> Some Cmo
990-
| "Caml2021A" -> Some Cma
986+
| "Caml1999X" -> Some Exec
987+
| "Caml1999I" -> Some Cmi
988+
| "Caml1999O" -> Some Cmo
989+
| "Caml1999A" -> Some Cma
991990
| "Caml2021y" -> Some (Cmx {flambda = true})
992991
| "Caml2021Y" -> Some (Cmx {flambda = false})
993992
| "Caml2021z" -> Some (Cmxa {flambda = true})
994993
| "Caml2021Z" -> Some (Cmxa {flambda = false})
995-
| "Caml2021D" -> Some Cmxs
996-
| "Caml2021T" -> Some Cmt
997-
| "Caml2021M" -> Some Ast_impl
998-
| "Caml2021N" -> Some Ast_intf
994+
995+
(* Caml2007D and Caml2012T were used instead of the common Caml1999 prefix
996+
between the introduction of those magic numbers and October 2017
997+
(8ba70ff194b66c0a50ffb97d41fe9c4bdf9362d6).
998+
999+
We accept them here, but will always produce/show kind prefixes
1000+
that follow the current convention, Caml1999{D,T}. *)
1001+
| "Caml2007D" | "Caml1999D" -> Some Cmxs
1002+
| "Caml2012T" | "Caml1999T" -> Some Cmt
1003+
1004+
| "Caml1999M" -> Some Ast_impl
1005+
| "Caml1999N" -> Some Ast_intf
9991006
| _ -> None
10001007

10011008
(* note: over time the magic kind number has changed for certain kinds;
10021009
this function returns them as they are produced by the current compiler,
10031010
but [parse_kind] accepts older formats as well. *)
10041011
let raw_kind : kind -> raw = function
1005-
| Exec -> "Caml2021X"
1006-
| Cmi -> "Caml2021I"
1007-
| Cmo -> "Caml2021O"
1008-
| Cma -> "Caml2021A"
1012+
| Exec -> "Caml1999X"
1013+
| Cmi -> "Caml1999I"
1014+
| Cmo -> "Caml1999O"
1015+
| Cma -> "Caml1999A"
10091016
| Cmx config ->
10101017
if config.flambda
10111018
then "Caml2021y"
@@ -1014,10 +1021,10 @@ module Magic_number = struct
10141021
if config.flambda
10151022
then "Caml2021z"
10161023
else "Caml2021Z"
1017-
| Cmxs -> "Caml2021D"
1018-
| Cmt -> "Caml2021T"
1019-
| Ast_impl -> "Caml2021M"
1020-
| Ast_intf -> "Caml2021N"
1024+
| Cmxs -> "Caml1999D"
1025+
| Cmt -> "Caml1999T"
1026+
| Ast_impl -> "Caml1999M"
1027+
| Ast_intf -> "Caml1999N"
10211028

10221029
let string_of_kind : kind -> string = function
10231030
| Exec -> "exec"

0 commit comments

Comments
 (0)