caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Problem native dynlink loading cryptokit
@ 2013-08-09  9:09 Maxence Guesdon
  2013-08-09  9:27 ` Stéphane Glondu
  0 siblings, 1 reply; 7+ messages in thread
From: Maxence Guesdon @ 2013-08-09  9:09 UTC (permalink / raw)
  To: caml-list

Hello,

I'm trying to dynamically load the cryptokit library in native mode.

Here is a test program:

cat > testload.ml
let _ = Dynlink.allow_unsafe_modules true;;

let load_file file =
  try Dynlink.loadfile (Dynlink.adapt_filename file)
  with Dynlink.Error e ->
      failwith (Dynlink.error_message e)

let () =
  match Array.to_list Sys.argv with
    [] | [_] -> prerr_endline "missing arguments"; exit 1
  | _ :: files -> List.iter load_file files

Compiling with
   ocamlopt -linkall -o testload dynlink.cmxa testload.ml

Then, running
  ./testload  ~/.opam/4.00.1/lib/ocaml/nums.cmxs \
      ~/.opam/4.00.1/lib/ocaml/unix.cmxs \
      ~/.opam/4.00.1/lib/cryptokit/cryptokit.cmxs

gives me the following error:

Fatal error: exception Failure("error loading shared
library: /home/guesdon/.opam/4.00.1/lib/cryptokit/cryptokit.cmxs:
undefined symbol: caml_sha1_init")

Am I doing something wrong ? Or is something missing in cryptokit
build ?

Thanks,

Maxence

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

* Re: [Caml-list] Problem native dynlink loading cryptokit
  2013-08-09  9:09 [Caml-list] Problem native dynlink loading cryptokit Maxence Guesdon
@ 2013-08-09  9:27 ` Stéphane Glondu
  2013-08-09  9:33   ` Maxence Guesdon
  0 siblings, 1 reply; 7+ messages in thread
From: Stéphane Glondu @ 2013-08-09  9:27 UTC (permalink / raw)
  To: Maxence Guesdon; +Cc: caml-list

Le 09/08/2013 11:09, Maxence Guesdon a écrit :
> Here is a test program:
> [...]
> gives me the following error:
> 
> Fatal error: exception Failure("error loading shared
> library: /home/guesdon/.opam/4.00.1/lib/cryptokit/cryptokit.cmxs:
> undefined symbol: caml_sha1_init")
> 
> Am I doing something wrong ? Or is something missing in cryptokit
> build ?

It works for me (with system packages).

caml_sha1_init should be in cryptokit.cmxs. The output of

  objdump -j .text -T /path/to/cryptokit.cmxs

should contain all the C functions defined in cryptokit, plus some
caml_curry* functions and camlCryptokit__* functions (compiled from
OCaml). Is it true for you?

-- 
Stéphane


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

* Re: [Caml-list] Problem native dynlink loading cryptokit
  2013-08-09  9:27 ` Stéphane Glondu
@ 2013-08-09  9:33   ` Maxence Guesdon
  2013-08-09  9:43     ` Stéphane Glondu
  0 siblings, 1 reply; 7+ messages in thread
From: Maxence Guesdon @ 2013-08-09  9:33 UTC (permalink / raw)
  To: caml-list

On Fri, 09 Aug 2013 11:27:03 +0200
Stéphane Glondu <steph@glondu.net> wrote:

> Le 09/08/2013 11:09, Maxence Guesdon a écrit :
> > Here is a test program:
> > [...]
> > gives me the following error:
> > 
> > Fatal error: exception Failure("error loading shared
> > library: /home/guesdon/.opam/4.00.1/lib/cryptokit/cryptokit.cmxs:
> > undefined symbol: caml_sha1_init")
> > 
> > Am I doing something wrong ? Or is something missing in cryptokit
> > build ?
> 
> It works for me (with system packages).
> 
> caml_sha1_init should be in cryptokit.cmxs. The output of
> 
>   objdump -j .text -T /path/to/cryptokit.cmxs
> 
> should contain all the C functions defined in cryptokit, plus some
> caml_curry* functions and camlCryptokit__* functions (compiled from
> OCaml). Is it true for you?

No, I only have camlCryptokit__sha1_init_3833 which I assume corresponds
to the function of src/cryptokit.ml:
 external sha1_init: unit -> string = "caml_sha1_init"

- m

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

* Re: [Caml-list] Problem native dynlink loading cryptokit
  2013-08-09  9:33   ` Maxence Guesdon
@ 2013-08-09  9:43     ` Stéphane Glondu
  2013-08-09  9:49       ` Maxence Guesdon
  0 siblings, 1 reply; 7+ messages in thread
From: Stéphane Glondu @ 2013-08-09  9:43 UTC (permalink / raw)
  To: Maxence Guesdon; +Cc: caml-list

Le 09/08/2013 11:33, Maxence Guesdon a écrit :
>>> Here is a test program:
>>> [...]
>>> gives me the following error:
>>>
>>> Fatal error: exception Failure("error loading shared
>>> library: /home/guesdon/.opam/4.00.1/lib/cryptokit/cryptokit.cmxs:
>>> undefined symbol: caml_sha1_init")
>>>
>>> Am I doing something wrong ? Or is something missing in cryptokit
>>> build ?
>>
>> It works for me (with system packages).
>>
>> caml_sha1_init should be in cryptokit.cmxs. The output of
>>
>>   objdump -j .text -T /path/to/cryptokit.cmxs
>>
>> should contain all the C functions defined in cryptokit, plus some
>> caml_curry* functions and camlCryptokit__* functions (compiled from
>> OCaml). Is it true for you?
> 
> No, I only have camlCryptokit__sha1_init_3833 which I assume corresponds
> to the function of src/cryptokit.ml:
>  external sha1_init: unit -> string = "caml_sha1_init"

Then, I suspect stubs were forgotten during the build of cryptokit.cmxs.
In the output of:

  ocamlobjinfo /path/to/cryptokit.cmxa

there should be the following lines:

  Extra C object files: -lcryptokit_stubs -lz
  Extra C options:

Do you have the same lines? If so, maybe -linkall is missing in the call
to ocamlopt -shared (the one that builds cryptokit.cmxs).


Cheers,

-- 
Stéphane


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

* Re: [Caml-list] Problem native dynlink loading cryptokit
  2013-08-09  9:43     ` Stéphane Glondu
@ 2013-08-09  9:49       ` Maxence Guesdon
  2013-08-09 12:13         ` Maxence Guesdon
  0 siblings, 1 reply; 7+ messages in thread
From: Maxence Guesdon @ 2013-08-09  9:49 UTC (permalink / raw)
  To: caml-list

On Fri, 09 Aug 2013 11:43:53 +0200
Stéphane Glondu <steph@glondu.net> wrote:

> Le 09/08/2013 11:33, Maxence Guesdon a écrit :
> >>> Here is a test program:
> >>> [...]
> >>> gives me the following error:
> >>>
> >>> Fatal error: exception Failure("error loading shared
> >>> library: /home/guesdon/.opam/4.00.1/lib/cryptokit/cryptokit.cmxs:
> >>> undefined symbol: caml_sha1_init")
> >>>
> >>> Am I doing something wrong ? Or is something missing in cryptokit
> >>> build ?
> >>
> >> It works for me (with system packages).
> >>
> >> caml_sha1_init should be in cryptokit.cmxs. The output of
> >>
> >>   objdump -j .text -T /path/to/cryptokit.cmxs
> >>
> >> should contain all the C functions defined in cryptokit, plus some
> >> caml_curry* functions and camlCryptokit__* functions (compiled from
> >> OCaml). Is it true for you?
> > 
> > No, I only have camlCryptokit__sha1_init_3833 which I assume corresponds
> > to the function of src/cryptokit.ml:
> >  external sha1_init: unit -> string = "caml_sha1_init"
> 
> Then, I suspect stubs were forgotten during the build of cryptokit.cmxs.
> In the output of:
> 
>   ocamlobjinfo /path/to/cryptokit.cmxa
> 
> there should be the following lines:
> 
>   Extra C object files: -lcryptokit_stubs -lz
>   Extra C options:
> 
> Do you have the same lines? If so, maybe -linkall is missing in the call
> to ocamlopt -shared (the one that builds cryptokit.cmxs).

These lines are present in the .cmxa. But, sutdying the build commands,
the .cmxs is produced from cryptokit.cmx, not cryptokit.cmxa. Running
by hand 
# camlfind ocamlopt -shared -I src  src/cryptokit.cmxa -linkall -o \
  src/cryptokit.cmxs

includes the missing code:
# objdump -j .text -T src/cryptokit.cmxs | grep sha1_init
0000000000037e2b g    DF .text 000000000000001b  Base caml_sha1_init

I will report to the cryptokit authors. Thansk for your help !

Cheers,

Maxence

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

* Re: [Caml-list] Problem native dynlink loading cryptokit
  2013-08-09  9:49       ` Maxence Guesdon
@ 2013-08-09 12:13         ` Maxence Guesdon
  2013-08-09 12:41           ` [Caml-list] " Sylvain Le Gall
  0 siblings, 1 reply; 7+ messages in thread
From: Maxence Guesdon @ 2013-08-09 12:13 UTC (permalink / raw)
  To: caml-list

On Fri, 9 Aug 2013 11:49:44 +0200
Maxence Guesdon <Maxence.Guesdon@inria.fr> wrote:

> On Fri, 09 Aug 2013 11:43:53 +0200
> Stéphane Glondu <steph@glondu.net> wrote:
> 
> > Le 09/08/2013 11:33, Maxence Guesdon a écrit :
> > >>> Here is a test program:
> > >>> [...]
> > >>> gives me the following error:
> > >>>
> > >>> Fatal error: exception Failure("error loading shared
> > >>> library: /home/guesdon/.opam/4.00.1/lib/cryptokit/cryptokit.cmxs:
> > >>> undefined symbol: caml_sha1_init")
> > >>>
> > >>> Am I doing something wrong ? Or is something missing in cryptokit
> > >>> build ?
> > >>
> > >> It works for me (with system packages).
> > >>
> > >> caml_sha1_init should be in cryptokit.cmxs. The output of
> > >>
> > >>   objdump -j .text -T /path/to/cryptokit.cmxs
> > >>
> > >> should contain all the C functions defined in cryptokit, plus some
> > >> caml_curry* functions and camlCryptokit__* functions (compiled from
> > >> OCaml). Is it true for you?
> > > 
> > > No, I only have camlCryptokit__sha1_init_3833 which I assume corresponds
> > > to the function of src/cryptokit.ml:
> > >  external sha1_init: unit -> string = "caml_sha1_init"
> > 
> > Then, I suspect stubs were forgotten during the build of cryptokit.cmxs.
> > In the output of:
> > 
> >   ocamlobjinfo /path/to/cryptokit.cmxa
> > 
> > there should be the following lines:
> > 
> >   Extra C object files: -lcryptokit_stubs -lz
> >   Extra C options:
> > 
> > Do you have the same lines? If so, maybe -linkall is missing in the call
> > to ocamlopt -shared (the one that builds cryptokit.cmxs).
> 
> These lines are present in the .cmxa. But, sutdying the build commands,
> the .cmxs is produced from cryptokit.cmx, not cryptokit.cmxa. Running
> by hand 
> # camlfind ocamlopt -shared -I src  src/cryptokit.cmxa -linkall -o \
>   src/cryptokit.cmxs

For the records, as suggested by Sylvain Le Gall, adding
use_libcryptokit_stubs in the _tags file to get:

  "src/cryptokit.cmxs": use_cryptokit, use_libcryptokit_stubs

also produced a .cmxs file with the C part.

- m

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

* [Caml-list] Re: Problem native dynlink loading cryptokit
  2013-08-09 12:13         ` Maxence Guesdon
@ 2013-08-09 12:41           ` Sylvain Le Gall
  0 siblings, 0 replies; 7+ messages in thread
From: Sylvain Le Gall @ 2013-08-09 12:41 UTC (permalink / raw)
  To: caml-list

On 09-08-2013, Maxence Guesdon <Maxence.Guesdon@inria.fr> wrote:
> On Fri, 9 Aug 2013 11:49:44 +0200
> Maxence Guesdon <Maxence.Guesdon@inria.fr> wrote:
>
>> On Fri, 09 Aug 2013 11:43:53 +0200
>> Stéphane Glondu <steph@glondu.net> wrote:
>> 
>> > Le 09/08/2013 11:33, Maxence Guesdon a écrit :
>> > >>> Here is a test program:
>> > >>> [...]
>> > >>> gives me the following error:
>> > >>>
>> > >>> Fatal error: exception Failure("error loading shared
>> > >>> library: /home/guesdon/.opam/4.00.1/lib/cryptokit/cryptokit.cmxs:
>> > >>> undefined symbol: caml_sha1_init")
>> > >>>
>> > >>> Am I doing something wrong ? Or is something missing in cryptokit
>> > >>> build ?
>> > >>
>> > >> It works for me (with system packages).
>> > >>
>> > >> caml_sha1_init should be in cryptokit.cmxs. The output of
>> > >>
>> > >>   objdump -j .text -T /path/to/cryptokit.cmxs
>> > >>
>> > >> should contain all the C functions defined in cryptokit, plus some
>> > >> caml_curry* functions and camlCryptokit__* functions (compiled from
>> > >> OCaml). Is it true for you?
>> > > 
>> > > No, I only have camlCryptokit__sha1_init_3833 which I assume corresponds
>> > > to the function of src/cryptokit.ml:
>> > >  external sha1_init: unit -> string = "caml_sha1_init"
>> > 
>> > Then, I suspect stubs were forgotten during the build of cryptokit.cmxs.
>> > In the output of:
>> > 
>> >   ocamlobjinfo /path/to/cryptokit.cmxa
>> > 
>> > there should be the following lines:
>> > 
>> >   Extra C object files: -lcryptokit_stubs -lz
>> >   Extra C options:
>> > 
>> > Do you have the same lines? If so, maybe -linkall is missing in the call
>> > to ocamlopt -shared (the one that builds cryptokit.cmxs).
>> 
>> These lines are present in the .cmxa. But, sutdying the build commands,
>> the .cmxs is produced from cryptokit.cmx, not cryptokit.cmxa. Running
>> by hand 
>> # camlfind ocamlopt -shared -I src  src/cryptokit.cmxa -linkall -o \
>>   src/cryptokit.cmxs
>
> For the records, as suggested by Sylvain Le Gall, adding
> use_libcryptokit_stubs in the _tags file to get:
>
>   "src/cryptokit.cmxs": use_cryptokit, use_libcryptokit_stubs
>
> also produced a .cmxs file with the C part.
>

FTR, this is an OASIS bug:
https://forge.ocamlcore.org/tracker/index.php?func=detail&aid=1304&group_id=54&atid=291

It will be quickly fixed in cryptokit and later the fix will be included
in OASIS itself so the next version of OASIS will fix this bug for all
OASIS enabled packages.

Cheers
Sylvain

--
Website:     http://sylvain.le-gall.net/
OCaml forge: http://forge.ocamlcore.org
OCaml blogs: http://planet.ocaml.org


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

end of thread, other threads:[~2013-08-09 12:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-09  9:09 [Caml-list] Problem native dynlink loading cryptokit Maxence Guesdon
2013-08-09  9:27 ` Stéphane Glondu
2013-08-09  9:33   ` Maxence Guesdon
2013-08-09  9:43     ` Stéphane Glondu
2013-08-09  9:49       ` Maxence Guesdon
2013-08-09 12:13         ` Maxence Guesdon
2013-08-09 12:41           ` [Caml-list] " Sylvain Le Gall

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).