[RFC] Allow context initialization to use `ocaml` binaries from workspace
Nobody has claimed this yet.
- Dominant language
- OCaml
- Stars
- 1.9k
- Forks
- 500
- Avg merge
- 15h 21m
- Merged PRs (30d)
- 277
Description
It would be very cool if we could compose the OCaml compiler itself in a Dune workspace (c.f. https://github.com/ocaml/ocaml/issues/10315 ). A key step is to actually teach Dune to also look for OCaml binaries produced by rules in the current workspace.
This is subtle, thus I'm making an issue to discuss possible approaches; as of today, the code initializing the context does:
let* ocamlc =
get_tool_using_findlib_config "ocamlc" >>= function
| Some x -> Memo.Build.return x
| None -> (
which "ocamlc" >>| function
| Some x -> x
| None -> prog_not_found_in_path "ocamlc")
in
let dir = Path.parent_exn ocamlc in
let get_ocaml_tool prog =
get_tool_using_findlib_config prog >>| function
| Some x -> Ok x
| None -> (
match Program.best_path dir prog with
| Some p -> Ok p
| None ->
let hint =
sprintf "ocamlc found in %s, but %s/%s doesn't exist (context: %s)"
(Path.to_string dir) (Path.to_string dir) prog
(Context_name.to_string name)
in
Error
(Action.Prog.Not_found.create ~context:name ~program:prog ~loc:None
~hint ()))
thus, findlib is tried first, if not, path is tried (IIUC)
I could image two ways to tweak this:
- make ocaml binary resolution just use the regular mechanism from
Super_context.resolve_program - add yet a first special case for the resolution on the current workspace
Good news is that all the tools are already Action.Prog.t in Context.t , except for ocaml which is a path, I wonder why.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the context-initialization code shown in the issue, then read Super_context.resolve_program and the definitions of Context.t and Action.Prog.t. Compare the existing findlib and PATH lookup with workspace rule resolution. Done means agreeing on an approach and covering resolution of OCaml binaries produced in the current workspace.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ocaml
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100