caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Damien Doligez <damien.doligez@inria.fr>
To: caml-list <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] bytecode apps without stdlib/pervasives
Date: Thu, 17 Nov 2005 17:15:11 +0100	[thread overview]
Message-ID: <C8D1E7E1-06E7-4BC0-B624-2F2AE583ACBD@inria.fr> (raw)
In-Reply-To: <ad8cfe7e0511151445y40659b7ge191698147f30f59@mail.gmail.com>


On Nov 15, 2005, at 23:45, Jonathan Roewen wrote:

> Hi,
>
> I have a simple ML file (test.ml):
>
> external raise : exn -> 'a = "%raise";;
>
> raise End_of_file;;
>
> so I can check how the compiler does things (like if predefined ocaml
> symbols are still present without stdlib present), and compile as:
>
> ocamlc -nostdlib -nopervasives test.ml, which generates a.out.
>
> when I run it, I get error: "-bash: ./a.out: cannot execute binary
> file" (btw, generates expected behabiour without those flags)
>
> why can't it execute it? can we only use -nostdlib as long as we
> provide our own pervasives module?

Note that a.out is still a valid bytecode file:
   ocamlrun ./a.out
works.

What happens is that ocamlc tries to create an executable bytecode file,
by prepending the standard header (#!/usr/local/bin/ocamlrun) to your
bytecode file.  But it can't find this header because you have specified
-nostdlib, thus preventing it from looking in its library directory.

It explicitely ignores the "file not found" error, I'm not sure why.

What you can do is provide your own header file, named "camlheader", and
placed in one of the directories searched by ocamlc.  If you don't give
any -I option, this has to be the current directory:

$ echo '#!/bin/echo foo' >camlheader
$ ocamlc -nostdlib -nopervasives test.ml
$ ./a.out
foo ./a.out

-- Damien


      parent reply	other threads:[~2005-11-17 16:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-15 22:45 Jonathan Roewen
2005-11-16  1:55 ` skaller
2005-11-17 16:15 ` Damien Doligez [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=C8D1E7E1-06E7-4BC0-B624-2F2AE583ACBD@inria.fr \
    --to=damien.doligez@inria.fr \
    --cc=caml-list@yquem.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).