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

Add API to convert wasm-opt command-line options to OptimizationOptions #64

Closed
brson opened this issue Sep 5, 2022 · 2 comments
Closed
Assignees
Milestone

Comments

@brson
Copy link
Owner

brson commented Sep 5, 2022

The easiest way for projects to integrate the wasm-opt API will be if they can continue using their existing CLI arguments instead of using the builder API directly. e.g. I imagine cargo-contract will want to continue having the ability to optionally use the wasm-opt CLI for some period until they are confident removing that code. To avoid having two code paths, it will be easier for them if the wasm-opt API can just handle the same CLI arguments they are already using.

  • Create an integration module with a single function, run, that accepts std::process::Command
  • Iterate over all the arguments of that command to create an OptimizationOptions, while also pulling out the input file, output file, input sourcemap, and output souremap paths.
  • Call OptimizationOptions::run
  • Return an error for any command line options that aren't understood.

We implement this on a best-effort basis to support whatever actual integrators need, for now just cargo-contract. It doesn't need full fidelity with exactly everything the wasm-opt CLI can parse, as long as integrators can craft a single command that works with both the "real" wasm-opt and the API.

cargo-contract needs these arguments:

  • the input file
  • "-o" output file
  • "-On"
  • "--zero-filled-memory"
  • "-g"

We can get that working, and should probably go ahead and support all CLI equivalents for everything the builder API supports.

@brson brson added this to the M2 milestone Sep 5, 2022
@brson brson self-assigned this Sep 5, 2022
@brson
Copy link
Owner Author

brson commented Sep 5, 2022

I've started this.

@brson
Copy link
Owner Author

brson commented Sep 26, 2022

Done.

@brson brson closed this as completed Sep 26, 2022
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

1 participant