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

threads and mt predicate #96

Closed
bobot opened this issue May 25, 2017 · 8 comments
Closed

threads and mt predicate #96

bobot opened this issue May 25, 2017 · 8 comments

Comments

@bobot
Copy link
Collaborator

bobot commented May 25, 2017

The mt predicate is forced by jbuilder.

let preds = ["ppx_driver"; "mt"; "mt_posix"] in

What is the rational for that? For example Lablgtk can be used without threads, jbuilder force the user to use them (or perhaps it change nothing when you don't use them).

ocamlfind has some heuristics for adding missing threads dependency (eg. lablgtk with mt doesn't depend on thread):

let fixup_thread_needed_1 predlist =
  (* When the thread fixup is required to apply, 1st criterion *)
  List.mem "mt" predlist
;;

let fixup_thread_needed_2 pkg =
  (* When the thread fixup is required to apply, 2nd criterion *)
  (pkg <> "unix" && pkg <> "threads" && not (has_prefix pkg "threads."))
;;

It seems to me that jbuilder doesn't have them, even if ,maybe by chance , program that use lablgtk and threads can be linked well.

@ghost
Copy link

ghost commented May 26, 2017

So far predicates were not needed so they are not supported to simplify things, it's one less concept to understand for users.

I think supporting this would be a lot of work for little benefit, if any. Especially given that support for multicore is coming.

@bobot
Copy link
Collaborator Author

bobot commented May 28, 2017

I think supporting this would be a lot of work for little benefit, if any. Especially given that support for multicore is coming.

Ok it is reasonable. I think something should be said in the manual for advanced user. And shouldn't thread be always linked in that case?

@ghost ghost closed this as completed in 052dda3 May 29, 2017
@ghost
Copy link

ghost commented May 29, 2017

Ok, I added a comment about it in the manual.

And shouldn't thread be always linked in that case?

they will be linked if you depend directly or indirectly on the threads library.

@bobot
Copy link
Collaborator Author

bobot commented May 29, 2017

Ok so I'm going to propose an MR that adds ocamlfind heuristics for missing thread dependency (and I should also try to ask lablgtk to fix its meta).

@ghost
Copy link

ghost commented May 29, 2017

I'm a bit confused, what would such a heuristic do?

@bobot
Copy link
Collaborator Author

bobot commented May 31, 2017

The ocamlfind heuristic is when mt is used "for all package add a dependency to threads except for unix and threads.* packages".

If you want that binary for which no packages use the mt predicate, the heuristic could be, if a package use the predicate +mt for the definition of a variable then add a dependency to threads. For example for

description = "Bindings for gtk2"
requires = ""
version = "2.18.4"

archive(byte) = "lablgtk.cma"
archive(native) = "lablgtk.cmxa"
archive(byte,mt) += "gtkThread.cmo"
archive(native,mt) += "gtkThread.cmx"

the heuristic adds requires += threads. If ,mt) is not present the requires is not added.

But I think that if mt is always present the threads package must be always present.

@ghost
Copy link

ghost commented May 31, 2017

Seems to me that lablgtk should just say:

requires(mt) += "threads"

If only a handful of packages are affected, i'd rather document that people need to add an explicit dependency on threads when using such packages rather than add some magic.

@ghost
Copy link

ghost commented May 31, 2017

However i'm happy to detect such cases and print a warning, to help users understand what's happening and fix their linking errors

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

1 participant