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

Allow outputting the binary bytecode blob from CLI #151

Closed
Gskartwii opened this issue Nov 6, 2021 · 2 comments
Closed

Allow outputting the binary bytecode blob from CLI #151

Gskartwii opened this issue Nov 6, 2021 · 2 comments
Labels
enhancement New feature or request pr welcome Please contribute a pull request

Comments

@Gskartwii
Copy link
Contributor

As a Luau CLI user, I would find it handy if the CLI application had an option to output a binary bytecode blob, so that it would be easier to achieve interoperability between programs. The binary format would be far easier for a 3rd-party program to parse compared to the textual representation that is currently dumped. Of course, this need not be the default behaviour of the CLI.

For example, I could use the Luau CLI like this:
luau --compile --binary script.lua > bytecode.luac
And following this, there would be a bytecode.luac file created, containing the bytecode as given by Luau::Compiler::compile.

Another interesting idea could be to allow the loading and execution of precompiled binary bytecode blobs.

@Gskartwii Gskartwii added the enhancement New feature or request label Nov 6, 2021
@zeux
Copy link
Collaborator

zeux commented Nov 6, 2021

We definitely need a way to compile bytecode in CLI. I'm now thinking that maybe --compile should actually be reserved for outputting a binary bytecode blob? We can probably find another command line to print the text representation, or maybe require another flag. We could also go with --binary I suppose, one caveat is that for compiling bytecode to stdout we need to process just a single file, whereas disasm can work on multiple files which is somewhat useful to be able to analyze large portions of Luau code by compiling the entire folder and processing the result with regex/etc.

I don't think we'll ever support direct loading of bytecode. Bytecode is not verified during loading; applications that want to support loading from bytecode are expected to verify that the bytecode never comes from untrusted sources, for example by signing it with asymmetric cryptography. It's trivial to load the bytecode directly on the application level, but CLI supporting it is not a great idea.

@zeux zeux added the pr welcome Please contribute a pull request label Nov 7, 2021
@zeux
Copy link
Collaborator

zeux commented Nov 9, 2021

Fixed by #170.

@zeux zeux closed this as completed Nov 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pr welcome Please contribute a pull request
Development

No branches or pull requests

2 participants