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

Disable production of shared libraries (.cmxs, .so) #3934

Open
mato opened this issue Nov 10, 2020 · 2 comments
Open

Disable production of shared libraries (.cmxs, .so) #3934

mato opened this issue Nov 10, 2020 · 2 comments
Assignees

Comments

@mato
Copy link

mato commented Nov 10, 2020

This is needed primarily for MirageOS, but may also be useful for others. We would like a way to disable production of all shared libraries (.cmxs for OCaml, .so for C code) on a per-project (or indeed, for Mirage on a "entire universe") basis.

The only workaround which currently works without requiring any hacks or foreign library changes is to create a custom compiler variant where that compiler is configured with --disable-shared, which propagates down to dune nicely.

That doesn't seem like a hack. It seems like there should be a way to set this option for any context from inside dune.

How about we make it possible to override the -config options for any context from inside dune? This could be done in the workspace file:

(context
 (default
  (config
   (supports_shared _libraries false))))

Originally posted by @rgrinberg in #3718 (comment)

@nojb
Copy link
Collaborator

nojb commented Nov 10, 2020

Trying to do this at the dune-level is probably rather tricky (for example, ocamlmklib will produce shared libraries if those are supported by the compiler, and this cannot be controlled by an external flag if memory serves). So it feels like it would be better to address this issue at the level of the compiler.

@mato
Copy link
Author

mato commented Nov 10, 2020

@nojb Actually, dune already does "the right thing", if the compiler is built with --disable-shared, I tested this by adding a custom variant to OPAM. This is about having a way of "emulating" that behaviour against a compiler that hasn't been built that way, as I understand it, that should be possible by just modifying dune's "view" of the compiler configuration as Rudi suggested.

and this cannot be controlled by an external flag if memory serves

-custom will stop ocamlmklib from producing shared libraries.

If anyone wants a test repository to play with, the following branch of mirage-xen: https://github.com/mato/mirage-xen/tree/test-dune-cflags in combination with #3718 is where we'd want the build to succeed.

@rgrinberg rgrinberg self-assigned this Nov 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants