Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007688OCamlmiscpublic2017-12-07 17:382017-12-11 23:17
Assigned Tojacques-henri.jourdan 
StatusclosedResolutionno change required 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0007688: Hard bootstrap procedure is broken
DescriptionAt the begining of the makefile is described a "hard bootstrap procedure", that is supposed to work even if the set of C primitives used by stdlib has changed.

However, in the current state, the procedure does not work and fails in the last "coreboot" phase.

I think we should solve this issue by either updating the doc of this bootstrap procedure, or even removing it (but then how one should do ?) or fixing the makefile.

Moreover, I think it would be good to test that this keep working in the future by adding a test in the CI. This is not the first time it breaks.
Steps To ReproduceIn current trunk:

$ ./configure
$ make world
<start of hard bootstarp procedure as stated in Makefile:>
$ make coreboot
[add a primitive in the runtime, add call it from the stdlib]
$ make clean runtime coreall
$ make coreboot
< fails with :
     ../boot/ocamlrun ../boot/ocamlc -nostdlib -I ../boot -use-prims ../byterun/primitives -I .. -o make_opcodes
     File "", line 1:
     Error: Error while linking ../boot/stdlib.cma(Pervasives):
     The external function `caml_foo' is not available

FWIW, the changes I made in my test to add the new primitive are:

diff --git a/byterun/misc.c b/byterun/misc.c
index 46e40992b..bd2b7a441 100644
--- a/byterun/misc.c
+++ b/byterun/misc.c
@@ -51,6 +51,11 @@ void caml_set_fields (value v, unsigned long start, unsigned long filler)
 #endif /* DEBUG */
+CAMLprim value caml_foo(value x)
+ return x;
 uintnat caml_verb_gc = 0;
 void caml_gc_message (int level, char *msg, ...)
diff --git a/stdlib/ b/stdlib/
index faa421871..69b2cdb78 100644
--- a/stdlib/
+++ b/stdlib/
@@ -546,3 +546,9 @@ let exit retcode =
   sys_exit retcode
 let _ = register_named_value "Pervasives.do_at_exit" do_at_exit
+external foo : int -> int = "caml_foo"
+let _ = ignore (foo 5)
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
nojebar (developer)
2017-12-11 12:02

I do not know whether the hard bootstrap procedure is currently working or not, but I believe your error is not related to that.

Indeed primitives are currently expected to be defined in the files listed in the PRIMS variable in byterun/Makefile, which does not currently contain misc.c.

It would be great if you could try adding misc.c to PRIMS and post back whether the bootstrap procedure is working or not.
jacques-henri.jourdan (manager)
2017-12-11 21:56

Alright, I should not have defined caml_foo in misc.c.

If I define it in array.c instead, I get another error, *earlier*:

$ make coreall
boot/ocamlrun tools/make_opcodes -opcodes < byterun/caml/instruct.h > bytecomp/
Fatal error: unknown C primitive `caml_foo'
nojebar (developer)
2017-12-11 22:29

Did you start the process from the beginning or try to continue from the bootstrap process you had started before? If the latter, could you test starting from a fresh repository (you can do git clean -fdx from the repository root to make sure you are starting from zero).

Also, note that the bootstrap instructions have been refreshed recently ( [^]), but if I am not mistaken simply adding a primitive should work even with the old instructions.
jacques-henri.jourdan (manager)
2017-12-11 23:16

> Also, note that the bootstrap instructions have been refreshed recently ( [^] [^]), but if I am not mistaken simply adding a primitive should work even with the old instructions.

Ok, I was not aware of this recent change (merged yesterday ! that's a data race, actually). It indeed works with the current instructions.

Thanks, and sorry for the noise.

- Issue History
Date Modified Username Field Change
2017-12-07 17:38 jacques-henri.jourdan New Issue
2017-12-11 12:02 nojebar Note Added: 0018738
2017-12-11 21:56 jacques-henri.jourdan Note Added: 0018739
2017-12-11 22:29 nojebar Note Added: 0018740
2017-12-11 23:16 jacques-henri.jourdan Note Added: 0018741
2017-12-11 23:17 jacques-henri.jourdan Status new => closed
2017-12-11 23:17 jacques-henri.jourdan Assigned To => jacques-henri.jourdan
2017-12-11 23:17 jacques-henri.jourdan Resolution open => no change required

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker