Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make boot/ocamlc read directly byterun/primitives #324

Closed
wants to merge 2 commits into from

Conversation

bobot
Copy link
Contributor

@bobot bobot commented Dec 1, 2015

boot/* are often responsible for merge conflict in github or rebase conflict during development, because they are binaries. People needs to modifies boot/ocamlc each time the set of primitives in the default runtime is modified.

This merge request proposes to use for boot/ocamlc the option -use-prims byterun/primitives. It allows to add new primitive and use it in the standard library without bootstrapping. Compilation with ./ocamlc,./ocamlopt are not modified.

For example you can compile with the following patch without the errors:

File "_none_", line 1:
Error: Error while linking boot/stdlib.cma(Weak):
The external function `caml_test_add_prim' is not available
diff --git a/byterun/weak.c b/byterun/weak.c
index 3614d11..29e1845 100644
--- a/byterun/weak.c
+++ b/byterun/weak.c
@@ -190,3 +190,8 @@ CAMLprim value caml_weak_blit (value ars, value ofs,
   }
   return Val_unit;
 }
+
+CAMLprim value caml_test_add_prim (value ar, value n)
+{
+  return ar;
+}
diff --git a/stdlib/weak.ml b/stdlib/weak.ml
index 71385c9..5dc37b4 100644
--- a/stdlib/weak.ml
+++ b/stdlib/weak.ml
@@ -303,3 +303,7 @@ module Make (H : Hashtbl.HashedType) : (S with type data = H.t) = struct
   ;;

 end;;
+
+external test_add_prim: int -> int -> int = "caml_test_add_prim"
+
+let _ = test_add_prim 1 2

I think that work also for removing some primitives but I don't know which exactly.

This could wait after 4.03 since it only simplifies compiler development.

   Adding primitives doesn't require to bootstrap anymore
@gasche
Copy link
Member

gasche commented Dec 1, 2015

I don't know enough of the compiler build machinery to understand if that is correct, but I warmly welcome the change. Indeed bootstrapping on primitive changes is a pain and makes some sorts of contributions much more delicate. (It also generates conflicts that makes handling out-of-tree branches painful, etc.)

Thanks for this very productive work.

@damiendoligez
Copy link
Member

@gerdstolpmann should look at this, as it's getting close to cross-compilation territory.

Anyway, let's wait for 4.04, there's a lot going on now and I don't want to risk breaking the makefiles at this time.

@gerdstolpmann
Copy link

Basically, we have primitives that are hard-coded in the compiler (e.g. look at the beginnning of Translcore, it assumes caml_equal and others), and primitives that are used in the standard library. The -use-prims option is correct for the latter. My thinking is that there should also be a list of hard-coded primitives that is merged with the loaded list.

But anyway, given that there are rarely new hard-coded primitives the new approach is better than the old one. I don't see any problems with cross-compilation. On the contrary, host and target compilers could now even deviate with respect to the primitives.

@damiendoligez damiendoligez added this to the 4.04-or-later milestone Dec 17, 2015
@bobot bobot mentioned this pull request Dec 24, 2015
@alainfrisch
Copy link
Contributor

Thanks! Merged (manually -- somehow Git got overly confused while trying to merge, apparently by Windows EOL in .nt files).

@damiendoligez damiendoligez mentioned this pull request Oct 19, 2017
poechsel pushed a commit to poechsel/ocaml that referenced this pull request Mar 1, 2021
poechsel pushed a commit to poechsel/ocaml that referenced this pull request Mar 1, 2021
poechsel pushed a commit to poechsel/ocaml that referenced this pull request Mar 1, 2021
chambart pushed a commit to chambart/ocaml-1 that referenced this pull request Jan 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants