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

Compiler configuration with -O or -C/--codegen flag on wasmer #1237

Closed
Hywan opened this issue Feb 21, 2020 · 6 comments
Closed

Compiler configuration with -O or -C/--codegen flag on wasmer #1237

Hywan opened this issue Feb 21, 2020 · 6 comments
Labels
🎉 enhancement New feature! 📦 lib-cli About wasmer-cli priority-low Low priority issue 🏚 stale Inactive issues or PR

Comments

@Hywan
Copy link
Contributor

Hywan commented Feb 21, 2020

Considering (i) #1212, (ii) we have multiple backends addressing different needs, (iii) we may add more profiling information or execution context, I'm more and more thinking about adding the very classical compiler -C/--codegen option to the wasmer executable. Here is a list of options I've in mind (inspired from rustc):

  • -C opt-level=value where value can be:
    • 0 to 3, where 0 implies --generate-debug-info (introduced in Add support for GDB JIT debugging #1212),
    • s and z to optimise for speed or small size,
    • the option controls the output of the compiler, but we may even use this option to run wasm-opt on the Wasm module before starting compilation, just an idea,
  • -C backend-arguments=value where value is different according to the backend:
    • arguments to the LLVM backend (@nick may confirm that it could be useful to enable/disable some passes, checks or assertions),
    • arguments to the Singlepass backend (@losfair may confirm whether it is useful or not),
    • arguments to the Cranelift backend,
  • -C overflow-checks=yes/no to check integer overflows,
  • -C debuginfo=value where value can be:
    • 0 for no debug info,
    • 1 for line tables only,
    • 2 for full debug information,
  • -C profile-generate=value to enable PGO (I assume it can work only with the LLVM backend for the moment, we don't support PGO in Singlepass or Cranelift, cc @nick),
  • -C profile-use=value to use a PGO profile file,
  • -C target-cpu and target-features to cross-compile or to enable some specific features for a target,
  • -C simd=yes/no to replace the --enable-simd option,
  • -C thread=yes/no to replace the --enable-thread option,
  • -C wasm-features=values to replace the --enable-all features,
  • -C abi-arguments=values where value depends on the ABI: emscripten or WASI, even if the current option (--em-entrypoint, --em-symbol-map, --dir etc.) are for runtime only, not compile-time. We should find a way to simplify those options too, that's for another issue.

And thus, we can have the very classical alias option -Ovalue for -C opt-level=value.

I think it is important to get a standard way to configure the backends and the compilations before adding too much options.

Also, it would imply to rethinkg a little bit the wasmer command. For the moment, we have the following commands:

  • run to compile and cache (if not cached), and run a module,
  • cache to clean the caches,
  • validate to validate a module.

Here is my proposal:

  • build to compile and cache a module,
  • run to compile and cache (if not cached), and run a module,
  • cache to clean the caches,
  • validate to validate a module.

The new build command will offer the -O and -C options, while run on the other hand will just assume default options and configurations.

Thoughts?

Additional cc @syrusakbary @MarkMcCaskey

@Hywan Hywan added 🎉 enhancement New feature! 📦 lib-cli About wasmer-cli labels Feb 21, 2020
@losfair
Copy link
Contributor

losfair commented Feb 21, 2020

I think this is generally a good idea. But instead of having a -C for everything, can we divide the arguments into two classes?

Class 1: High-level features that Wasm programs depend on. wasm-features and (maybe flattened) abi-arguments belong to this class.

Class 2: Low-level details that we can usually figure out a good default value for. Optimization level, overflow checks, debuginfo, target-cpu, PGO, middlewares and most backend-specific options.

For Class 1 they can be assigned first-level arguments for convenience of use, and Class 2 arguments can be put behind -C since they are not frequently used.

@MarkMcCaskey
Copy link
Contributor

I agree with @losfair here and like the idea of having finer grained options exposed to user generally!

I'm for this change with the qualifications mentioned!

@stale
Copy link

stale bot commented Jul 14, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the 🏚 stale Inactive issues or PR label Jul 14, 2021
@Hywan
Copy link
Contributor Author

Hywan commented Jul 15, 2021

Still relevant.

@stale stale bot removed the 🏚 stale Inactive issues or PR label Jul 15, 2021
@Amanieu Amanieu added the priority-low Low priority issue label Oct 20, 2021
@stale
Copy link

stale bot commented Oct 20, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the 🏚 stale Inactive issues or PR label Oct 20, 2022
@stale
Copy link

stale bot commented Nov 19, 2022

Feel free to reopen the issue if it has been closed by mistake.

@stale stale bot closed this as completed Nov 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🎉 enhancement New feature! 📦 lib-cli About wasmer-cli priority-low Low priority issue 🏚 stale Inactive issues or PR
Projects
None yet
Development

No branches or pull requests

4 participants