Relocatable compiler in 5.5.0 does not work out of the box?

Attempt to create local switches with announced relocatable compiler optimization seems to no longer work with 5.5.0 release and runtimes are even or worse then for the initial/global one:

$ /usr/bin/time opam switch create 5.5.0 ocaml.5.5.0

<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><>
Switch invariant: [“ocaml” {= “5.5.0”}]

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
:down_arrow: retrieved ocaml.5.5.0 (cached)
∗ installed base-bigarray.base
∗ installed base-threads.base
∗ installed base-unix.base
∗ installed ocaml-options-vanilla.1
:down_arrow: retrieved ocaml-compiler.5.5.0 (cached)
∗ installed ocaml-compiler.5.5.0
∗ installed ocaml-base-compiler.5.5.0
∗ installed ocaml.5.5.0
∗ installed base-domains.base
∗ installed base-effects.base
∗ installed base-nnp.base
Done.
346.33user 35.18system 1:18.88elapsed 483%CPU (0avgtext+0avgdata 396620maxresident)k
0inputs+2098392outputs (972major+9764743minor)pagefaults 0swaps

1 min 19 sec for the initial switch

$ eval $(opam env)

$ ocamlopt -where
/home/torimus/.opam/5.5.0/lib/ocaml

$ /usr/bin/time opam switch create -y . ocaml.5.5.0

<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><>
Switch invariant: [“ocaml” {= “5.5.0”}]

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
:down_arrow: retrieved ocaml.5.5.0 (cached)
∗ installed base-bigarray.base
∗ installed base-threads.base
∗ installed base-unix.base
∗ installed ocaml-options-vanilla.1
:down_arrow: retrieved ocaml-compiler.5.5.0 (cached)
∗ installed ocaml-compiler.5.5.0
∗ installed ocaml-base-compiler.5.5.0
∗ installed ocaml.5.5.0
∗ installed base-domains.base
∗ installed base-effects.base
∗ installed base-nnp.base
Done.

To update the current shell environment, run: eval $(opam env)

346.45user 35.28system 1:19.52elapsed 480%CPU (0avgtext+0avgdata 396376maxresident)k
0inputs+2098480outputs (1125major+9777914minor)pagefaults 0swaps

1 min 20 sec for the local (cloned) switch,

where most time is spent on

Processing 21/36: [ocaml-compiler: make]

I’ve guessed it should just reuse existing build by default, but it seems this is not the case…

What is going on here?

This is a mistake on my side: I have accidentally reverted the compiler package to the pre-relocatable template during the release. A fix is incoming, thanks for the report!

Ok and thanks in an advance.

staying tuned…

This should be fixed now: the proper opam files has been propagated to the opam repository.

Sorry to hijack the thread, but are the instructions to get a relocatable toolchain when compiling from source documented anywhere?

Cheers,
Nicolas

The code is sort of the documentation :face_with_peeking_eye:

  • --with-relative-libdir - the main one; enables the relative discovery of the standard library
  • --enable-runtime-search - bytecode versions of the compiler tool locate ocamlrun relocatably
  • --enable-runtime-search-target=fallback - bytecode programs linked by ocamlc locate search for ocamlrun if necessary (but the executables themselves still include the absolute path to where ocamlrun was when they were linked)

Thanks David!

Nicolas

Is there some work planned around the caching of the packages in addition to the compiler? Is it time to revive opam-bin-cache.sh (setup instructions)? I know this is still technically not completely correct for all packages, but a good starting point in most cases?

I haven’t anything planned personally, but the goal of sorting the compiler out was that it should be possible to build caching systems for all packages without needing to rely on patching (either sources or binaries) to ease the maintenance of such systems.

Here’s a cool application of both relocatable OCaml and a bulk-building opam system - GitHub - avsm/oi: Oi you who's there? The OCaml Installer! · GitHub