-
Notifications
You must be signed in to change notification settings - Fork 414
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
Fix #3766 - Libraries without modules #3793
Conversation
Libraries without any modules must specify (modules) so that dune knows whether it needs a native archive for this library without evaluating any rules. Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
cc @kit-ty-kate |
I just launched a test using |
There are a handful of packages that fail with this PR and for which I'm not totally sure if the failures are expected. For instance for C (or javascript) stubs-only libraries:
In those cases I would expect a non-empty
|
Oo - is ocaml-gettext an actual in the wild case of a library with no modules?! |
Yeah, that makes sense. Will amend this PR. The only exception seems to be the zarith js stubs, for that package a |
I think the author thought an intermediate empty library was necessary in dune to "initialize" the base library as previously gildor478/ocaml-gettext@48d320e#diff-5929aa3a82d5e73ebf049c97f9ce3462 I think this could easily be just removed. |
Me and @jeremiedimino discussed this again, and we propose a simpler solution that will not break any existing packages: We'll just generate an empty module for libraries that do not have a module. We will not install the cmi for this module, so it will be invisible. @kit-ty-kate wdyt |
I don't know, I guess I personally liked the current proposal (this PR) a bit more as it would not create any unnecessary empty modules. It feels a bit cleaner I guess. |
That idea was discussed when we hit the original problem in stdlib-shims of genuinely needing an empty library - the conclusion there was that any name picked was still the possibility for a link error at some point in the future, since hiding the .cmi still reserves the module name. However, those other failures are for wrapped libraries, aren't they? Truly empty libraries can only happen for |
Further follow-up - I just hit this in a vendored build - things like ppx_base and ppx_jane were failing too (i.e. libraries which are just collections of other libraries). In this instance, there's definitely no problem because diff --git a/src/dune_rules/lib_archives.ml b/src/dune_rules/lib_archives.ml
index 02e1badfa..6adef9702 100644
--- a/src/dune_rules/lib_archives.ml
+++ b/src/dune_rules/lib_archives.ml
@@ -17,7 +17,7 @@ let has_native_archive lib config contents =
let name = Dune_file.Library.best_name lib in
let ml_sources = Dir_contents.ocaml contents in
let modules = Ml_sources.modules_of_library ml_sources ~name in
- not (Modules.is_empty modules)
+ not (Modules.is_empty modules) || lib.wrapped <> (This (Simple false))
module Library = Dune_file.Library
diff --git a/src/dune_rules/lib_rules.ml b/src/dune_rules/lib_rules.ml
index 6bc606b1c..c611258a7 100644
--- a/src/dune_rules/lib_rules.ml
+++ b/src/dune_rules/lib_rules.ml
@@ -62,6 +62,7 @@ let build_lib (lib : Library.t) ~sctx ~dir_contents ~expander ~flags ~dir ~mode
if
(not (Dune_file.Buildable.no_modules_specified lib.buildable))
&& Modules.is_empty modules
+ && lib.wrapped = (This (Simple false))
then
let is_error =
not |
@rgrinberg any news on this? As already said in DM, this branch works perfectly with @dra27's patch. I've added it to opam-alpha-repository a while ago, in case you want to test it further. |
Libraries without any modules must specify (modules) so that dune knows
whether it needs a native archive for this library without evaluating
any rules.