[new feature] Mode-specific foreign stubs#5649
Conversation
6d95bea to
081fe68
Compare
|
@mshinwell @snowleopard: I was able to build the flambda-backend with this reimplementation of mode-specific foreign stubs The rebased "special-dune" which has a lot less patches than before is here: https://github.com/voodoos/dune/commits/special_dune |
|
This is very good news, thanks. cc @stedolan |
dc7cf64 to
a9f9ca2
Compare
51850dd to
380817f
Compare
4b7a730 to
1ed47ef
Compare
c4319cc to
895bfbe
Compare
c12b677 to
b8de130
Compare
|
This PR is now ready for review: only the docs update is missing. A lot of the code addition goes into the I am not sure about the necessity of the |
Signed-off-by: Ulysse Gérard <thevoodoos@gmail.com>
Signed-off-by: Ulysse Gérard <thevoodoos@gmail.com>
Signed-off-by: Ulysse Gérard <thevoodoos@gmail.com>
Signed-off-by: Ulysse Gérard <thevoodoos@gmail.com>
Signed-off-by: Ulysse Gérard <thevoodoos@gmail.com>
Signed-off-by: Ulysse Gérard <thevoodoos@gmail.com>
Signed-off-by: Ulysse Gérard <thevoodoos@gmail.com>
Signed-off-by: Ulysse Gérard <thevoodoos@gmail.com>
Signed-off-by: Ulysse Gérard <thevoodoos@gmail.com>
Co-authored-by: Christine Rose <christinerose@users.noreply.github.com> Signed-off-by: Ulysse <5031221+voodoos@users.noreply.github.com>
Co-authored-by: Christine Rose <christinerose@users.noreply.github.com> Signed-off-by: Ulysse <5031221+voodoos@users.noreply.github.com>
Co-authored-by: Christine Rose <christinerose@users.noreply.github.com> Signed-off-by: Ulysse <5031221+voodoos@users.noreply.github.com>
…/fsmd-exe.t/run.t Co-authored-by: Christine Rose <christinerose@users.noreply.github.com> Signed-off-by: Ulysse <5031221+voodoos@users.noreply.github.com>
Signed-off-by: Ulysse Gérard <thevoodoos@gmail.com>
Signed-off-by: Ulysse Gérard <thevoodoos@gmail.com>
4066e27 to
4e8a8c0
Compare
|
|
||
| (** [Select] is a utility module that represents a mode selection. *) | ||
| module Select : sig | ||
| type mode = t |
| apply to any mode while keys of the form [Select.Only _] designate values | ||
| that apply to specific modes. *) | ||
| module Map : sig | ||
| type mode = t |
| (** Returns the list of values associated to a specific mode. If the | ||
| [and_all] option (which defaults to [false]) is set to true then values | ||
| which are not associated to a specific mode are also returned. *) | ||
| val for_only : ?and_all:bool -> 'a t -> mode -> 'a list |
There was a problem hiding this comment.
Please remove this optional argument as well.
|
|
||
| let object_name t = | ||
| t.path |> Path.Build.split_extension |> fst |> Path.Build.basename | ||
| let object_name ?(with_mode_suffix = true) t = |
There was a problem hiding this comment.
Can you remove this optional argument? Thanks.
| val decode : t Dune_lang.Decoder.t | ||
|
|
||
| val build_paths : t -> ext_obj:string -> dir:Path.Build.t -> Path.Build.t list | ||
| val build_paths : t -> ext_obj:string -> dir:Path.Build.t -> Path.t list |
There was a problem hiding this comment.
I had to modify consumers of the output of this function for my changes and noticed that all its usages where followed by a List.map ~f:Path.build so I "upstreamed" it.
| match mode with | ||
| | Some _ when for_library -> | ||
| User_error.raise ~loc:loc_mode | ||
| [ Pp.textf "The field \"mode\" is not available for foreign_libraries" |
There was a problem hiding this comment.
"foreign_libraries" isn't a stanza. Should be singular or just "foreign libraries"
| file [some/path/name.cpp]. *) | ||
| val object_name : t -> string | ||
| file [some/path/name.cpp]. [with_mode_suffix] defaults to true. *) | ||
| val object_name : ?with_mode_suffix:bool -> t -> string |
There was a problem hiding this comment.
Also, can you explain how this with_mode_suffix is supposed to work and how should the caller decide to provide it?
There was a problem hiding this comment.
I completely removed it: 7137b68
It was only used to hide the mode suffix in an error message which was probably even more confusing.
There was a problem hiding this comment.
I finally added it back (with an additional function) in order to improve the error message:
571a4f3
| if List.is_empty t.buildable.foreign_stubs then None | ||
| else Some (Foreign.Archive.stubs (Lib_name.Local.to_string (snd t.name))) | ||
| in | ||
| (lib_stubs, List.map ~f:snd t.buildable.foreign_archives) |
There was a problem hiding this comment.
Instead of returning a tuple, let's just have two separate functions. The return type is just confusing and there's no performance to gain from computing them together.
…ne-site, dune-rpc, dune-rpc-lwt, dune-private-libs, dune-glob, dune-configurator, dune-build-info, dune-action-plugin and chrome-trace (3.5.0) CHANGES: - macOS: Handle unknown fsevents without crashing (ocaml/dune#6217, @rgrinberg) - Enable file watching on MacOS SDK < 10.13. (ocaml/dune#6218, @rgrinberg) - Sandbox running cinaps actions starting from cinaps 1.1 (ocaml/dune#6176, @rgrinberg) - Add a `runtime_deps` field in the `cinaps` stanza to specify runtime dependencies for running the cinaps preprocessing action (ocaml/dune#6175, @rgrinberg) - Shadow alias module `Foo__` when building a library `Foo` (ocaml/dune#6126, @rgrinberg) - Extend dune describe to include the root path of the workspace and the relative path to the build directory. (ocaml/dune#6136, @reubenrowe) - Allow dune describe workspace to accept directories as arguments. The provided directories restrict the worskpace description to those directories. (ocaml/dune#6107, fixes ocaml/dune#3893, @esope) - Add a terminal persistence mode that attempts to clear the terminal history. It is enabled by setting terminal persistence to `clear-on-rebuild-and-flush-history` (ocaml/dune#6065, @rgrinberg) - Disallow generating targets in sub direcories in inferred rules. The check to forbid this was accidentally done only for manually specified targets (ocaml/dune#6031, @rgrinberg) - Do not ignore rules marked `(promote (until-clean))` when `--ignore-promoted-rules` (or `-p`) is passed. (ocaml/dune#6010, fixes ocaml/dune#4401, @emillon) - Dune no longer considers .aux files as targets during Coq compilation. This means that .aux files are no longer cached. (ocaml/dune#6024, fixes ocaml/dune#6004, @Alizter) - Cinaps actions are now sandboxed by default (ocaml/dune#6062, @rgrinberg) - Allow rules producing directory targets to be not sandboxed (ocaml/dune#6056, @rgrinberg) - Introduce a `dirs` field in the `install` stanza to install entire directories (ocaml/dune#5097, fixes ocaml/dune#5059, @rgrinberg) - Menhir rules are now sandboxed by default (ocaml/dune#6076, @rgrinberg) - Allow rules producing directory targets to create symlinks (ocaml/dune#6077, fixes ocaml/dune#5945, @rgrinberg) - Inline tests are now sandboxed by default (ocaml/dune#6079, @rgrinberg) - Fix build-info version when used with flambda (ocaml/dune#6089, fixes ocaml/dune#6075, @jberdine) - Add an `(include <file>)` term to the `include_dirs` field for adding directories to the include paths sourced from a file. (ocaml/dune#6058, fixes ocaml/dune#3993, @gridbugs) - Support `(extra_objects ...)` field in `(executable ...)` and `(library ...)` stanzas (ocaml/dune#6084, fixes ocaml/dune#4129, @gridbugs) - Fix compilation of Dune under esy on Windows (ocaml/dune#6109, fixes ocaml/dune#6098, @nojb) - Improve error message when parsing several licenses in `(license)` (ocaml/dune#6114, fixes ocaml/dune#6103, @emillon) - odoc rules now about `ODOC_SYNTAX` and will rerun accordingly (ocaml/dune#6010, fixes ocaml/dune#1117, @emillon) - dune install: copy files in an atomic way (ocaml/dune#6150, @emillon) - Add `%{coq:...}` macro for accessing data about the configuration about Coq. For instance `%{coq:version}` (ocaml/dune#6049, @Alizter) - update vendored copy of cmdliner to 1.1.1. This improves the built-in documentation for command groups such as `dune ocaml`. (ocaml/dune#6038, @emillon, ocaml/dune#6169, @shonfeder) - The test suite for Coq now requires Coq >= 8.16 due to changes in the plugin loading mechanism upstream (which now uses `Findlib`). - Starting with Coq build language 0.6, theories can be built without importing Coq's standard library by including `(stdlib no)`. (ocaml/dune#6165 ocaml/dune#6164, fixes ocaml/dune#6163, @ejgallego @Alizter @LasseBlaauwbroek) - on macOS, sign executables produced by artifact substitution (ocaml/dune#6137, ocaml/dune#6231, fixes ocaml/dune#5650, fixes ocaml/dune#6226, @emillon) - Added an (aliases ...) field to the (rules ...) stanza which allows the specification of multiple aliases per rule (ocaml/dune#6194, @Alizter) - The `(coq.theory ...)` stanza will now ensure that for each declared `(plugin ...)`, the `META` file for it is built before calling `coqdep`. This enables the use of the new `Findlib`-based loading method in Coq 8.16; however as of Coq 8.16.0, Coq itself has some bugs preventing this to work yet. (ocaml/dune#6167 , workarounds ocaml/dune#5767, @ejgallego) - Allow include statement in install stanza (ocaml/dune#6139, fixes ocaml/dune#256, @gridbugs) - Handle CSI n K code in ANSI escape codes from commands. (ocaml/dune#6214, fixes ocaml/dune#5528, @emillon) - Add a new experimental feature `mode_specific_stubs` that allows the specification of different flags and sources for foreign stubs depending on the build mode (ocaml/dune#5649, @voodoos)
This PR implements the proposal in #4639
It allows one to specify distinct flags and sources when building the same stubs for different modes (byte/native).
This is only possible for foreign stubs, not foreign libraries. It should not be too hard to allow it for foreign-libraries too but this PR does not implement it right now.
All relevant tests are passing but there are still a few tasks remaining: