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

Hard bootstrap procedure is broken #7688

Closed
vicuna opened this issue Dec 7, 2017 · 4 comments
Closed

Hard bootstrap procedure is broken #7688

vicuna opened this issue Dec 7, 2017 · 4 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Dec 7, 2017

Original bug ID: 7688
Reporter: @jhjourdan
Assigned to: @jhjourdan
Status: closed (set by @jhjourdan on 2017-12-11T22:17:28Z)
Resolution: not a bug
Priority: normal
Severity: minor
Category: misc
Monitored by: @nojb @gasche @alainfrisch

Bug description

At 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 reproduce

In current trunk:

$ ./configure
$ make world

$ 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 .. make_opcodes.ml -o make_opcodes
File "make_opcodes.ml", 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/pervasives.ml b/stdlib/pervasives.ml
index faa421871..69b2cdb78 100644
--- a/stdlib/pervasives.ml
+++ b/stdlib/pervasives.ml
@@ -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)

@vicuna
Copy link
Author

vicuna commented Dec 11, 2017

Comment author: @nojb

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.

@vicuna
Copy link
Author

vicuna commented Dec 11, 2017

Comment author: @jhjourdan

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/opcodes.ml
Fatal error: unknown C primitive `caml_foo'

@vicuna
Copy link
Author

vicuna commented Dec 11, 2017

Comment author: @nojb

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 (#1434), but if I am not mistaken simply adding a primitive should work even with the old instructions.

@vicuna
Copy link
Author

vicuna commented Dec 11, 2017

Comment author: @jhjourdan

Also, note that the bootstrap instructions have been refreshed recently (#1434 [^]), 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.

@vicuna vicuna closed this as completed Dec 11, 2017
@vicuna vicuna added the bug label Mar 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant