Skip to content

Commit

Permalink
Support OCaml 4.13, 4.14
Browse files Browse the repository at this point in the history
  • Loading branch information
stedolan committed Sep 23, 2022
1 parent fa48c08 commit 16b37a9
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 14 deletions.
8 changes: 6 additions & 2 deletions dune-workspace.all
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
(context (opam (switch 4.10.2+flambda)))
(context (opam (switch 4.11.0)))
(context (opam (switch 4.11.0+flambda)))
(context (opam (switch 4.11.1) (merlin)))
(context (opam (switch 4.11.1)))
(context (opam (switch 4.11.1+flambda)))
(context (opam (switch 4.12.0) ))
(context (opam (switch 4.12.0) (merlin)))
(context (opam (switch 4.12.0+flambda)))
(context (opam (switch 4.13.1) ))
(context (opam (switch 4.13.1+flambda)))
(context (opam (switch 4.14.0) ))
(context (opam (switch 4.14.0+flambda)))
44 changes: 33 additions & 11 deletions src/malfunction_compat.cppo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,41 @@ let lfunction params body =
#if OCAML_VERSION >= (4, 08, 0)
let params = List.map (fun x -> x, Pgenval) params in
#endif
let attr = {
inline = Default_inline;
specialise = Default_specialise;
is_a_functor = false;
#if OCAML_VERSION >= (4, 05, 0)
stub = false;
#endif
#if OCAML_VERSION >= (4, 08, 0)
local = Default_local;
#endif
#if OCAML_VERSION >= (4, 14, 0)
poll = Default_poll;
tmc_candidate = false;
#endif
} in
#if OCAML_VERSION >= (4, 14, 0)
lfunction
~kind:Curried
~params
~return:Pgenval
~body
~attr
~loc:loc_none
#else
Lfunction {
kind = Curried;
params;
body;
loc = loc_none;
attr = {
inline = Default_inline;
specialise = Default_specialise;
is_a_functor = false;
#if OCAML_VERSION >= (4, 05, 0)
stub = false;
#endif
#if OCAML_VERSION >= (4, 08, 0)
local = Default_local;
#endif
};
attr;
#if OCAML_VERSION >= (4, 08, 0)
return = Pgenval;
#endif
}
#endif

let lapply fn args =
Lapply {
Expand Down Expand Up @@ -241,7 +256,14 @@ let compile_implementation
if Config.flambda then Flambda_middle_end.lambda_to_clambda
else Closure_middle_end.lambda_to_clambda
in
#if OCAML_VERSION >= (4, 13, 0)
ignore filename;
Asmgen.compile_implementation
?toplevel:None ~backend ~prefixname ~middle_end ~ppf_dump:ppf
program
#else
Asmgen.compile_implementation
?toplevel:None ~backend ~filename ~prefixname ~middle_end ~ppf_dump:ppf
program
#endif
#endif
15 changes: 14 additions & 1 deletion src/malfunction_compiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,21 @@ module IntSwitch = struct
let geint = Pintcomp Cge
let gtint = Pintcomp Cgt

type arg = Lambda.lambda
type test = Lambda.lambda
type act = Lambda.lambda

let make_is_nonzero arg =
(* https://github.com/ocaml/ocaml/pull/10681 *)
Lprim (pintcomp_cne,
[arg; Lconst (Const_base (Const_int 0))],
loc_none)

let arg_as_test (arg : arg) : test = arg

(* these are unused on some OCaml versions *)
let _ = make_is_nonzero, arg_as_test

let make_prim p args = lprim p args
let make_offset arg n = match n with
| 0 -> arg
Expand Down Expand Up @@ -630,7 +643,7 @@ let setup_options options =
(* FIXME: should we use classic_arguments for non-flambda builds? *)

(* Hack: disable the "no cmx" warning for zarith *)
Warnings.parse_options false "-58";
let _ = Warnings.parse_options false "-58" in
assert (not (Warnings.is_active (Warnings.No_cmx_file "asdf")));

(options |> List.iter @@ function
Expand Down

0 comments on commit 16b37a9

Please sign in to comment.