Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bigarray compatibility library not linked #1845

Closed
aantron opened this issue Feb 14, 2019 · 8 comments
Closed

bigarray compatibility library not linked #1845

aantron opened this issue Feb 14, 2019 · 8 comments

Comments

@aantron
Copy link
Collaborator

aantron commented Feb 14, 2019

After ocaml/ocaml#1685, projects requiring compatibility with OCaml < 4.06 that use the Bigarray.*.map_file functions need to link in the bigarray library. However, this seems to be broken on OCaml 4.08 and Dune 1.7.0 (though I suspect it's not specific to this Dune version). Bigarray seems to resolve to the stdlib instance rather than the bigarray one, resulting in

Error: Unbound value Bigarray.Array1.map_file

Here is a sample project reproducing the issue.

  • Changing map_file to any other function from Bigarray.Array1 makes compilation succeed, so an instance of Bigarray is being linked.
  • Compilation succeeds on 4.07 (rather, it fails with another error, but only after first triggering a deprecation warning on map_file, demonstrating resolution).
  • Adding or removing (libraries bigarray) has no effect on the outcome.
@avsm
Copy link
Member

avsm commented Feb 14, 2019

@TheLortex has also been running into this as part of mirage/mirage#969

@rgrinberg
Copy link
Member

@nojb any idea?

@rgrinberg
Copy link
Member

Hmm, testing this out a bit it seems like it's not an issue with dune. In 4.07, I get this in the REPL:

01:37 .opam rlwrap ocaml
        OCaml version 4.07.1

# Bigarray.Array1.map_file;;
Warning 3: deprecated: Bigarray.Array1.map_file
Use [array1_of_genarray (Unix.map_file ...)] instead.
Note that Bigarray.Array1.map_file raises Sys_error while
Unix.map_file raises Unix_error.
Error: Reference to undefined global `Bigarray'

While in 4.08, I get:

01:38 .opam rlwrap ocaml
        OCaml version 4.08.0+beta1

# Bigarray.Array1.map_file;;
Error: Unbound value Bigarray.Array1.map_file
#

@nojb
Copy link
Collaborator

nojb commented Feb 15, 2019

Can you check if there is a bigarray.cmi in ocamlc -where?

@nojb
Copy link
Collaborator

nojb commented Feb 15, 2019

I am guessing that ocaml/ocaml#2041 may be involved: as per the explanation in that PR the initial environment is now built as:

env <- add_dir(env, stdlib_dir)
env <- open(env, Stdlib)

which would effectively hide any module in stdlib_dir with the same name as a submodule of Stdlib.

@diml ?

@nojb
Copy link
Collaborator

nojb commented Feb 15, 2019

@rgrinberg can you try doing rlwrap ocaml -I + and repeating the experiment?

@rgrinberg
Copy link
Member

Can you check if there is a bigarray.cmi in ocamlc -where?

There is.

can you try doing rlwrap ocaml -I + and repeating the experiment?

That seems to fix things:

04:26 .opam rlwrap ocaml -I +
        OCaml version 4.08.0+beta1

# Bigarray.Array1.map_file;;
Alert deprecated: Bigarray.Array1.map_file
Use [array1_of_genarray (Unix.map_file ...)] instead.
Note that Bigarray.Array1.map_file raises Sys_error while
Unix.map_file raises Unix_error.
Error: Reference to undefined global `Bigarray'

@ghost
Copy link

ghost commented Feb 18, 2019

This is in fact a bug in the compiler. It is fixed in ocaml/ocaml#2256

@ghost ghost closed this as completed Feb 18, 2019
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants