caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: rixed@happyleptic.org
To: caml-list@inria.fr
Subject: Re: [Caml-list] compiling custom runtime
Date: Sat, 20 Jul 2013 13:36:24 +0200	[thread overview]
Message-ID: <20130720113624.GA14182@dell.happyleptic.org> (raw)
In-Reply-To: <20130719154909.GA29399@dell.happyleptic.org>

[-- 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

      reply	other threads:[~2013-07-20 11:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-19 15:49 rixed
2013-07-20 11:36 ` rixed [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130720113624.GA14182@dell.happyleptic.org \
    --to=rixed@happyleptic.org \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).