inhabitedtype / bigstringaf

Bigstring intrinsics and fast blits based on memcpy/memmove
Other
37 stars 15 forks source link

Unbound module Bigstringaf #41

Closed ichigoXZ closed 4 years ago

ichigoXZ commented 4 years ago

After installed, I tried to use in ocaml. test passed, and I can find it in ocamlfind list Anything wrong? sorry I am new in ocaml.

>ocaml
        OCaml version 4.09.0

# open Bigstringaf;;
Error: Unbound module Bigstringaf
# require "Bigstringaf";;
Error: Unbound value require

I have the same problem in mirageos.

Have this installed following:

opam pin add -n bigstringaf .
opam install --deps-only bigstringaf
opam install bigstringaf
dinosaure commented 4 years ago

Anything wrong? sorry I am new in ocaml.

To load a library in OCaml, we use #require (instead require). Then, you should differ the name of the library bigstringaf (which is not capitalized) and the module Bigstringaf (which is capitalized anytime). So this code should works:

$ ocaml
        OCaml version 4.08.1

# #require "bigstringaf" ;;
# #show Bigstringaf ;;
...

Then, about MirageOS, the problem can be more specific and I need more information to help you :+1: like which target you want to use (unix, hvt, xen ... ?) and a view of your config.ml.

ichigoXZ commented 4 years ago

@dinosaure Thank you so much. now I can run functions in ocaml and I have learnt more about writing Ocaml.

and then I tried in mirageos hvt, ===config.ml===

open Mirage

let main =
  foreign
    ~packages:[package "duration"; package "bigstringaf"]
    "Unikernel.Main" (console @-> time @-> job)

let () =
  register "console" [main $ default_console $ default_time ]

I tried Bigstringaf.memcpy but it seems that I can not get the result and mirageos just exits. Afraid of having passed wrong parameters, I write a simple function inbigstringaf_stubs.c which returns an int and it runs well using ocaml. added in bigstringaf.ml

external send_an_int: int -> int = "get_an_int" [@@noalloc]

let get_return_value x =
    send_an_int x
;;

but still, I can not get any result from Bigstringaf.get_return_value before solo5_exit(0) called.

dinosaure commented 4 years ago

The compilation of C stubs with MirageOS is little bit trickier and depends on your context mostly. In fact, if you look into bigstringaf, it has two sub-directory freestanding and xen where we want to compile bigstringaf_stubs.c with some specific flags (according the target - about hvt, we use freestanding).

Then, when you compile your unikernel, it will uses bigstringaf.{freestanding,xen} instead bigstringaf according the META file provided by the distribution.

So I would like to say that any update of bigstringaf should be back to OPAM (with opam pin) and then, your change will be available. However. your issue is out of the scope of bigstringaf as far as know and you should probably make an issue into mirage/mirage - and we will be able to help you then :+1:.

ichigoXZ commented 4 years ago

@dinosaure OK, I think I figrue out how it works now.

You're right, further problems should be disscussed in mirage, thanks for your help and I would close this issue.