caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] bytecode: ./prog vs ocamlrun ./prog
@ 2011-12-18  1:19 Dmitry Grebeniuk
  0 siblings, 0 replies; 7+ messages in thread
From: Dmitry Grebeniuk @ 2011-12-18  1:19 UTC (permalink / raw)
  To: caml-list

Hello.

  The OCaml manual states that executing bytecode program
with "./prog" and "ocamlrun ./prog" should give the same result
(in simple case, without options and environment modifications).
  However in my case the result is different: "./prog" executes
well, but "ocamlrun ./prog" gives
"Fatal error: unknown C primitive `unix_dup'".

  But I have no good minimal case (other small unix.cma-dependent
programs run fine both ways), and I can't show the full sources due
to my contract with employer.
  I suspect this issue can give me additional headache in the future,
so I prefer to solve it now.

  How can I find the source of this problem?

  What I have checked for now:
- host OS is linux (gentoo, fresh enough)
- the host contains (and contained ever) only one OCaml installation
  (3.11.2), and I can't install more recent OCaml versions
  system-wide (and I want this program to work under system-wide
  3.11.2 anywhere)
- ocaml toplevel doesn't fail on "#load "unix.cma"" and on calls to
  functions of Unix module
- this system doesn't provide ocamlobjinfo, so I can't read its output
- the program is built with ocamlbuild, without custom myocamlbuild.ml
  and other C-specific options, however some libraries may use
  C bindings (I'll check this if it is important)
- I've tried to set environment variable LD_DEBUG=libs and run
  both cases: "ocamlrun ./prog" output is pasted to
  http://paste.in.ua/3499/raw/ , "./prog" output is pasted to
  http://paste.in.ua/3500/raw/ , but I don't understand where
  the problem is, even after meditation on these logs

  What should I do to diagnose this problem?

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

* Re: [Caml-list] bytecode: ./prog vs ocamlrun ./prog
  2011-12-18 16:40     ` Dmitry Grebeniuk
@ 2011-12-18 16:49       ` Gerd Stolpmann
  0 siblings, 0 replies; 7+ messages in thread
From: Gerd Stolpmann @ 2011-12-18 16:49 UTC (permalink / raw)
  To: Dmitry Grebeniuk; +Cc: caml-list

Am Sonntag, den 18.12.2011, 18:40 +0200 schrieb Dmitry Grebeniuk:
> Hello.
> 
> >> So, this is a -custom linked bytecode executable.
> 
>   Thanks for clarifications about -custom and dynamic loading.
> 
> > ocamlc -o myrun -make-runtime unix.cma
> >
> > Then ./myrun prog should work (provided that Unix is the only missing
> > lib).
> 
>   Yes, it works (fails on the next required library).
>   But in my practice I've never needed -make-runtime.  What
> are the practical cases when -make-runtime is useful?

It's mostly useful on platforms where dynamic libraries are not
implemented. You can then at least create your own ocamlrun that is able
to run all your programs. There is a companion switch -use-runtime which
instructs to use a certain runtime when linking a program.

On platforms with dynamic libraries it is close to useless. (Well, if I
remember correctly, I'm using this feature in the GODI bootstrap to get
a distributed bytecode executable running on the local system, w/o
needing a complete ocaml infrastructure, but this is certainly a very
special case.)

Gerd
-- 
------------------------------------------------------------
Gerd Stolpmann, Darmstadt, Germany    gerd@gerd-stolpmann.de
Creator of GODI and camlcity.org.
Contact details:        http://www.camlcity.org/contact.html
Company homepage:       http://www.gerd-stolpmann.de
*** Searching for new projects! Need consulting for system
*** programming in Ocaml? Gerd Stolpmann can help you.
------------------------------------------------------------



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

* Re: [Caml-list] bytecode: ./prog vs ocamlrun ./prog
  2011-12-18 15:53   ` Gerd Stolpmann
@ 2011-12-18 16:40     ` Dmitry Grebeniuk
  2011-12-18 16:49       ` Gerd Stolpmann
  0 siblings, 1 reply; 7+ messages in thread
From: Dmitry Grebeniuk @ 2011-12-18 16:40 UTC (permalink / raw)
  To: Gerd Stolpmann

Hello.

>> So, this is a -custom linked bytecode executable.

  Thanks for clarifications about -custom and dynamic loading.

> ocamlc -o myrun -make-runtime unix.cma
>
> Then ./myrun prog should work (provided that Unix is the only missing
> lib).

  Yes, it works (fails on the next required library).
  But in my practice I've never needed -make-runtime.  What
are the practical cases when -make-runtime is useful?

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

* Re: [Caml-list] bytecode: ./prog vs ocamlrun ./prog
  2011-12-18 15:39 ` Dmitry Grebeniuk
@ 2011-12-18 15:53   ` Gerd Stolpmann
  2011-12-18 16:40     ` Dmitry Grebeniuk
  0 siblings, 1 reply; 7+ messages in thread
From: Gerd Stolpmann @ 2011-12-18 15:53 UTC (permalink / raw)
  To: Dmitry Grebeniuk; +Cc: Jacques Garrigue

Am Sonntag, den 18.12.2011, 17:39 +0200 schrieb Dmitry Grebeniuk:
> Hello.
> 
> > Do "head -1 prog" to see the right ocamlrun.
> 
>   Thank you, this really helped, but in the other way.
> I've found that this executable has ELF format.
> So, this is a -custom linked bytecode executable.
>   But I can't find anywhere in the documentation
> any information about whether can I / should I run
> such executables using ocamlrun or I can't / I shouldn't.
>   If the answer is "I can't / I shouldn't", then the problem
> is solved (and maybe I should report a
> documentation-related issue to mantis?).
> 

This explains it. An executable compiled with -custom is self-contained,
and all add-on C libraries (like Unix) are linked in. Because of this,
such an executable does not include a loader section for add-on
libraries, and you normally cannot run it with ocamlrun (except for the
corner case that no extra libraries are needed).

However, if you link without -custom, the generated bytecode includes
the information which extra libraries are needed, and ocamlrun will load
these libraries.

You can, however, run prog with a special version of ocamlrun that
statically links the extra libraries in. E.g. create a special ocamlrun
that includes Unix:

ocamlc -o myrun -make-runtime unix.cma

Then ./myrun prog should work (provided that Unix is the only missing
lib).

Gerd
-- 
------------------------------------------------------------
Gerd Stolpmann, Darmstadt, Germany    gerd@gerd-stolpmann.de
Creator of GODI and camlcity.org.
Contact details:        http://www.camlcity.org/contact.html
Company homepage:       http://www.gerd-stolpmann.de
*** Searching for new projects! Need consulting for system
*** programming in Ocaml? Gerd Stolpmann can help you.
------------------------------------------------------------



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

* Re: [Caml-list] bytecode: ./prog vs ocamlrun ./prog
  2011-12-18  4:30 Jacques Garrigue
  2011-12-18 15:20 ` oliver
@ 2011-12-18 15:39 ` Dmitry Grebeniuk
  2011-12-18 15:53   ` Gerd Stolpmann
  1 sibling, 1 reply; 7+ messages in thread
From: Dmitry Grebeniuk @ 2011-12-18 15:39 UTC (permalink / raw)
  To: Jacques Garrigue

Hello.

> Do "head -1 prog" to see the right ocamlrun.

  Thank you, this really helped, but in the other way.
I've found that this executable has ELF format.
So, this is a -custom linked bytecode executable.
  But I can't find anywhere in the documentation
any information about whether can I / should I run
such executables using ocamlrun or I can't / I shouldn't.
  If the answer is "I can't / I shouldn't", then the problem
is solved (and maybe I should report a
documentation-related issue to mantis?).

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

* Re: [Caml-list] bytecode: ./prog vs ocamlrun ./prog
  2011-12-18  4:30 Jacques Garrigue
@ 2011-12-18 15:20 ` oliver
  2011-12-18 15:39 ` Dmitry Grebeniuk
  1 sibling, 0 replies; 7+ messages in thread
From: oliver @ 2011-12-18 15:20 UTC (permalink / raw)
  To: Jacques Garrigue; +Cc: Dmitry Grebeniuk, caml-list

and with

 "which ocamlrun"

you get the info, which one is used.

Ciao,
   Oliver


On Sun, Dec 18, 2011 at 01:30:25PM +0900, Jacques Garrigue wrote:
> This basically means that you have 2 ocamlrun on this machine.
> ./prog calls ocamlrun with a fixed path, but the 1st ocamlrun is your
> path is an incompatible one.
> Do "head -1 prog" to see the right ocamlrun.
> 
> Jacques Garrigue
> 
> -----
> From: Dmitry Grebeniuk <gdsfh1@gmail.com>
> 
> Hello.
> 
>   The OCaml manual states that executing bytecode program
> with "./prog" and "ocamlrun ./prog" should give the same result
> (in simple case, without options and environment modifications).
>   However in my case the result is different: "./prog" executes
> well, but "ocamlrun ./prog" gives
> "Fatal error: unknown C primitive `unix_dup'".
> 
>   But I have no good minimal case (other small unix.cma-dependent
> programs run fine both ways), and I can't show the full sources due
> to my contract with employer.
>   I suspect this issue can give me additional headache in the future,
> so I prefer to solve it now.
> 
>   How can I find the source of this problem?
> 
>   What I have checked for now:
> - host OS is linux (gentoo, fresh enough)
> - the host contains (and contained ever) only one OCaml installation
>   (3.11.2), and I can't install more recent OCaml versions
>   system-wide (and I want this program to work under system-wide
>   3.11.2 anywhere)
> - ocaml toplevel doesn't fail on "#load "unix.cma"" and on calls to
>   functions of Unix module
> - this system doesn't provide ocamlobjinfo, so I can't read its output
> - the program is built with ocamlbuild, without custom myocamlbuild.ml
>   and other C-specific options, however some libraries may use
>   C bindings (I'll check this if it is important)
> - I've tried to set environment variable LD_DEBUG=libs and run
>   both cases: "ocamlrun ./prog" output is pasted to
>   http://paste.in.ua/3499/raw/ , "./prog" output is pasted to
>   http://paste.in.ua/3500/raw/ , but I don't understand where
>   the problem is, even after meditation on these logs
> 
>   What should I do to diagnose this problem?
> 
> -- 
> Caml-list mailing list.  Subscription management and archives:
> https://sympa-roc.inria.fr/wws/info/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
> 
> -- 
> Caml-list mailing list.  Subscription management and archives:
> https://sympa-roc.inria.fr/wws/info/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
> 

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

* RE: [Caml-list] bytecode: ./prog vs ocamlrun ./prog
@ 2011-12-18  4:30 Jacques Garrigue
  2011-12-18 15:20 ` oliver
  2011-12-18 15:39 ` Dmitry Grebeniuk
  0 siblings, 2 replies; 7+ messages in thread
From: Jacques Garrigue @ 2011-12-18  4:30 UTC (permalink / raw)
  To: Dmitry Grebeniuk, caml-list

This basically means that you have 2 ocamlrun on this machine.
./prog calls ocamlrun with a fixed path, but the 1st ocamlrun is your
path is an incompatible one.
Do "head -1 prog" to see the right ocamlrun.

Jacques Garrigue

-----
From: Dmitry Grebeniuk <gdsfh1@gmail.com>

Hello.

  The OCaml manual states that executing bytecode program
with "./prog" and "ocamlrun ./prog" should give the same result
(in simple case, without options and environment modifications).
  However in my case the result is different: "./prog" executes
well, but "ocamlrun ./prog" gives
"Fatal error: unknown C primitive `unix_dup'".

  But I have no good minimal case (other small unix.cma-dependent
programs run fine both ways), and I can't show the full sources due
to my contract with employer.
  I suspect this issue can give me additional headache in the future,
so I prefer to solve it now.

  How can I find the source of this problem?

  What I have checked for now:
- host OS is linux (gentoo, fresh enough)
- the host contains (and contained ever) only one OCaml installation
  (3.11.2), and I can't install more recent OCaml versions
  system-wide (and I want this program to work under system-wide
  3.11.2 anywhere)
- ocaml toplevel doesn't fail on "#load "unix.cma"" and on calls to
  functions of Unix module
- this system doesn't provide ocamlobjinfo, so I can't read its output
- the program is built with ocamlbuild, without custom myocamlbuild.ml
  and other C-specific options, however some libraries may use
  C bindings (I'll check this if it is important)
- I've tried to set environment variable LD_DEBUG=libs and run
  both cases: "ocamlrun ./prog" output is pasted to
  http://paste.in.ua/3499/raw/ , "./prog" output is pasted to
  http://paste.in.ua/3500/raw/ , but I don't understand where
  the problem is, even after meditation on these logs

  What should I do to diagnose this problem?

-- 
Caml-list mailing list.  Subscription management and archives:
https://sympa-roc.inria.fr/wws/info/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

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

end of thread, other threads:[~2011-12-18 16:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-18  1:19 [Caml-list] bytecode: ./prog vs ocamlrun ./prog Dmitry Grebeniuk
2011-12-18  4:30 Jacques Garrigue
2011-12-18 15:20 ` oliver
2011-12-18 15:39 ` Dmitry Grebeniuk
2011-12-18 15:53   ` Gerd Stolpmann
2011-12-18 16:40     ` Dmitry Grebeniuk
2011-12-18 16:49       ` Gerd Stolpmann

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