ocaml / ocaml/dune

Linker flags vs. libraries

Open
#2,977 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

c-bindings question
Dominant language
OCaml
Stars
1.9k
Forks
500
Avg merge
15h 21m
Merged PRs (30d)
277

Description

I am trying to build a couple of projects for the Fedora Linux distribution. These projects use dune to build. Fedora mandates that certain flags be passed to the linker (e.g., -Wl,-z,relro and -Wl,--as-needed). I cannot seem to find the correct way to do this. If I pass these flags along with the libraries to be linked with in c_library_flags, then the cmxs files are appropriately linked, but the stub libraries generated with ocamlmklib are not. In fact, ocamlmklib emits "Unknown option" warnings. What I need is some way to specify linker flags, which have to be guarded with -ldopt when passed to ocamlmklib, separately from the libraries to be used for linking. Does dune provide some way of doing this?

This seems to be related to #119.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading how dune handles c_library_flags and how ocamlmklib receives options, then review the related discussion in issue #119. The change is complete when linker flags such as -Wl,-z,relro can be specified separately from libraries and are passed correctly to both cmxs linking and generated stub libraries without Unknown option warnings.

Written by the indexing model from the issue text.

Assessment

Tech stack
ocaml
Domain
build-system
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.