`make install` not copying ocamlnat in OCaml 4.14.2

Hi all,

This could be a question that had been already answered by somebody in the past, but I found that in OCaml 4.14.2 make install does not copy ocamlnat even if it was built by make world.opt.

I was downloading & building this source code: https://github.com/ocaml/ocaml/archive/4.14.2.tar.gz

Is there a background why make install of OCaml 4.14.2 was designed to not copy the file into its installation directory?

The ocamlnat REPL is an experimental tool that is not part of the standard installation of the compiler.

Thanks for a quick reply! :slight_smile:

Actually I must have discovered earlier that configuration has --enable-native-toplevel which indeed installs the file. Including this in my reply to record for someone who might be interested in its availability as well…

I am wondering whether my ocamlnat was built with right configuration options or it had missing ones. Running #use "topfind" is raising an undefined symbol error and one additional warning:

$ ocamlnat
OCaml version 4.14.2 - native toplevel
Enter #help;; for help.

# #use "topfind";;
>> Fatal error: Toploop.dll_run /tmp/camlTOP223e2fe.so: undefined symbol: camlTopfind
File "_none_", line 1:
Warning 58 [no-cmx-file]: no cmx file was found in path for module TOP1, and its interface was not compiled with -opaque
- : unit = ()
Findlib has been successfully loaded. Additional directives:
  #require "package";;      to load a package
  #list;;                   to list the available packages
  #camlp4o;;                to load camlp4 (standard syntax)
  #camlp4r;;                to load camlp4 (revised syntax)
  #predicates "p,q,...";;   to set these predicates
  Topfind.reset();;         to force that packages will be reloaded
  #thread;;                 to enable threads

- : unit = ()
#

I used ./configure --enable-native-toplevel when building OCaml 4.14.

IIRC it’s not possible to use ocamlfind with ocamlnat. Omod should work but apparently there were changes that I didn’t see fly by (ocamlnat is not checked by opam-ci on new releases).

With the new toploop API unification do you know if there is a way to detect whether I’m running in the bytecode or native code toplevel ?

It seems I could almost get rid of #use {omod,down}.top vs #use {omod,down}.nattop and thus have a single .ocamlinit that works with both toplevels but I need this information bit.

EDIT: Oh I forgot that Sys.backend_type is a thing nowadays.

In fact it seems that’s no longer true, I guess thanks to the ocamlnat/ocaml API unification done by @AltGr upstream (thanks!).

I had a closer look at the error you reported it is triggered by the test here. This doesn’t prevent topfind from loading on 4.14.2 but it does on 5.2.0~rc1. However even on 4.14.2 it seems to fail to load libraries correctly I have opened an issue.

I’m glad to report that this is fixed. And with:

> cat ~/.config/ocaml/init.ml 
#use "down.top"
#use "omod.top"

you can now simply invoke ocaml or ocamlnat regardless (also tested with 5.2.0~rc1).

> ocaml
OCaml version 4.14.2
Enter #help;; for help.

Down v0.3.0-7-ge3a4f38 loaded. Type Down.help () for more info.
Omod v0.0.4-3-gb0d2684 loaded. Type Omod.help () for more info.
# ^D
> ocamlnat
OCaml version 4.14.2 - native toplevel
Enter #help;; for help.

Down v0.3.0-7-ge3a4f38 loaded. Type Down.help () for more info.
Omod v0.0.4-3-gb0d2684 loaded. Type Omod.help () for more info.
# ^D

For those interested I also updated ocaml-repo-ocamlnat with 4.14.2 and 5.2.0~rc1. I will make new omod and down releases soon.

2 Likes