Remove support for compiler plugins#2276
Conversation
|
This PR also removes the "hooks" ( |
|
@nojb I thought the majority of the "hooks" code---exactly those parts I deleted---were introduced along with the plugins mechanism. (I deduced that by looking at some of the documentation, which described their use in conjunction with plugins, if I remember correctly.) I did leave some "hooks" in place, in particular in the toplevel code. |
Yes, but the hook mechanism could still be used when building standalone compiler drivers. I don't have any use case in mind, so am not arguing to keep them. But maybe worth asking about it in caml-devel. |
|
I do have a light use case for hooks: I have at least one toy projects, https://github.com/Octachron/more_ocaml_warnings, which use the Typemod's hook in order to add a warning for the beginner's mistake like Going from a compiler plugin to a statistically-linked driver does not change much in term of usability (it may even improve it), but removing hooks would make harder to maintain such toy projects. This is certainly not a very strong point for keeping those hooks. However, since the maintenance cost of such hooks is far lighter than the plugin mechanism, it might make sense to keep it? |
|
|
@alainfrisch #2268 will provide what you want, I think, although I'm still working out some tricky details with @xclerc . |
|
Regarding hooks, it doesn't seem to me that these are worth keeping. I think the main reason is as follows: they just exist in a small collection of rather arbitrary locations. As such it seems to me that someone's future development work changing the behaviour of the compiler will, with some reasonable probability, not coincide with a place where one of these hooks exist---and it seems messy to add hooks everywhere. The whole thing seems like a poor-man's version of aspect-oriented programming (in which case it must be quite poor). It also isn't difficult to rebuild the compiler libraries if you want to implement functionality that isn't provided by any hook. This might also, perhaps, encourage people to contribute such functionality upstream. @xavierleroy and @damiendoligez : Could you please offer an opinion? |
|
FTR: my use of a plugin was indeed just lazyness. For my use case it would have been better, for various other reasons, to write my own driver. Personally my plugin didn't use any fancy "hook" mechanism. It just updated some references already present in the typechecker; but I assume that the hook mechanism is just a nicer interface, which covers a different set of references than the one I happened to need? |
3499765 to
098bcd4
Compare
|
On hooks: Some of them are quite essential for alternate toplevels (like jsoo's toplevel or sketch.ml). In particular the hook to redefine .cmi loading. Maintaining a fork of the typechecker just for these is not reasonable. |
|
The |
|
There is a |
53a96a9 to
cb03285
Compare
|
I've pushed a single changeset containing everything so far, since there was some trouble rebasing. |
|
CI green! The only objection was about not removing the toplevel hooks and indeed they are not. Unless someone else objects, this looks good to merge. |
|
|
|
One small spanner to throw into the works - is it definitely the case that the |
|
I think deleting the flag is fine, given the data we collected about the (non-)use of plugins. |
|
That's not the point, though - the issue is how we deal with changes in the CLI - there are other flags for which this has happened and it should be consistentm |
|
Unrelated to that, |
|
@dra27 Given that the work has been done to remove the flag now, and with the lack of use of plugins, I really think it is fine as it is. There is a clear I have removed |
|
Come on, the "work" we're talking here is one-line alterations in |
|
dra27@eb1ab30 is what I was meaning which gives: dra@cosmic:~/ocaml-$ ./ocamlc.opt -plugin foo -plugin is only supported up to OCaml 4.08.0 dra@cosmic:~/ocaml$ echo $? 2 This seems to have the additional desirable side-effect that |
|
I could use an explanation of |
|
@xavierleroy This function is needed to support existing use cases where clients of the The two existing use cases, which now both go via this function, are:
The [*] This seems good, because |
8684f51 to
0985d56
Compare
dra27
left a comment
There was a problem hiding this comment.
Dynlink.unsafe_get_global_variable is hidden from the documentation, as being an internal function.
LGTM, pending @xavierleroy's agreement
| let if_on = if name = "timings" then [ `Time ] else Profile.all_columns in | ||
| profile_columns := if check_bool ppf name v then if_on else [] | ||
|
|
||
| | "plugin" -> !load_plugin v |
There was a problem hiding this comment.
My feeling is that where -plugin wants to remain in the CLI, leaving handling here could be annoying (on the basis that OCAMLRUNPARAM comes from your shell, not the specific invocation of the driver binary.
Arguably we could emit a warning instead? (doesn't have to be in this GPR)
There was a problem hiding this comment.
I think this is fine, at least for the moment.
|
@xavierleroy If you are happy with my explanation above, please merge. |
|
Thank you @mshinwell for the detailed explanations. With them I could review the dynlink + debugger part of this PR. It looks good to me and I agree the debugger's use of Symtable is nicer and clearer. About Dynlink + Symtable: the following is probably obvious for @mshinwell but perhaps not clear to everyone. Even though proper packing of Dynlink hides the copy of Symtable that it uses, making it possible to link it along Symtable, there is still only one table of global values in the bytecode VM and changes to this table are NOT synchronized between Dynlink and the Symtable functions that change the global value table (update_global_table, assign_global_value). That's why we can't use Dynlink from the toplevel interactive loop, in particular. I think this GPR doesn't run into this trap, since the debugger doesn't seem to use those Dynlink functions. Coming back to this GPR: I think it's in good shape and will merge soon. I still encourage @dra27 to submit a PR that will 1- remove |
|
@xavierleroy I was not fully clear on all the details of that actually, so thanks for the explanation. Let me just add a comment based on your text before we merge this. |
|
I was writing the log entry for the squashed merge :-) Ping me when you're done. |
|
@xavierleroy - no problem to follow it up with a |
|
@xavierleroy Please see the comment, which is a slightly expanded version of your text. That's all from me. |
|
@dra27 don't forget to open a PR for the removal of |
|
I was advised from https://discuss.ocaml.org/t/compiler-plugins/3898/2?u=overminddl1 to voice my issues upon the compiler plugins being removed, it's essentially killing my codebase and preventing me from upgrading past 4.8.0 (which I just completed doing). I'm not finding any documentation on any migration path or anything to be able to keep the workflow this uses in a backwards compatible way using the stock installed compiler, otherwise it seems I'll need to essentially fork the compiler, which I'm exceptionally not wanting to do... |
After consultation on the core developers' list I am proposing this patch to remove support for compiler plugins.
The main motivations for removing compiler plugins are:
Dynlinklibraries more difficult (although actually, this complexity could probably be reduced after Improve the packing mechanism used to build Dynlink #2268 is merged).compilerlibs.It is not clear there are actually any extant uses of this feature (save for one from @trefis that can be implemented in a different way).