caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: David Allsopp <dra-news@metastack.com>
To: "caml-list@inria.fr" <caml-list@inria.fr>
Subject: RE: [Caml-list] external function with arity > 5 and "noalloc"
Date: Thu, 22 Aug 2013 08:44:06 +0000	[thread overview]
Message-ID: <E51C5B015DBD1348A1D85763337FB6D9CCB3F5E1@Remus.metastack.local> (raw)
In-Reply-To: <CAE1DttCqPe=4odArkPFpAK4zNX2_KEbEd02BLxAv-S1NzLqs5g@mail.gmail.com>

Florent Monnier wrote:
> Hi,
> 
> I'm not sure if this behavior is a bug or not.
> Here a given function defined in a stub:
> 
> cat > bind.ml <<EOF
> external f :
>   v1:int ->
>   v2:int ->
>   v3:int ->
>   v4:int ->
>   v5:int ->
>   v6:int -> int
>   = "bind_f"
>     "bind_f_bc"
>     "noalloc"
> EOF

The naming you're using here implies you've got these the wrong way around - the bytecode stub comes first (I'm assuming that's what _bc means) - see 19.1.2 in the manual.

> if compiles fine with all warnings on:
> ocamlopt -c -w +A -warn-error +A bind.ml
> 
> if will also compile fine with:
>   = "bind_f"
>     "bind_f_bc"
> 
> if I put only:
>   = "bind_f"
> 
> I get a compilation error, which is what I expected:
> 
> ocamlopt -c -w +A -warn-error +A bind.ml
> 
> File "bind.ml", line 2, characters 2-75:
> Error: An external function with more than 5 arguments requires
>   a second stub function for native-code compilation
> 
> 
> But now if I write this way:
>   = "bind_f"
>     "noalloc"
> then I get no compile error anymore.

This isn't a bug - are you able to link the executable? What you've specified is an external f using a function bind_f for bytecode and noalloc for native code - unless there is a symbol noalloc knocking around somewhere in the runtime, I'd expect you to get a linking error with ocamlopt and either a linking error or a runtime segfault with ocamlc (because of using bind_f not bind_f_bc).

"noalloc" as a string rather than a keyword is a bit of a hack (though I'm sure there's a logical reason it was done that way - although it does just look a teensy bit lazy as it means the grammar for external is simply a string list!). What is a bug is that noalloc isn't mentioned in Chapter 19 of the manual (similarly for "float" which can also be specified).


David 


      reply	other threads:[~2013-08-22  8:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-21 16:37 Florent Monnier
2013-08-22  8:44 ` David Allsopp [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=E51C5B015DBD1348A1D85763337FB6D9CCB3F5E1@Remus.metastack.local \
    --to=dra-news@metastack.com \
    --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).