-
Notifications
You must be signed in to change notification settings - Fork 821
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
Expose wasmer::{CraneliftOptLevel, LLVMOptLevel} #1894
Conversation
@@ -11,7 +11,7 @@ use wasmer_compiler::{ | |||
/// Possible optimization levels for the Cranelift codegen backend. | |||
#[non_exhaustive] | |||
#[derive(Clone, Debug)] | |||
pub enum OptLevel { | |||
pub enum CraneliftOptLevel { |
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.
Why do we need to rename this type?
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.
Not strictly necessary, but with this rename we avoid naming collisions in the wasmer::
high level API namespace. In the not too far future there is probably wasmer::OptimizationLevel
for the LLVM version, making it hard to reason about to which backends the types belong.
The other option would be use have pub use wasmer_compiler_cranelift::{Cranelift, OptLevel as CraneliftOptLevel};
, which gives us wasmer_compiler_cranelift::OptLevel
and wasmer::CraneliftOptLevel
. But in my opinion this creates more confusion than it helps.
What do you think?
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.
Not sure about this change.
You think is likely companies will use two compilers within the same codebase? This PR moves into prefixing all the public-facing objects of compilers with CompilernameXXX
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.
You think is likely companies will use two compilers within the same codebase?
Well, we do. I don't know much about other use cases. But even if they don't: the caller code use wasmer::OptLevel;
should not refer to compiler X in one project and compiler Y in a different project, right?
This PR moves into prefixing all the public-facing objects of compilers with
CompilernameXXX
Right. It is based on the idea that you promoted recently: make all high level API available in the wasmer::
namespace. This is a noble goal, but hard to get right. In #1730 we were fighting imports, #1872 documents a conflict now we have at least very similar names for multiple compilers.
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.
I think it's a good idea to rename OptLevel
to CraneliftOptLevel
here, since we already have the Cranelift
compiler. It makes sense and it avoids name clashing. Thoughts @syrusakbary @MarkMcCaskey @nlewycky and @jubianchi?
@webmaster128 Could you extend this renaming to other compilers in this PR, so that it's consistent across the entire codebase please?
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.
@webmaster128 Could you extend this renaming to other compilers in this PR, so that it's consistent across the entire codebase please?
So far this is the only new compiler-specific export in wasmer::
:
#[cfg(feature = "singlepass")]
pub use wasmer_compiler_singlepass::Singlepass;
#[cfg(feature = "cranelift")]
pub use wasmer_compiler_cranelift::{Cranelift, CraneliftOptLevel};
#[cfg(feature = "llvm")]
pub use wasmer_compiler_llvm::LLVM;
However, I now also added LLVMOptLevel
to show the direction in which this is heading.
Thanks for the PR! |
98222b9
to
767f5a9
Compare
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.
Thanks!
bors r+ |
1894: Expose wasmer::{CraneliftOptLevel, LLVMOptLevel} r=Hywan a=webmaster128 # Description This is required to do something like ```rust use wasmer::{Cranelift, CraneliftOptLevel}; let mut compiler = Cranelift::default(); compiler.opt_level(CraneliftOptLevel::None); let engine = JIT::new(compiler).engine(); // ... ``` # Review - [ ] Add a short description of the the change to the CHANGELOG.md file Co-authored-by: Simon Warta <simon@warta.it> Co-authored-by: Ivan Enderlin <ivan@mnt.io>
Build failed: |
c6a693c
to
5196b8f
Compare
Fixed the compile issue |
bors try |
I think this is ready to be merged. Or should I update it again to master? |
Please can you just update the |
This is required to do something like ```rust use wasmer::{Cranelift, CraneliftOptLevel}; let mut compiler = Cranelift::default(); compiler.opt_level(CraneliftOptLevel::None); let engine = JIT::new(compiler).engine(); // ... ```
5196b8f
to
50f0339
Compare
Sure, done |
Thanks! bors r+ |
Description
This is required to do something like
Review