Add a missing dependency in the configuration detection - #267
Conversation
Make sure the configuration is detected, via `config/cfg.exe`, only once in a build by running it in `config` rather than in every directory where the flags are used
The configuration detection executable uses `dune-configurator` and so it uses the configuration passed in (currently) `.dune/configurator.v2` in particular to know which C compiler it should invoke. This adds an explicit dependency to this file (with a glob in case the format changes) to make sure a change of compiler triggers a redetection.
|
Thanks, though I'm curious -- I copied this detection logic from elsewhere (I don't remember where), and I've never seen this Is this a new thing? Is this documented somewhere? I couldn't find anything e.g. in https://dune.readthedocs.io/en/stable/dune-libs.html#configurator Also, I'm not sure about workspace_root (never used that), neither what kind this ".dune/configurator*" is? An executable? A directory? I find this rather mysterious, and would like to understand why this is needed and which other projects need these magic lines? |
|
I digged into the mirage issue tracker, and is this one relevant mirage/mirage#1195 (comment) -- where some changes were needed to some of the packages that used the dune-configurator to play nicely with opam-monorepo / the MirageOS 4.0 story of building unikernels using cross-compilation? |
It’s based on
Maybe an example would answer this question?
(their contents are not meant to be human-readable, though...) Executables using the
I think that the dependency is usually missing but the use case is rare enough that it has never been blocking, I suppose? I’ve been wondering whether I should open a PR to change the documentation about this.
I didn’t see what you were referring to in that issue. |
I think that this is where the proposed approach depends quite subtly on what
|
|
From the linked dune issue, it sounds like there's a different solution the dune developers have in mind, but also they haven't done any action to move this forward. What is the state of this PR and dune changes? |
|
On the dune side, I expect that this is waiting on someone having some spare time to implement that. I hope to get round to do this, but I’ve no idea when I’ll find some time to look into that.
|
This PR fixes an issue due to a missing dependency on the configuration for the configuration detection.
The configuration detection executable uses
dune-configuratorand so it uses the configuration passed in (currently).dune/configurator.v2in particular to know which C compiler it should invoke. This adds an explicit dependency to this file (with a glob in case the format changes) to make sure a change of compiler triggers a redetection.The issue arose when building a MirageOS unikernel with a Unikraft backend. The OCaml/Unikraft packaging makes it easy to switch between arm64 and x86_64 architecture, where only the
%{lib}%/findlib.conf.d/unikraft.conffile is updated to point to one or the other toolchain. With such a change of target,dunewas missing the dependency information to reruncfg.exewith the proper C compiler.This PR also takes the opportunity to centralise the detection in one directory.
The bug investigation is joint work with @Firobe.