ocaml / ocaml/dune

In some cases, `dune` needs to run cross-compiled executables

Open
#2,571 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

While working on https://github.com/toots/ocaml-sys-socket I noticed that, in order to have ctypes generate the proper C constants for the underlying socket structures when cross-compiling for windows, the binary that it generates needed to be run as a binary for the windows target.

I was able to work around it by using the system call instead of run and calling a wrapper that used wine or wine64. See: https://github.com/toots/ocaml-sys-socket/blob/master/src/sys-socket/types/dune#L10

I believe that this might become a fairly reasonable use case when writing low-level bindings. I know that ocaml-ffmpeg has the same issue.

Could it be possible to allow the user to run an executable as a target binary, possibly by also passing a wrapper for it, perhaps with default values such as wine for windows?

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 with the example in src/sys-socket/types/dune and compare its system call and wrapper usage with Dune's run behavior. Trace how cross-compilation targets and executable invocation are handled; done means the issue's target executable and optional wrapper use case is supported without the workaround.

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.