Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] Link time code generation #594

Closed
ghost opened this issue Mar 6, 2018 · 3 comments
Closed

[RFC] Link time code generation #594

ghost opened this issue Mar 6, 2018 · 3 comments
Labels
proposal RFC's that are awaiting discussion to be accepted or rejected

Comments

@ghost
Copy link

ghost commented Mar 6, 2018

It'd be nice to support special libraries whose implementation would be generated at link time. Here are several uses cases:

Build info

module Dune_build_info : sig
  (** If inside git, this is the output of [git describe ...] *)
  val vcs_head : string option

  (** Project version *)
  val version : string

  (** For things that dynamically load libraries *)
  val linked_in_libraries : string list
end

Ocaml config

This could be used for all configurator scripts:

module Dune_ocaml_config : sig
  val version : int * int * int
  val standard_library : string
  ...
end

all you'd have to do is add dune.ocaml_config in the libraries field and we'd get this library with the values instantiated with the current build context configuration.

@rgrinberg
Copy link
Member

Will there be a way for a user to add their own variables? I'm thinking of the configurator use case where a user wants to pass custom arguments. We could add either add a function to fetch such arguments into the module. Or just generate a binding for every argument.

I'm also for the feature btw. I'm also wondering if we could implement this feature in terms of variants as well. I'm thinking of generating a single library for the link time library, and a variant implementation for every context.

@ghost
Copy link
Author

ghost commented Apr 10, 2018

That seems fine, however the .mli would have to be static, so generating arbitrary bindings wouldn't work.

@rgrinberg rgrinberg added the proposal RFC's that are awaiting discussion to be accepted or rejected label Oct 22, 2018
@emillon emillon changed the title [IDEA] Link time code generation [RFC] Link time code generation Dec 11, 2018
@rgrinberg
Copy link
Member

I believe this has been addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal RFC's that are awaiting discussion to be accepted or rejected
Projects
None yet
Development

No branches or pull requests

1 participant