ocaml / ocaml/dune

Add a way to pass the context CFLAGS to foreign build sandboxing

Open
#3,341 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Hi there,

I am trying to compile some C code, using the foreign build sandboxing. This is working nicely, but now I would like to be able to tweak the C flags (for instance to use the ones defined in the current workspace context).

Is there a way to do that properly?

I've tried various things, but I only succeeded to make dune explode:

$ echo dune
(rule
  (target foo)
  (action (setenv X %{c_flags} (run echo 1))))
$ dune build ./foo
Error: exception { exn =
    ("Pform.Map.expand_exn",
    { t =
        { vars =
            map
              { "-verbose" : No_info Values []
              ; "<" :
                  Deleted_in
                    "First_dep",(1, 0),[ "Use a named dependency instead:\n\
                                          \n\
                                         \  (deps (:x <dep>) ...)\n\
                                         \   ... %{x}\n\
                                          ..."
                                       ]
[...]

Same for:

(rule
  (target foo)
  (action (run echo %{c_flags})))

Or with (with is what I wanted to use to pass %{c_flags} to the sandboxed ./configure script):

(rule
  (target foo)
  (action (bash "echo %{c_flags}")))

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 Dune's foreign build sandboxing and the sample rules using %{c_flags}, including the attempted with form for ./configure. Trace how context CFLAGS are exposed to sandboxed commands and define done as allowing the workspace flags to reach the foreign build without the reported Pform.Map.expand_exn failure.

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
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.