From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 1B3717FC86 for ; Thu, 19 Mar 2015 22:36:42 +0100 (CET) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of kennethadammiller@gmail.com) identity=pra; client-ip=209.85.214.182; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="kennethadammiller@gmail.com"; x-sender="kennethadammiller@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of kennethadammiller@gmail.com designates 209.85.214.182 as permitted sender) identity=mailfrom; client-ip=209.85.214.182; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="kennethadammiller@gmail.com"; x-sender="kennethadammiller@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-ob0-f182.google.com) identity=helo; client-ip=209.85.214.182; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="kennethadammiller@gmail.com"; x-sender="postmaster@mail-ob0-f182.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0BuAAD+QAtVm7bWVdFcg1haBIMJuT+JYIV5AoFCB0wBAQEBAQERAQEBAQEGCwsJFC6EDwEBAQMBEhEdARseAwELBgMCCw0qAgIhAQERAQUBHAYBEggah3gBAwkIDZUmkFY+MYsxgWuCd5EaChknDVSEXQEBAQcBAQEBAQEWAQUOiwmCRIIpC4JogUUFhhaOJIQzgUyBGzqLYUyCX4F9EiOBDAmCJByBbCIxgkMBAQE X-IPAS-Result: A0BuAAD+QAtVm7bWVdFcg1haBIMJuT+JYIV5AoFCB0wBAQEBAQERAQEBAQEGCwsJFC6EDwEBAQMBEhEdARseAwELBgMCCw0qAgIhAQERAQUBHAYBEggah3gBAwkIDZUmkFY+MYsxgWuCd5EaChknDVSEXQEBAQcBAQEBAQEWAQUOiwmCRIIpC4JogUUFhhaOJIQzgUyBGzqLYUyCX4F9EiOBDAmCJByBbCIxgkMBAQE X-IronPort-AV: E=Sophos;i="5.11,432,1422918000"; d="scan'208";a="104045923" Received: from mail-ob0-f182.google.com ([209.85.214.182]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 19 Mar 2015 22:36:40 +0100 Received: by obdfc2 with SMTP id fc2so64915491obd.3 for ; Thu, 19 Mar 2015 14:36:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=hRVuA9sxZwh7h2xnLRGcFzZzbgBlTJ3ytUOy+afun+A=; b=rx2QlP0qB6yt90CnGEsbxaJb1/NPU/97ArAk3K7D0zchbbKQrFB5KlwFU8S+Dfn8vj y/i49Ac7/RzoZ3VVh4pCOyp3beBRvHKW88gKfqAxHQb450jPbXgMU4tOSD7BDavQkMa/ Tsy1dJg3pBwbenD9gACEdGWmigRbHjlmkrAY+7vMBy5V2I9k8bdoyojZ2h66nCfCq5Lx ffmxU3ZR0GVwgiw2W0ytM0NlB+5CnpbiUewzLzN0E36SB0zCfN1I7Zxza6uRUNLsrhmH o948YtdY7G9zi8vlbz7Uc1YvENTgln0UiuhAnF5wRxawdqGqoW6zxqSbvyO9NGgy5z0K ts5A== MIME-Version: 1.0 X-Received: by 10.202.213.214 with SMTP id m205mr5641616oig.52.1426800999358; Thu, 19 Mar 2015 14:36:39 -0700 (PDT) Received: by 10.202.185.8 with HTTP; Thu, 19 Mar 2015 14:36:39 -0700 (PDT) In-Reply-To: References: Date: Thu, 19 Mar 2015 17:36:39 -0400 Message-ID: From: Kenneth Adam Miller To: caml users , Anton Lavrik Content-Type: multipart/alternative; boundary=001a11431776bb66ed0511aafe73 Subject: Re: [Caml-list] Utop Difficulties with C callbacks --001a11431776bb66ed0511aafe73 Content-Type: text/plain; charset=UTF-8 Well, I gave this a shot, and got more errors. I'm going to list what I did, and then copy the errors, and then I'm out for the day. git clone https://github.com/alavrik/piqi.git cd piqi/piqilib make && make ocaml ocamlfind ocamlc -ccopt "-fPIC -DPIC -shared -DNATIVE_CODE -o piqi_c_impl.so " piqi_c_impl.c ocamlfind ocamlc -a -custom -dllib piqilib_stubs -o piqilib.cma piqi_version.cmo piqi_piqirun.cmo piqi_piqi.cmo piqloc.cmo piqi_util.cmo piq_ast.cmo piqi_impl_piqi.cmo piqi_boot.cmo piqi_c.cmo piqi_config.cmo piqi_iolist.cmo piqi_name.cmo piqi_common.cmo piqi_file.cmo piqi_command.cmo piqi_protobuf.cmo piqi_db.cmo piq_lexer.cmo piq_parser.cmo piq_gen.cmo piqi_objstore.cmo piqobj.cmo piqobj_common.cmo piqobj_to_protobuf.cmo piqobj_of_protobuf.cmo piqobj_to_piq.cmo piqobj_of_piq.cmo piq.cmo piqi.cmo piqi_pp.cmo piqi_json_parser.cmo piqi_json_gen.cmo piqi_json.cmo piqi_base64.cmo piqobj_to_json.cmo piqobj_of_json.cmo piqi_xml.cmo piqobj_to_xml.cmo piqobj_of_xml.cmo piqi_convert.cmo piqi_compile.cmo piqi_light.cmo piqi_getopt.cmo cp piqi_c_impl.so piqilib_stubs.so utop -require mylib (mylib being the bap package that was compiled with oasis where a BuildDepends: piqilib specified a need). ----------- Cannot load required shared library dllpiqilib_stubs. Reason: ./dllpiqilib_stubs.so: ./dllpiqilib_stubs.so: only ET_DYN and ET_EXEC can be loaded. Error: Reference to undefined global `Piqi_convert' On Thu, Mar 19, 2015 at 3:33 PM, Kenneth Adam Miller < kennethadammiller@gmail.com> wrote: > Thanks! I appreciate this so much! > > Gah, I skipped sleep in my determination to fix this. > > I will hit it with -dllib iteration. I love oasis, and I'm an avid user. > Piqi doesn't use oasis :( sadness. > > It does, however, already do the -custom approach, but only when compiling > the cma (I differentiate you said when building the executable). So I don't > know why it wouldn't work with that. In any case, I will take your advice > about the proper route. I'm all about quality and doing things right! > > On Thu, Mar 19, 2015 at 3:01 PM, Jeremie Dimino > wrote: > >> I have to run, but think the problem is that piqilib is not building a >> shared library for its C stubs: if you want to be able to load a >> library with C stubs in the toplevel, the stubs must be packed into a >> shared library. You normally do this with ocamlmklib and pass a -dllib >> option when building the .cma. oasis does all that automatically. >> >> This other option is to build the bytecode executable with -custom, >> which will link the C libraries, the ocamlrun executable and the >> bytecode into a single native executable. >> >> So simply adding -custom when building a custom utop should work. But >> the proper fix is to update piqilib to build a .so for its C stubs. >> >> >> >> On Thu, Mar 19, 2015 at 6:19 PM, Kenneth Adam Miller >> wrote: >> > So, I've been working for a while with a library and I've made a good >> > iteration. My code compiles and is nice, it does what is expected, but >> it >> > depends on a library, Piqi, that doesn't want to play nice in the >> > interpreter. I want to be a good citizen and do my homework and due >> > diligence, but nothing I do seems to make utop want to play nice with >> piqi. >> > >> > Here goes: >> > >> > When I execute utop -require mypackage repository with the newly built >> > package mypackage, but I get this error: >> > >> > File "_none_", line 1: >> > Error: The external function `camlidl_piqi_c_piqi_strtoull' is not >> available >> > >> > I checked out piqi locally, and pinned the package to my local build, >> where >> > I tried to ensure that the appropriate .c file is getting compiled and >> > linked into the cma and cmxa. They are without a shadow of a doubt. I >> then >> > thought maybe I would add an include directive to utop to tell it to >> pick up >> > the mli where the the external func : type = "name" is. Nope. >> > >> > I've done everything I can, from adding all combinations of additional >> > piqirun/piqilib/piqirun.pb/piqirun.ext combinations to the _oasis file >> that >> > specifies the serialization to trying to build my own utop to adding >> > additional require statements and include statements in the utop >> script. So >> > after trying to add the dependency to BuildDepends for myouterlib, I had >> > backed off to just adding the mylibrary to the specific binary that >> consumes >> > it, which is where my changes are (in that binary). >> > >> > I even went so far as to just try and get the changes compiled into a >> custom >> > utop. Nope. I got errors and errors; I built it with: >> > ocamlbuild -use-ocamlfind -pkg threads -pkg utop -pkg myouterlib -pkg >> camlp4 >> > -pkg core_kernel customtop.top >> > >> > (At the time I ran this, I had bap package's _oasis updated with the >> > appropriate compile BuildDepends so that it would link mylibrary too) >> > >> > and I had the let () = Utop_main.main ();; in "utopmain.ml" and >> customary >> > customtop.mltop containing just "Utopmain". I got: >> > >> > (Unbound value > which >> > is specified in -pkg!>) >> > >> > I don't know what else to do besides ship code that is watered down >> without >> > an interactive component. :/ >> >> >> >> -- >> Jeremie >> > > --001a11431776bb66ed0511aafe73 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Well, I gave this a shot, and got more errors. I'm goi= ng to list what I did, and then copy the errors, and then I'm out for t= he day.

cd piqi/piqilib=
make && make ocaml
ocamlfind ocamlc -ccopt &qu= ot;-fPIC -DPIC -shared -DNATIVE_CODE =C2=A0-o piqi_c_impl.so " piqi_c_= impl.c
ocamlfind ocamlc -a -custom =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 -dllib piqilib_stubs =C2=A0 =C2=A0-o piqilib.cma piqi_ver= sion.cmo piqi_piqirun.cmo piqi_piqi.cmo piqloc.cmo piqi_util.cmo piq_ast.cm= o piqi_impl_piqi.cmo piqi_boot.cmo piqi_c.cmo piqi_config.cmo piqi_iolist.c= mo piqi_name.cmo piqi_common.cmo piqi_file.cmo piqi_command.cmo piqi_protob= uf.cmo piqi_db.cmo piq_lexer.cmo piq_parser.cmo piq_gen.cmo piqi_objstore.c= mo piqobj.cmo piqobj_common.cmo piqobj_to_protobuf.cmo piqobj_of_protobuf.c= mo piqobj_to_piq.cmo piqobj_of_piq.cmo piq.cmo piqi.cmo piqi_pp.cmo piqi_js= on_parser.cmo piqi_json_gen.cmo piqi_json.cmo piqi_base64.cmo piqobj_to_jso= n.cmo piqobj_of_json.cmo piqi_xml.cmo piqobj_to_xml.cmo piqobj_of_xml.cmo p= iqi_convert.cmo piqi_compile.cmo piqi_light.cmo piqi_getopt.cmo
cp piqi_c_impl.so piqilib_stubs.so
utop -require mylib

(mylib being the bap package that was compiled with oasis= where a BuildDepends: piqilib specified a need).

= -----------
Cannot load required shared library dllpiqilib_stubs.= =C2=A0
Reason: ./dllpiqilib_stubs.so: ./dllpiqilib_stubs.so:= only ET_DYN and ET_EXEC can be loaded. =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0=C2=A0
Error: Reference to undefined global `Piqi_co= nvert'

On Thu, Mar 19, 2015 at 3:33 PM, Kenneth Adam Miller <k= ennethadammiller@gmail.com> wrote:
Thanks! I appreciate this so much!=C2=A0

<= /div>
Gah, I skipped sleep in my determination to fix this.
<= br>
I will hit it with -dllib iteration. I love oasis, and I'= m an avid user. Piqi doesn't use oasis :( sadness.

=
It does, however, already do the -custom approach, but only when compi= ling the cma (I differentiate you said when building the executable). So I = don't know why it wouldn't work with that. In any case, I will take= your advice about the proper route. I'm all about quality and doing th= ings right!

On Thu, Mar 19, 2015 at 3:0= 1 PM, Jeremie Dimino <jdimino@janestreet.com> wrote:
I have to run, but think the problem is tha= t piqilib is not building a
shared library for its C stubs: if you want to be able to load a
library with C stubs in the toplevel, the stubs must be packed into a
shared library. You normally do this with ocamlmklib and pass a -dllib
option when building the .cma. oasis does all that automatically.

This other option is to build the bytecode executable with -custom,
which will link the C libraries, the ocamlrun executable and the
bytecode into a single native executable.

So simply adding -custom when building a custom utop should work. But
the proper fix is to update piqilib to build a .so for its C stubs.



On Thu, Mar 19, 2015 at 6:19 PM, Kenneth Adam Miller
<kennet= hadammiller@gmail.com> wrote:
> So, I've been working for a while with a library and I've made= a good
> iteration. My code compiles and is nice, it does what is expected, but= it
> depends on a library, Piqi, that doesn't want to play nice in the<= br> > interpreter. I want to be a good citizen and do my homework and due
> diligence, but nothing I do seems to make utop want to play nice with = piqi.
>
> Here goes:
>
> When I execute utop -require mypackage repository with the newly built=
> package mypackage, but I get this error:
>
> File "_none_", line 1:
> Error: The external function `camlidl_piqi_c_piqi_strtoull' is not= available
>
> I checked out piqi locally, and pinned the package to my local build, = where
> I tried to ensure that the appropriate .c file is getting compiled and=
> linked into the cma and cmxa. They are without a shadow of a doubt. I = then
> thought maybe I would add an include directive to utop to tell it to p= ick up
> the mli where the the external func : type =3D "name" is. No= pe.
>
> I've done everything I can, from adding all combinations of additi= onal
> piqirun/piqilib/piqirun.pb/piqirun.ext combinations to the _oasis file= that
> specifies the serialization to trying to build my own utop to adding > additional require statements and include statements in the utop scrip= t. So
> after trying to add the dependency to BuildDepends for myouterlib, I h= ad
> backed off to just adding the mylibrary to the specific binary that co= nsumes
> it, which is where my changes are (in that binary).
>
> I even went so far as to just try and get the changes compiled into a = custom
> utop. Nope. I got errors and errors; I built it with:
> ocamlbuild -use-ocamlfind -pkg threads -pkg utop -pkg myouterlib -pkg = camlp4
> -pkg core_kernel customtop.top
>
> (At the time I ran this, I had bap package's _oasis updated with t= he
> appropriate compile BuildDepends so that it would link mylibrary too)<= br> >
> and I had the let () =3D Utop_main.main ();; in "utopmain.ml" and customary
> customtop.mltop containing just "Utopmain". I got:
>
> (Unbound value <everything I need *and* that's contained in myl= ibrary which
> is specified in -pkg!>)
>
> I don't know what else to do besides ship code that is watered dow= n without
> an interactive component. :/



--
Jeremie


--001a11431776bb66ed0511aafe73--