Linker is invoked from unexpected directory
Nobody has claimed this yet.
- Dominant language
- OCaml
- Stars
- 1.9k
- Forks
- 500
- Avg merge
- 15h 21m
- Merged PRs (30d)
- 277
Description
Expected Behavior
If a library specifies custom linker flags in (c_library_flags ...) which reference files relative to the directory containing the dune file, those files should be discoverable by the linker. For example, if I have a project with a static library src/libfoo.a and src/dune is
(library
...
(c_library_flags :standard -lfoo -L.))
...or...
(library
...
(c_library_flags :standard -lfoo -L%{project_root}/src))
...the linker should be able to find the archive libfoo.a.
Actual Behavior
The linker can't find the library: cannot find -lfoo: No such file or directory. This is because the linker is not invoked from the directory containing the dune file, and %{project_root} resolves to a relative path (relative to the directory containing the dune).
Reproduction
- PR with a reproducing test: https://github.com/ocaml/dune/pull/7147
Specifications
- Version of
dune(output ofdune --version): 3.7 - Version of
ocaml(output ofocamlc --version): 4.14.0 - Operating system (distribution and version): NixOS
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 reproducing test in PR #7147 and the testing guidance in doc/hacking.rst. Verify the relative linker paths described in the issue, then confirm that the linker can discover libfoo.a from the directory containing the dune file.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ocaml
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100