-
Notifications
You must be signed in to change notification settings - Fork 86
Add -instantiate
#1905
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
Add -instantiate
#1905
Conversation
None of the changes to code gen can actually be tested without `-instantiate`, which won't be implemented until PR ocaml-flambda#1905. This lets PR ocaml-flambda#2177 just be about typechecking, which we _can_ test immediately (in that we can check that if you compile with `-as-argument-for` then you have to conform to the parameter type and we remember that you passed the flag).
For each runtime parameter `P`, this generates a Lambda binding let P = raise (Invalid_argument "-parameter not yet implemented") This, of course, makes the module unusable when linked, but we can still test that compilation goes through. (Also, linking directly against a parameterised module _should_ raise an error!)
The test currently fails, as linking shouldn't be allowed against a parameterised module. (The module will harmlessly load and do nothing, since it's just a block with a function, but silent failure is bad.) A partial cherry-pick from commit 95e7772.
Removal of code gen from this branch of parameterised libraries means the list of runtime parameters is no longer stored in the .cmo (yet).
Parser Change ChecklistThis PR modifies the parser. Please check that the following tests are updated:
This test should have examples of every new bit of syntax you are adding. Feel free to just check the box if your PR does not actually change the syntax (because it is refactoring the parser, say). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More comments; I need to take a closer look at instantiator and translmod and asmpackager.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looked at all code
This is the last piece of compiler support for parameterised libraries: the ability to take a parameterised module and a set of arguments and produce an instance module. The
-instantiate
option is similar to-pack
in that it specifies a special compilation mode that takes in .cmo or .cmx files and produces a new one from them. It takes the module to instantiate and the modules to provide as instance arguments.One bit of awkwardness is that the
-o
option is required, but (up to directory) there's no actual choice: the output module must have the correct form to be usable from other modules so that .cmx lookup can function. This would be somewhat awkward to fix, and it's not worth doing so at the moment since we don't intend for humans to be running-instantiate
by hand.