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

ocaml_lib is not specific enough with tags, leading to highly confusing error message #4943

Closed
vicuna opened this issue Dec 17, 2009 · 3 comments

Comments

@vicuna
Copy link

vicuna commented Dec 17, 2009

Original bug ID: 4943
Reporter: @ygrek
Status: resolved (set by @damiendoligez on 2017-03-03T15:55:09Z)
Resolution: suspended
Priority: normal
Severity: feature
Version: 3.11.1
Category: -for ocamlbuild use https://github.com/ocaml/ocamlbuild/issues
Tags: junior_job
Related to: #4958

Bug description

Consider this ocaml_lib code (in ocaml_utils.ml) :

if byte then
  flag_and_dep ["ocaml"; tag_name; "link"; "byte"] (libpath^".cma");
if native then
  flag_and_dep ["ocaml"; tag_name; "link"; "native"] (libpath^".cmxa");

When the final linking target is a program - everything is ok. If it is a library - ocamlc will work, but ocamlopt will refuse to link cmxa into another cmxa, producing highly confusing error message : "...cmxa is not a compilation unit description". Of course, this situation can be avoided by carefully specifying tags like "true and not <*.cmxa>: use_lib" but this quickly becomes cumbersome in non-trivial projects. So the suggestion is for ocaml_lib to be more specific with tags :

if byte then
  flag_and_dep ["ocaml"; tag_name; "link"; "program"; "byte"] (libpath^".cma");
if native then
  flag_and_dep ["ocaml"; tag_name; "link"; "program"; "native"] (libpath^".cmxa");

Are those the only link targets : "library" and "program" ?

Additional information

$ cat _tags
true: use_str

$ cat q.ml
let x = Str.regexp "a"

$ cat q.mllib
Q

$ ocamlbuild q.cma
Finished, 3 targets (0 cached) in 00:00:00.

$ ocamlbuild q.cmxa

  • /usr/bin/ocamlopt.opt -a str.cmxa q.cmx -o q.cmxa
    File "none", line 1, characters 0-1:
    Error: /usr/lib/ocaml/str.cmxa
    is not a compilation unit description.
    Command exited with code 2.
@vicuna
Copy link
Author

vicuna commented Dec 17, 2009

Comment author: @ygrek

Looks like more link targets should be considered : "output_obj" and "toplevel"

@vicuna
Copy link
Author

vicuna commented Feb 20, 2017

Comment author: @xavierleroy

Un-assigning from xclerc

@vicuna
Copy link
Author

vicuna commented Mar 3, 2017

Comment author: @damiendoligez

ocamlbuild is now a separate project that lives on GitHub.
PR transferred to ocaml/ocamlbuild#225

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant