Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
050b513
enabling native-compiler
IBBXEF Jun 5, 2026
bb6c614
Created placeholder functions for compiling to mlf
IBBXEF Jun 5, 2026
238477b
Now compiles lambda functions
IBBXEF Jun 5, 2026
24371ff
Now compiles primitives
IBBXEF Jun 5, 2026
21cdcaa
the mlf compiler is now called by the general compile function
IBBXEF Jun 8, 2026
50fcc05
fixed two naming errors
IBBXEF Jun 8, 2026
c501fcf
Now compiles local and global variable names, applications and let st…
IBBXEF Jun 8, 2026
741d512
Now compiles if and letrec statements, and fixed a bug with global names
IBBXEF Jun 8, 2026
01393e9
Now compiles (at least define) let cases
IBBXEF Jun 8, 2026
1d8d2c4
Now compiles global table fix types (whatever that is)
IBBXEF Jun 8, 2026
1ed11de
Now compiles global table norm and fixed a few bugs
IBBXEF Jun 8, 2026
53890e2
Fixed a capitalization error and a few inconsistencies
IBBXEF Jun 8, 2026
0a3be3f
Now compiles arrays and reference assignment
IBBXEF Jun 8, 2026
2fe67ee
Fixed an arror where global names where wrongly assumed to come from …
IBBXEF Jun 8, 2026
e6fd9ed
Fixed a bug introduced by the last fix where some global variable wou…
IBBXEF Jun 8, 2026
5a62b24
refactored some of the code and fixed a bug where () would be transla…
IBBXEF Jun 8, 2026
5962c78
rt1 and rt2 are now correctly marked as coming from the Nativelib module
IBBXEF Jun 8, 2026
fd8852f
refactored pp_gname_plf
IBBXEF Jun 8, 2026
8d28a82
Fixed an error whith double dollar signs before variables
IBBXEF Jun 9, 2026
3b6b7d3
Now compiles match statements
IBBXEF Jun 9, 2026
a9153b4
Now compiles primitives Mk_fix and Mk_var
IBBXEF Jun 9, 2026
6ef0751
Fixed a double dollar bug and some values being wrongly compiled as f…
IBBXEF Jun 9, 2026
d06b9e0
Fixed multiple cases where definition would be compiled as functions,…
IBBXEF Jun 9, 2026
c974fe7
Now compiles global cofix tables and all global declaration !
IBBXEF Jun 9, 2026
8c98c41
Now compiles MLconstruct and MLisaccu, and thus, all mllambda express…
IBBXEF Jun 9, 2026
e472d18
Now compiles lazy values correctly
IBBXEF Jun 9, 2026
867d435
Started to make a function to call the mlf compiler
IBBXEF Jun 9, 2026
5aa109b
Now correctly compiles uints and floats in 32 and 64 bits architectures
IBBXEF Jun 9, 2026
9f7a637
Now correctly compiles negative ints
IBBXEF Jun 9, 2026
988090e
Refactored code and improved generated code identation
IBBXEF Jun 9, 2026
2c6e11e
fixed bugs with uint compilation, refactored code, removed useless pa…
IBBXEF Jun 9, 2026
8612027
refactored and fixed typos
IBBXEF Jun 10, 2026
2d07c60
Now compiles field access correctly
IBBXEF Jun 10, 2026
7bc7c28
the malfunction compiler is now called
IBBXEF Jun 10, 2026
ab1de57
letrec are now compiled properly
IBBXEF Jun 10, 2026
2ad5d7e
compiled mlf programs now generate mli files and import each other
IBBXEF Jun 10, 2026
c3918aa
Cleaned code and did a small fix
IBBXEF Jun 10, 2026
d538c9f
ML primitives without arguments are now correctly compiled as values …
IBBXEF Jun 10, 2026
a707d73
Compilation now works perfectly
IBBXEF Jun 10, 2026
788da35
Cleaned generated code and fixed ml primitives being imported from th…
IBBXEF Jun 11, 2026
dea3999
Fixed Lazy.force being incorrectly compiled
IBBXEF Jun 11, 2026
7b90bb8
Fixed an error in string compilation
IBBXEF Jun 11, 2026
8fc86af
Generated interface is now compatible with Ocaml native compilation
IBBXEF Jun 11, 2026
3e3a42d
.mli interfaces now contains defined types
IBBXEF Jun 11, 2026
406f5ac
refactored code, and generated interfaces now have types more coheren…
IBBXEF Jun 12, 2026
a92cac2
Now correctly compiles floats, Array.get and cofix
IBBXEF Jun 12, 2026
d112f42
Now correctly compiles cofix
IBBXEF Jun 13, 2026
1a6a805
removed now unecessary code
IBBXEF Jun 15, 2026
f02c67d
Now correctly handles nan and infinity
IBBXEF Jun 15, 2026
adc655a
Now handles decode_string and compilation in specific folders
IBBXEF Jun 15, 2026
a1d3c2c
Went back to simpler mli generation as interfacing with Ocaml will no…
IBBXEF Jun 15, 2026
c6545e3
removed Ocaml compilation
IBBXEF Jun 16, 2026
c0a6506
Added cleaner debug messages and error handling
IBBXEF Jun 16, 2026
530b3b9
removed most of Ocaml code generation
IBBXEF Jun 16, 2026
b92250a
More cleanup, reused now free function names, and moved Lazy.force in…
IBBXEF Jun 16, 2026
a31380b
more renaming
IBBXEF Jun 16, 2026
cbc1348
fixed identation
IBBXEF Jun 16, 2026
e181096
pp_lname now adds truly returns the variable name in mlf (with the do…
IBBXEF Jun 16, 2026
f505c2c
replaced arrays with normal memory blocks
IBBXEF Jun 16, 2026
16379d0
removed Obj_magic primitive as it is no longer needed
IBBXEF Jun 16, 2026
dd3ade1
The compilation of logical and is now cleaner
IBBXEF Jun 16, 2026
389ea57
fixed a comment
IBBXEF Jun 16, 2026
45a2e42
removed some support for the creation of clotures on primitives
IBBXEF Jun 16, 2026
2bd1cd7
added a space to make code generation clearer
IBBXEF Jun 16, 2026
e7862cd
removed annotations from matches as they are no longer needed
IBBXEF Jun 17, 2026
8629609
removed annotations from Gletcase as they are no longer needed
IBBXEF Jun 17, 2026
261cc4a
updated Dockerfile to add malfunction as an opam pin
IBBXEF Jun 17, 2026
138cc5c
The compilation of Uint, float, and pstring into mlf is now separated…
IBBXEF Jun 19, 2026
423641e
updated benchmarks
IBBXEF Jun 23, 2026
5928a2b
enabled native for benchmarks
IBBXEF Jun 23, 2026
ac8a08e
now compiles with Oclassic
IBBXEF Jul 6, 2026
7f3e2dd
updated ci hash key
IBBXEF Jul 7, 2026
15bc055
updated Dockerfile
IBBXEF Jul 7, 2026
de38b35
Avoid identity cast functions in native compilation.
ppedrot Jul 10, 2026
04864ad
Updated dockerfile.
ppedrot Jul 10, 2026
e4cbb61
added a MLmatch_noaccu contructor to mllambda, and
IBBXEF Jun 17, 2026
287653c
added a Gletcase_noaccu constructor to global and made optionnal accu…
IBBXEF Jun 17, 2026
a4eb4dc
the compilation of cases no longer declares unused variables when com…
IBBXEF Jun 22, 2026
348c92b
refactored the compilation of fixpoint
IBBXEF Jun 22, 2026
0b19c03
The optionnal compilation has been extended to more functions and now…
IBBXEF Jun 22, 2026
834c63a
Production now forces accumulators as they need one to be evaluated
IBBXEF Jun 22, 2026
db4341f
move the choice to compile with or without accumulators to allow to f…
IBBXEF Jun 23, 2026
b35e792
Fixed some cases where accumulators where not believed to be needed
IBBXEF Jun 23, 2026
f7ae5bb
fixed cofix points not forcing the use of accumulators
IBBXEF Jun 23, 2026
b900ce0
fixed some comments that are no longer accurate
IBBXEF Jun 23, 2026
649408c
accumulator removal now takes into account libraries that could need …
IBBXEF Jun 23, 2026
516a3a3
fixed has_accus_native_file wrongly always returning true
IBBXEF Jun 24, 2026
f5a9513
Libraries mli interfaces now indicate if they use accumulators, and t…
IBBXEF Jun 24, 2026
2c08084
made a temporary fix to mli files being in the wrong location
IBBXEF Jun 24, 2026
df20cb1
When a library does not support accumulators but we do, we recompile …
IBBXEF Jun 25, 2026
60e294c
Libraries now indicate if they do not generate accumulators, and this…
IBBXEF Jun 25, 2026
1c40dbc
custom flags are now stored in the compiled interface and are retriev…
IBBXEF Jun 25, 2026
5f46da5
fixed library file being wrong when registering native libraries
IBBXEF Jun 25, 2026
7294f15
removed global type declaration as they are no longer needed
IBBXEF Jun 26, 2026
f5ab538
Removed prefix and inductive name from MLconstruct as they are no lon…
IBBXEF Jun 26, 2026
aa91e6f
Now longer forces accumulators by needing an inductive defined in ano…
IBBXEF Jun 26, 2026
ae8a008
fixed a comment
IBBXEF Jun 26, 2026
0d7ccdd
fixed most TODOs, and non-library files now also have a dinstinction …
IBBXEF Jun 30, 2026
ef77ee3
Fixed an old bug made visible by the last commit : native_conv_gen wo…
IBBXEF Jun 30, 2026
1839a60
fixed an important bug where functions (and productions) would not ca…
IBBXEF Jul 6, 2026
155d3b0
Now make simple checks to avoid recompiling everything when an accumu…
IBBXEF Jul 13, 2026
8945ff0
updated gitlab ci
IBBXEF Aug 14, 2026
e7ec5e5
changed the representation of accumulators to be a closure
IBBXEF Jun 29, 2026
9dbd0e2
Fixed closures and accumulators being undistinguishable
IBBXEF Jun 29, 2026
81ffacb
removed the main hack in the handling of accumulators
IBBXEF Jun 30, 2026
7ae5882
cleaned code and simplified the hack used to differentiate functions …
IBBXEF Jun 30, 2026
8cd6c05
removed magic numbers
IBBXEF Jun 30, 2026
28362fc
changed accumulator contruction and check to not use Obj.with_tag
IBBXEF Jul 9, 2026
79b43fc
removed architectures checks as native_compute no longer uses inline …
IBBXEF Jul 9, 2026
390c586
added more guardrails to the build_accu function to avoid optimisatio…
IBBXEF Jul 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ variables:
# The $hash is the first 10 characters of the md5 of the Dockerfile. e.g.
# echo $(md5sum dev/ci/docker/old_ubuntu_lts/Dockerfile | head -c 10)
# echo $(md5sum dev/ci/docker/edge_ubuntu/Dockerfile | head -c 10)
BASE_CACHEKEY: "old_ubuntu_lts-V2026-07-06-00242ff07f"
EDGE_CACHEKEY: "edge_ubuntu-V2026-07-06-62b9804f8c"
BASE_CACHEKEY: "old_ubuntu_lts-V2026-14-08-1c266a2665"
EDGE_CACHEKEY: "edge_ubuntu-V2026-14-08-e139ef8b6a"
BASE_IMAGE: "$CI_REGISTRY_IMAGE:$BASE_CACHEKEY"
EDGE_IMAGE: "$CI_REGISTRY_IMAGE:$EDGE_CACHEKEY"

Expand Down Expand Up @@ -329,6 +329,9 @@ build:base+32bit:
OPAM_VARIANT: "+32bit"
COQ_EXTRA_CONF: "-native-compiler yes"
ROCQIDE: "no"
artifacts:
paths:
- _build
only: *full-ci

build:edge+flambda:
Expand Down
4 changes: 2 additions & 2 deletions clib/cUnix.ml
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ let run_command ?(hook=(fun _ ->())) c =
(against whitespace or other funny chars in paths), hence no need
to care about the different quoting conventions of /bin/sh and cmd.exe. *)

let sys_command prog args =
let sys_command ?(out_file_descr=Unix.stdout) prog args =
let argv = Array.of_list (prog::args) in
let pid = Unix.create_process prog argv Unix.stdin Unix.stdout Unix.stderr in
let pid = Unix.create_process prog argv Unix.stdin out_file_descr Unix.stderr in
waitpid_non_intr pid

(*
Expand Down
2 changes: 1 addition & 1 deletion clib/cUnix.mli
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ val run_command :
(against whitespace or other funny chars in paths), hence no need
to care about the different quoting conventions of /bin/sh and cmd.exe. *)

val sys_command : string -> string list -> Unix.process_status
val sys_command : ?out_file_descr:(Unix.file_descr) -> string -> string list -> Unix.process_status

(** A version of [Unix.waitpid] immune to EINTR exceptions *)

Expand Down
2 changes: 1 addition & 1 deletion config/dune
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@
%{project_root}/dev/header.c
; Needed to generate include lists for coq_makefile
plugin_list)
(action (chdir %{project_root} (run %{project_root}/tools/configure/configure.exe -quiet -relocatable))))
(action (chdir %{project_root} (run %{project_root}/tools/configure/configure.exe -quiet -relocatable -native-compiler yes))))
6 changes: 4 additions & 2 deletions dev/bench/bench.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ check_variable () {
: "${old_coq_version:=dev}"
: "${num_of_iterations:=1}"
: "${timeout:=3h}"
: "${coq_opam_packages:=rocq-stdlib rocq-bignums coq-hott coq-performance-tests-lite coq-engine-bench-lite rocq-elpi rocq-mathcomp-boot rocq-mathcomp-order rocq-mathcomp-ssreflect rocq-mathcomp-finite-group rocq-mathcomp-algebra rocq-mathcomp-solvable rocq-mathcomp-field rocq-mathcomp-group-representation coq-mathcomp-odd-order rocq-mathcomp-analysis coq-math-classes coq-corn coq-compcert rocq-equations rocq-metarocq-utils rocq-metarocq-common rocq-metarocq-template rocq-metarocq-pcuic rocq-metarocq-safechecker rocq-metarocq-erasure rocq-metarocq-translations coq-color coq-coqprime coq-coqutil coq-bedrock2 coq-rewriter coq-fiat-core coq-fiat-parsers coq-fiat-crypto-with-bedrock coq-unimath coq-coquelicot coq-iris-examples coq-fourcolor coq-rewriter-perf-SuperFast coq-vst coq-category-theory coq-neural-net-interp-computed-lite}"
: "${coq_native:=}"
: "${coq_opam_packages:=rocq-stdlib rocq-bignums coq-hott coq-performance-tests-lite coq-engine-bench-lite rocq-elpi rocq-mathcomp-boot rocq-mathcomp-order rocq-mathcomp-ssreflect rocq-mathcomp-finite-group rocq-mathcomp-algebra rocq-mathcomp-solvable rocq-mathcomp-field rocq-mathcomp-group-representation coq-mathcomp-odd-order coq-mathcomp-analysis coq-math-classes coq-corn coq-compcert rocq-equations rocq-metarocq-utils rocq-metarocq-common rocq-metarocq-template rocq-metarocq-pcuic rocq-metarocq-safechecker rocq-metarocq-erasure rocq-metarocq-translations coq-color coq-coqprime coq-coqutil coq-bedrock2 coq-rewriter coq-fiat-core coq-fiat-parsers coq-fiat-crypto-with-bedrock coq-unimath coq-coquelicot coq-iris-examples coq-fourcolor coq-rewriter-perf-SuperFast coq-vst coq-category-theory coq-neural-net-interp-computed-lite}"
: "${coq_native:=1}"
: "${auto_overlays:=1}"

# example: coq-hott.dev git+https://github.com/some-user/coq-hott#some-branch
Expand Down Expand Up @@ -437,6 +437,8 @@ create_opam() {
opam install -qy -j "$number_of_processors" $initial_opam_packages
if [ ! -z "$BENCH_DEBUG" ]; then opam repo list; fi

opam pin add -qy -j "$number_of_processors" git+https://github.com/IBBXEF/malfunction#recusive_types

cd "$coq_dir"
echo "$1_coq_commit = $COQ_HASH"

Expand Down
3 changes: 2 additions & 1 deletion dev/ci/docker/edge_ubuntu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ RUN mkdir -p ~/.config/dune && printf '(lang dune 2.1)\n(jobs %s)\n' $NJOBS > ~/

# Edge opam is the set of edge packages required by Coq
ENV COMPILER="4.14.2" \
BASE_OPAM="zarith.1.14 ounit2.2.2.7 camlzip.1.14" \
BASE_OPAM="zarith.1.14 ounit2.2.2.7 camlzip.1.14 ocaml-compiler-libs" \
CI_OPAM="ocamlgraph.2.0.0 cppo.1.8.0" \
BASE_OPAM_EDGE="dune.3.23.1 dune-build-info.3.23.1 dune-release.2.2.1 ocamlfind.1.9.8 odoc.3.2.1" \
CI_OPAM_EDGE="memprof-limits.0.3.0 elpi.3.7.1 ppx_import.1.12.0 cmdliner.2.1.1 sexplib.v0.16.0 ppx_sexp_conv.v0.16.0 ppx_hash.v0.16.0 ppx_compare.v0.16.0 ppx_deriving_yojson.3.9.1 yojson.2.2.2 uri.4.4.0 ppx_yojson_conv.v0.16.0 ppx_inline_test.v0.16.1 ppx_assert.v0.16.0 ppx_optcomp.v0.16.0 lsp.1.26.0 sel.0.8.0" \
Expand All @@ -68,6 +68,7 @@ RUN opam init -a --disable-sandboxing --bare && eval $(opam env) && \
opam repo add archive git+https://github.com/ocaml/opam-repository-archive && \
opam update && \
opam install $BASE_OPAM $BASE_OPAM_EDGE $COQIDE_OPAM_EDGE $CI_OPAM $CI_OPAM_EDGE && \
opam pin add git+https://github.com/IBBXEF/malfunction#5b5b625cd98e7cbd60325cc2634ee6cbab033236 && \
opam clean -a -c

# set the locale for the benefit of Python
Expand Down
4 changes: 3 additions & 1 deletion dev/ci/docker/old_ubuntu_lts/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ RUN mkdir -p ~/.config/dune && printf '(lang dune 2.1)\n(jobs %s)\n' $NJOBS > ~/
ENV COMPILER="4.14.0"

# Common OPAM packages
ENV BASE_OPAM="zarith.1.11 ounit2.2.2.6 yojson.1.7.0 camlzip.1.10" \
ENV BASE_OPAM="zarith.1.11 ounit2.2.2.6 yojson.1.7.0 camlzip.1.10 ocaml-compiler-libs" \
CI_OPAM="ocamlgraph.2.0.0 cppo.1.6.9" \
BASE_ONLY_OPAM="dune.3.21.1 stdlib-shims.0.1.0 ocamlfind.1.9.1 odoc.3.2.1 num.1.4"

Expand All @@ -70,6 +70,7 @@ RUN opam init -a --disable-sandboxing --compiler="$COMPILER" default https://opa
opam repo add archive git+https://github.com/ocaml/opam-repository-archive && \
opam update && \
opam install $BASE_OPAM $COQIDE_OPAM $CI_OPAM $BASE_ONLY_OPAM && \
opam pin add git+https://github.com/IBBXEF/malfunction#5b5b625cd98e7cbd60325cc2634ee6cbab033236 && \
opam clean -a -c && \
find ~ '(' -name '*.cmt' -o -name '*.cmti' ')' -delete

Expand All @@ -81,6 +82,7 @@ RUN opam switch create "${COMPILER}+32bit" \
opam update && \
i386 env CC='gcc -m32' opam install zarith.1.11 && \
opam install $BASE_OPAM && \
opam pin add git+https://github.com/IBBXEF/malfunction#5b5b625cd98e7cbd60325cc2634ee6cbab033236 && \
opam clean -a -c && \
find ~ '(' -name '*.cmt' -o -name '*.cmti' ')' -delete

Expand Down
58 changes: 0 additions & 58 deletions kernel/byterun/rocq_values.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,61 +108,3 @@ value rocq_tcode_array(value tcodes) {
}
CAMLreturn(res);
}

/* The rocq_curry2_1 function returns a pointer to some code that
immediately branches to caml_curry2_1. It can be used as field 0 of
an OCaml closure, as long as field 3 contains a closure whose code
pointer accepts exactly two arguments (the first argument is stored
in field 2).

Since the word before the branch indicates to the garbage collector
that this block should be ignored, the code pointer can be used
inside blocks that do not have tag 247. This 2043 value is the
result of Caml_out_of_heap_header(2, Abstract_tag).

Keep the compile-time checks in sync with rocq_configure.c */

#ifdef NO_NATIVE_COMPUTE

value rocq_curry2_1_addr(value v) {
return Val_unit;
}

#elif defined(NO_NAKED_POINTERS)

__attribute__((weak))
void caml_curry2_1() {
abort();
}

#if defined(__GNUC__) && defined(__amd64__)

asm(".align 8\n\t"
".quad 2043\n"
"rocq_curry2_1:\n\t"
"jmp caml_curry2_1\n");

#elif defined(__GNUC__) && defined(__i386__)

asm(".align 4\n\t"
".long 2043\n"
"rocq_curry2_1:\n\t"
"jmp caml_curry2_1\n");

#else
#error "Unsupported architecture for native_compute."
#endif

value rocq_curry2_1_addr(value v) {
extern void rocq_curry2_1();
return (value)&rocq_curry2_1;
}

#else // not NO_NAKED_POINTERS

value rocq_curry2_1_addr(value v) {
extern void caml_curry2_1() __attribute__((weak));
return (value)&caml_curry2_1;
}

#endif
2 changes: 2 additions & 0 deletions kernel/float64.mli
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ val to_string : t -> string

val compile : t -> string

val compile_mlf : t -> string

val of_float : float -> t

(** All NaNs are normalized to [Stdlib.nan].
Expand Down
9 changes: 9 additions & 0 deletions kernel/float64_common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ let of_string = float_of_string
let compile f =
Printf.sprintf "Float64.of_float (%s)" (to_hex_string f)

(* Compiles a float to malfunction code *)
let compile_mlf f = (* malfunction does not support writing -1.1, so we have to be careful *)
if Float.is_nan f then "(apply (global $Float64 $of_float) nan)"
else if Float.is_infinite f then begin
if f < 0. then Printf.sprintf "(apply (global $Float64 $of_float) neg_infinity)"
else Printf.sprintf "(apply (global $Float64 $of_float) infinity)"
end else if f < 0. then Printf.sprintf "(apply (global $Float64 $of_float) (neg.f64 %.17e))" (-. f) (* malfunction supports scientific notation *)
else Printf.sprintf "(apply (global $Float64 $of_float) %.17e)" f

let of_float f = f

let to_float f = if is_nan f then nan else f
Expand Down
2 changes: 2 additions & 0 deletions kernel/float64_common.mli
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ val to_string : t -> string

val compile : t -> string

val compile_mlf : t -> string

val of_float : float -> t

(** All NaNs are normalized to [Stdlib.nan].
Expand Down
Loading
Loading