caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Build OCaml on linux
@ 2012-09-20 19:50 Zhi Han
  2012-09-22 19:52 ` Kristopher Micinski
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Zhi Han @ 2012-09-20 19:50 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 639 bytes --]

Hi,

I found that the OCaml executable "bin/ocaml" is built by default as an bytecode on Linux, i.e., it requires 'bin/ocamlrun" to run it. This has caused some issues in our group because our build process copies the executables from place to place. When the files are moved, the old location of the file is left in the first line of the bytecode file.

However, same issues does not exists on Windows build. The files are built as executables and we can move these files around and still be able to execute them. I am wondering what are the switches that makes the Windows build work. Can somebody help me with that? Thanks,

Zhi

[-- Attachment #2: Type: text/html, Size: 2684 bytes --]

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

* Re: [Caml-list] Build OCaml on linux
  2012-09-20 19:50 [Caml-list] Build OCaml on linux Zhi Han
@ 2012-09-22 19:52 ` Kristopher Micinski
       [not found] ` <sympa.1348346044.7674.559@inria.fr>
  2012-09-25  9:25 ` Fabrice Le Fessant
  2 siblings, 0 replies; 6+ messages in thread
From: Kristopher Micinski @ 2012-09-22 19:52 UTC (permalink / raw)
  To: Zhi Han; +Cc: caml-list

From the INSTALL notes
(http://caml.inria.fr/pub/distrib/ocaml-3.12/notes/INSTALL) ...

4- If your platform is supported by the native-code compiler (as
reported during the autoconfiguration), you can now build the
native-code compiler. From the top directory, do:

        make opt
or:
        make opt > log.opt 2>&1     # in sh
        make opt >& log.opt         # in csh

Is that the sort of thing for which you're looking?

kris


On Thu, Sep 20, 2012 at 3:50 PM, Zhi Han <Zhi.Han@mathworks.com> wrote:
> Hi,
>
>
>
> I found that the OCaml executable “bin/ocaml” is built by default as an
> bytecode on Linux, i.e., it requires ‘bin/ocamlrun” to run it. This has
> caused some issues in our group because our build process copies the
> executables from place to place. When the files are moved, the old location
> of the file is left in the first line of the bytecode file.
>
>
>
> However, same issues does not exists on Windows build. The files are built
> as executables and we can move these files around and still be able to
> execute them. I am wondering what are the switches that makes the Windows
> build work. Can somebody help me with that? Thanks,
>
>
>
> Zhi

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

* Re: [Caml-list] Build OCaml on linux
       [not found] ` <sympa.1348346044.7674.559@inria.fr>
@ 2012-09-23  0:33   ` Edgar Friendly
  2012-09-23  0:56     ` Wojciech Meyer
       [not found]   ` <04644211E51C7E40BF64101089F97E4D0A7B38C9@exmb-01-ah.ad.mathworks.com>
  1 sibling, 1 reply; 6+ messages in thread
From: Edgar Friendly @ 2012-09-23  0:33 UTC (permalink / raw)
  To: caml-list

On 9/22/2012 4:58 PM, Didier Cassirame wrote:
> The first line of the bytecode executable is just a hint for the shell to
> locate the bytecode interpreter.
it might not hurt to have the default hint to the shell be: 
#!/usr/bin/env ocamlrun
This would make it harder to have multiple OCaml installations and run 
the compiler of one while the PATH is set to the other, but this is a 
pretty edge case.  Is there any other problem with doing this?

E.

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

* Re: [Caml-list] Build OCaml on linux
  2012-09-23  0:33   ` Edgar Friendly
@ 2012-09-23  0:56     ` Wojciech Meyer
  0 siblings, 0 replies; 6+ messages in thread
From: Wojciech Meyer @ 2012-09-23  0:56 UTC (permalink / raw)
  To: Edgar Friendly; +Cc: caml-list

Edgar Friendly <thelema314@gmail.com> writes:

> On 9/22/2012 4:58 PM, Didier Cassirame wrote:
>> The first line of the bytecode executable is just a hint for the shell to
>> locate the bytecode interpreter.
> it might not hurt to have the default hint to the shell be:
> #!/usr/bin/env ocamlrun
> This would make it harder to have multiple OCaml installations and run
> the compiler of one while the PATH is set to the other, but this is a
> pretty edge case.  Is there any other problem with doing this?

No there is no other problem, but if you want to run an image with a
different compiler in a different root, just use different ocamlrun.

>
> E.

--
Wojciech Meyer
http://danmey.org

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

* Re: [Caml-list] Build OCaml on linux
       [not found]     ` <CA+LkvyqbZxzY=Coj7v_XnkSBDyN8wGuQP9ZB41bCBHqsE6XfcQ@mail.gmail.com>
@ 2012-09-25  0:36       ` Francois Berenger
  0 siblings, 0 replies; 6+ messages in thread
From: Francois Berenger @ 2012-09-25  0:36 UTC (permalink / raw)
  To: caml-list

Did someone mentioned ocamlbrew in order to perform installation
automatically?

https://github.com/hcarty/ocamlbrew

It also installs a few useful stuffs (oasis, odb, etc.).
This is what I use in our lab to install OCaml in user's home
in case they have a non Debian-like Linux distro.

Regards,
F.

On 09/25/2012 06:42 AM, Didier Cassirame wrote:
> Hi,
>
> First of, my apologies, I made a few mistakes in my previous message,
> which probably contributed to confuse everyone:
> - the -stdlib parameter doesn't exist, the correct parameter is "-I
> <path/to/stdlib>"
> - I actually cannot tell if the ocamlrun binary relies on a bytecode
> executable version number (that said a version number exists in compiled
> libraries),
>
> Regarding your problem, according to my own tests, it is not safe to
> change the shebang line in bytecode executables. It is
> preferable to explicitely launch a bytecode program with the interpreter
> corresponding to the compiler used to build the program.
>
> Sorry again for the generated confusion,
>
> didier
>
> 2012/9/24 Zhi Han <Zhi.Han@mathworks.com <mailto:Zhi.Han@mathworks.com>>
>
>     Hi,
>
>     Thanks everyone for the help so far. I was going through the
>     Makefile and it appears that there is a native target 'ocamlnat'. If
>     I do 'make ocamlnat' after 'make world.opt' that should create a
>     native executable toplevel that does not require 'ocamlrun', right?
>     It is a little odd because I presume 'make world.opt' would make all
>     native targets.
>
>     The workflow we want to support is:
>     Build OCaml from source on a machine and copy the installation to a
>     server.
>
>     1) Store the OCaml at a shared file server, so that users can setup
>     a few environment variables to use the shared OCaml.
>
>     2) When the users have intermittent network problems, they shall be
>     able to copy the network version to their machine and setup the
>     environment to use the local version.
>
>     Having the byte code really adds complexity to these workflows. Is
>     it safe to simply edit the bytecode to modify the first line?
>
>     Zhi
>
>     -----Original Message-----
>     From: Didier Cassirame [mailto:didier.cassirame@gmail.com
>     <mailto:didier.cassirame@gmail.com>]
>     Sent: Saturday, September 22, 2012 4:59 PM
>     To: Zhi Han; caml-list@inria.fr <mailto:caml-list@inria.fr>
>     Subject: Re: [Caml-list] Build OCaml on linux
>
>     Hello Zhi and Everyone,
>
>     The first line of the bytecode executable is just a hint for the
>     shell to locate the bytecode interpreter. Nothing stops you from
>     running a given bytecode executable with the interpreter of your
>     choice, provided it supports the file revision of said executable.
>
>     So, you have two options :
>     the first one is to keep track of the location of the ocamlrun
>     binary, and prepend every command line running ocaml, ocamlc,
>     ocamlopt with the full path to ocamlrun, i.e. :
>
>     $ /path/to/ocamlrun ocamlc myfile.ml <http://myfile.ml>
>
>     instead of
>
>     $ ocamlc myfile.ml <http://myfile.ml>
>
>     You may have to give the full path to ocamlc as well, and perhaps
>     also indicate the location of the stdlib if they are also moved from
>     their default location (use the -stdlib command line parameter of
>     ocamlc).
>
>     The second option is to recompile the ocaml software from source
>     (you are perhaps already doing that, if you are moving the
>     executables around), specifying the final install location of the
>     binaries at the configuration step (see INSTALL in the source tar ball).
>
>     cheers,
>
>     didier
>
>


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

* Re: [Caml-list] Build OCaml on linux
  2012-09-20 19:50 [Caml-list] Build OCaml on linux Zhi Han
  2012-09-22 19:52 ` Kristopher Micinski
       [not found] ` <sympa.1348346044.7674.559@inria.fr>
@ 2012-09-25  9:25 ` Fabrice Le Fessant
  2 siblings, 0 replies; 6+ messages in thread
From: Fabrice Le Fessant @ 2012-09-25  9:25 UTC (permalink / raw)
  To: caml-list

Hi,

On 09/20/2012 09:50 PM, Zhi Han wrote:
> I found that the OCaml executable “bin/ocaml” is built by default as an
> bytecode on Linux, i.e., it requires ‘bin/ocamlrun” to run it. This has
> caused some issues in our group because our build process copies the
> executables from place to place. When the files are moved, the old
> location of the file is left in the first line of the bytecode file.
>
> However, same issues does not exists on Windows build. The files are
> built as executables and we can move these files around and still be
> able to execute them. I am wondering what are the switches that makes
> the Windows build work. Can somebody help me with that? Thanks,

On Linux, the first line of a non-custom bytecode executable indicates 
the full path to ocamlrun. You can create a relocatable executable using:

cat `which ocamlrun` `which ocamlc` > ocamlc.byte

On Windows, a small loader is included at the beginning of each bytecode 
executable, that locates 'ocamlrun' in the PATH, and run it on the 
executable, so the only requirement is to have ocamlrun in your PATH.

--Fabrice

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

end of thread, other threads:[~2012-09-25 17:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-20 19:50 [Caml-list] Build OCaml on linux Zhi Han
2012-09-22 19:52 ` Kristopher Micinski
     [not found] ` <sympa.1348346044.7674.559@inria.fr>
2012-09-23  0:33   ` Edgar Friendly
2012-09-23  0:56     ` Wojciech Meyer
     [not found]   ` <04644211E51C7E40BF64101089F97E4D0A7B38C9@exmb-01-ah.ad.mathworks.com>
     [not found]     ` <CA+LkvyqbZxzY=Coj7v_XnkSBDyN8wGuQP9ZB41bCBHqsE6XfcQ@mail.gmail.com>
2012-09-25  0:36       ` Francois Berenger
2012-09-25  9:25 ` Fabrice Le Fessant

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