Add -with-runtime/-without-runtime options#2309
Conversation
|
The name is wrong, since this option does not take a path as argument, but rather a "link flag" ( More generally, what is the use-case for this flag? At first sight it seems too specific to deserve its own command line flag. Even more generally, I find the proliferation of command line flags (currently 144 for |
|
I agree with you. The problem is that when compiling with What can be a nicer way to achieve that ? |
|
Off the top of my head, shouldn't you use |
|
|
|
If memory serves the compiler will look for the runtime library (eg |
|
(and use |
|
I already know about this workaround, but found it better to have a new option for clarity. With the |
Personally I don't think this is enough of an argument to justify yet another command line flag. The same kind of ambiguity is present for all other concepts which are searched on lists of include directories, and it doesn't seem to cause much trouble. |
|
Maybe one compromise would be to better document the fact that (Personally I think that giving a path is a better interface than a filename suffix, so I like the new option better.) |
We could make the existing flag accept filenames, except when the argument is one of the already recognised suffixes ( |
|
I'm not convinced -- these are not enums from a closed world, but just filename suffixes. I suggested to @TheLortex that we behave differently when the "variant" name starts with a slash, but then people want to pass relative paths as well (for example in scripts that should be user-independent), so that doesn't fly. |
|
OK, what about assuming the argument is a file name, but if the file is not found, try interpreting as a suffix (or the other way around)? |
|
Well... personally I like having another option better. |
|
I still feel it is too specific as a use-case, but won't fight it anymore 😄 |
|
Would someone else have an opinion? |
|
If you really want one, I also suspect |
|
Having another option seems entirely sensible to me. |
Could we try to rationalize this a bit before ? First what does In any case this is for the link step, in that step the OCaml compiler automatically links the runtime system (except if you |
|
I'm unsure why we're bringing the It should certainly be clarified exactly what this proposed option takes as argument. @dbuenzli 's idea of |
Because currently it's the only option that allows you to by-pass the automatic behaviour of the OCaml link step in order to control the link step yourself, which allows, among other things to specify your own runtime system which is what this PR is about. And you can legitimately ask whether this is not already good enough for people that need to do so. |
|
Gabriel Scherer (2019/03/11 15:52 -0700):
Well... personally I like having another option better.
Given that the option- name does not suggest any particular type of
object, I think I like @nojb's proposal.
|
|
Nicolás Ojeda Bär (2019/03/12 02:04 -0700):
I still feel it is too specific as a use-case, but won't fight it
anymore 😄
I agree, but won't fight either.
|
|
I would prefer to see if the This allows to understand flags in terms of others. For example if I understood |
|
I don't think enough context was supplied with this PR to adequately judge the tradeoffs suggested above, so let me dive in here with that information before the CLI option popularity contest begins in earnest. In MirageOS, we compile OCaml source code that has been functorised against the external interfaces it uses for a variety of 'exotic' targets such as standalone Xen, KVM and Muen unikernels that link a boot layer, device drivers and application logic into one bootable kernel. The assembly process involves selecting concrete OCaml driver implementations for a chosen backend, doing a full OCaml library compilation, and then linking the whole lot against a (typically C) bootlayer to build the final executable. This may sound very exotic, but it's in fact no different from many of the workflows to generate shared libraries or other similar 'non-traditional' outputs from the compiler. So our goal is to remove as many of the custom hacks as we have in Mirage at the moment and use upstream interfaces where possible. Current MethodRight now, mirage (3.x) builds the OCaml cmx[a] as normal, and generates multiple findlib packages for any C stubs that have been cross-compiled to a particular backend. Each backend (e.g. mirage-solo5) installs a C library via opam that exposes its cross-compilation CFLAGS via pkg-config. The link process thus involves:
Pros/cons:
New modelWe are now using Then the next stage is for dune to select the right group of virtual modules by means of a tag feature which allows an executable to search for implementations that satisfy an executable's virtual module dependencies. With this, we no longer need the pkg-config and META file hacks above, since we simply embed the C linkopts using the standard OCaml mechanism of stashing them inside the relevant cmxa objinfo. So given all this, we are at a point in Mirage where the bleeding edge tree has a principled way to track all the cross-compilation needs of Mirage through a very complex build chain. We get to the final link phase, which is where this PR came in. The choices are:
So with this background done, I agree with @nojb that a runtime variant path seems too fine-grained to worth a new CLI option. @dbuenzli's suggestion that I'm in favour of a |
I think adding the |
Fair enough, but it could be argued that C dependencies being stored in the .cmxa files and managed by the compiler "automatically" is at odds with the general lack of automatic dependency linking (for OCaml code), and that it's rather the responsibility of the build system (dune or ocamlfind) to manage them as well. That being said:
|
|
Le me veto any weird fallback semantics for |
|
I think the |
|
I think |
|
According to what I see when I invoke this should be alright, the runtime system archive is added at the very end of the |
Not entirely.
(2) is irrelevant if you specify |
|
@damiendoligez - I had overlooked the primitives loading. I am actually ordering a bike shed at the moment, so forgive this: Noting that |
|
What's in a name? A @dra27 is correct that for bytecode, the Does this mean a different name should be given to Does this mean that Does this mean that the bytecode "executable" file produced by |
|
Maybe trying to have the same option name for If one agrees that |
|
I'm not clear how writing a I agree that L308 in bytelink.ml should be updated not to write in executable mode if the header is not written (that could be done without worrying about whether the header is present, or not, since #8537 will make it an error for the header not to be present without this flag) |
|
I agree with @dra27 that prepending the The option could be called |
d3251af to
090be90
Compare
|
So I renamed the option according to @damiendoligez's comment and added the man/manual pages. |
|
@TheLortex where are we with this PR? Is there anything else left to do? If not, could you rebase on |
090be90 to
e61263c
Compare
|
@nojb I don't think I've missed anything from the past reviews, so it can be reviewed again. |
nojb
left a comment
There was a problem hiding this comment.
LGTM, other than some tiny cosmetic tweaks.
|
@dra27 can you approve your review if you think this is ready for merging? |
|
@damiendoligez - is this trunk-only or can it go on 4.09? |
|
I added a commit according to @nojb's reviews |
|
@dra27 It can go to 4.09 if you merge and cherry-pick before next Monday. |
|
I'm going to assume that today is in the middle of @dra27 non-standard weekends, and merge myself at the end of the afternoon if nobody stops me -- or beats me to it. |
|
Rebasing on top of 4.09 runs into a small conflict due to the fact that #8622 was not itself included in 4.09. I considered cherry-picking that other patch, but its diff is scary (it regenerates the configure etc.) so I dropped the idea. Someone else should feel free to do it. |
Add -noruntime option (cherry picked from commit 010d94c)
This behaves almost the same as
-runtime-variant, but it is more flexible as it takes a file path as an input instead of a suffix.