caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] compiling custom runtime
@ 2013-07-19 15:49 rixed
  2013-07-20 11:36 ` rixed
  0 siblings, 1 reply; 2+ messages in thread
From: rixed @ 2013-07-19 15:49 UTC (permalink / raw)
  To: caml-list

On trunk compiler, I'm trying to add a function to the runtime
but cannot get the ocaml to compile. make world stops on:

boot/ocamlrun boot/ocamlc -nostdlib -I boot  -compat-32 -o ocamlc \
           compilerlibs/ocamlcommon.cma compilerlibs/ocamlbytecomp.cma driver/main.cmo
File "_none_", line 1:
Error: Error while linking boot/stdlib.cma(Array):
The external function `caml_create_vect' is not available

(caml_create_vect being the name of the function I added).

I tried to make ocamlrun in byterun and copy it in boot but it didn't
solve the problem.

How to bootstrap the compiler with a new function?
Shouldn't this be documented in the README?


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] compiling custom runtime
  2013-07-19 15:49 [Caml-list] compiling custom runtime rixed
@ 2013-07-20 11:36 ` rixed
  0 siblings, 0 replies; 2+ messages in thread
From: rixed @ 2013-07-20 11:36 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 884 bytes --]

> boot/ocamlrun boot/ocamlc -nostdlib -I boot  -compat-32 -o ocamlc \
>            compilerlibs/ocamlcommon.cma compilerlibs/ocamlbytecomp.cma driver/main.cmo
> File "_none_", line 1:
> Error: Error while linking boot/stdlib.cma(Array):
> The external function `caml_create_vect' is not available

So, caml_create_vect is in boot/ocamlrun but the boot/ocamlc that's shipped
in the tarball apparently don't know how to reach it.

Evgeny Roubinchtein suggested me to read again the manual about mixing C and
ocaml, and so I tried to add the -use-runtime parameter and it solved this
issue. In my limited understanding of the bootstraping process this option
should really always be present when using the shipped boot/ocamlc.

This was not enough, though, to trick myocamlbuild, so eventualy I used a
shell wrapper around ocamlrun (see attached patch).

There ought to be a better way!

[-- Attachment #2: use-runtime --]
[-- Type: text/plain, Size: 1284 bytes --]

diff --git a/Makefile b/Makefile
index 10c80d2..0b1b1c6 100644
--- a/Makefile
+++ b/Makefile
@@ -174,7 +174,7 @@ LIBFILES=stdlib.cma std_exit.cmo *.cmi camlheader
 # Start up the system from the distribution compiler
 coldstart:
 	cd byterun; $(MAKE) all
-	cp byterun/ocamlrun$(EXE) boot/ocamlrun$(EXE)
+	cp byterun/ocamlrun$(EXE) boot/actual.ocamlrun$(EXE)
 	cd yacc; $(MAKE) all
 	cp yacc/ocamlyacc$(EXE) boot/ocamlyacc$(EXE)
 	cd stdlib; $(MAKE) COMPILER=../boot/ocamlc all
@@ -215,7 +215,7 @@ promote-cross:
 # Promote the newly compiled system to the rank of bootstrap compiler
 # (Runs on the new runtime, produces code for the new runtime)
 promote: promote-cross
-	cp byterun/ocamlrun$(EXE) boot/ocamlrun$(EXE)
+	cp byterun/ocamlrun$(EXE) boot/actual.ocamlrun$(EXE)
 
 # Restore the saved bootstrap compiler if a problem arises
 restore:
diff --git a/boot/ocamlrun b/boot/ocamlrun
new file mode 100755
index 0000000..fcb291c
--- /dev/null
+++ b/boot/ocamlrun
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+d=$(dirname $0)
+
+# Dodge ocamlrun own options by avoiding interfering in that case
+case "$1" in
+	-*) c="$1" ;;
+	*)  c=$(basename $1) ;;
+esac
+
+if test "$c" = ocamlc ; then
+	shift
+	$d/actual.ocamlrun $d/ocamlc -use-runtime $d/ocamlrun "$@"
+else
+	$d/actual.ocamlrun "$@"
+fi

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-07-20 11:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-19 15:49 [Caml-list] compiling custom runtime rixed
2013-07-20 11:36 ` rixed

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).