-
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
Add wasmer create-exe
#1693
Add wasmer create-exe
#1693
Conversation
lib/cli/src/commands/create_exe.rs
Outdated
fn get_wasmer_include_directory() -> anyhow::Result<PathBuf> { | ||
let mut path = PathBuf::from(env::var("WASMER_DIR")?); | ||
path.push("include"); | ||
Ok(path) | ||
} | ||
|
||
fn get_libwasmer_path() -> anyhow::Result<PathBuf> { | ||
let mut path = PathBuf::from(env::var("WASMER_DIR")?); | ||
path.push("lib"); | ||
|
||
#[cfg(not(windows))] | ||
path.push("libwasmer.a"); | ||
#[cfg(windows)] | ||
path.push("libwasmer.lib"); | ||
|
||
Ok(path) | ||
} |
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.
It would be a good idea to abstract this out, and also reuse them on the lib/cli/src/commands/config.rs
file
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.
Yeah it looks like the config logic isn't tested right now... changes Ivan and I have been making to the C API are going to break it I think...
The config code implies we can just do -lwasmer
which is interesting that would make the code have fewer cfg
s in it.
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.
The code in wasmer config
for linking against wasmer seems to default to the dynamic libwasmer 🤔
I'm not sure what |
wasmer create-exe
wasmer create-exe
wasm_engine_t* engine = wasm_engine_new_with_config(config); | ||
wasm_store_t* store = wasm_store_new(engine); | ||
|
||
wasm_module_t* module = wasmer_object_file_engine_new(store, "qjs.wasm"); |
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 this is a typo. Can we use the first argument in argv
(or "wasmer-exe" in case argc == 0)
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.
argc should never be 0 I think, there's always supposed to be 1 arg which is the name of the program... We could handle it but I'm not aware of a situation in which that can happen
#[cfg(windows)] | ||
let command = command.arg("-luserenv").arg("-lWs2_32").arg("-ladvapi32"); |
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.
It seems this logic is duplicated?
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.
Yeah, this is test code. I'm not sure where a good place to share this code would be.
We could maybe make it public in the wasmer-cli
crate and then depend on it, but I think it's probably fine to duplicate
Those flags are required to link with wasmer compile
, but since we do that in create-exe we also do that
bors try |
tryBuild failed: |
bors try |
Build failed: |
bors r+ |
Canceled. |
bors r- |
bors r+ |
1693: Add `wasmer create-exe` r=MarkMcCaskey a=MarkMcCaskey This adds the `wasmer create-exe` subcommand. This subcommand is a combination of `wasmer compile --object-file` and linking that compiled Wasm with a main function and libwasmer. Put more plainly: it lets us transform Wasm modules into native executables in one step. In order for this to work we need: - [x] Ship wasm.h with Wasmer or use different mechanism to find it - [x] Ship wasmer_wasm.h with Wasmer - [x] Requires up to date libwasmer... had to build one and copy it over, may fail in CI because of this... will be fixed with next release though - [x] More gracefully handle wasmer installed without WASMER_DIR, etc (even if just error messages, should be tested) - [x] Add tests # Review - [ ] Add a short description of the the change to the CHANGELOG.md file Co-authored-by: Mark McCaskey <mark@wasmer.io> Co-authored-by: Mark McCaskey <5770194+MarkMcCaskey@users.noreply.github.com>
Build failed: |
bors r+ |
1693: Add `wasmer create-exe` r=MarkMcCaskey a=MarkMcCaskey This adds the `wasmer create-exe` subcommand. This subcommand is a combination of `wasmer compile --object-file` and linking that compiled Wasm with a main function and libwasmer. Put more plainly: it lets us transform Wasm modules into native executables in one step. In order for this to work we need: - [x] Ship wasm.h with Wasmer or use different mechanism to find it - [x] Ship wasmer_wasm.h with Wasmer - [x] Requires up to date libwasmer... had to build one and copy it over, may fail in CI because of this... will be fixed with next release though - [x] More gracefully handle wasmer installed without WASMER_DIR, etc (even if just error messages, should be tested) - [x] Add tests # Review - [ ] Add a short description of the the change to the CHANGELOG.md file Co-authored-by: Mark McCaskey <mark@wasmer.io> Co-authored-by: Mark McCaskey <5770194+MarkMcCaskey@users.noreply.github.com>
Build failed: |
bors r+ |
1693: Add `wasmer create-exe` r=MarkMcCaskey a=MarkMcCaskey This adds the `wasmer create-exe` subcommand. This subcommand is a combination of `wasmer compile --object-file` and linking that compiled Wasm with a main function and libwasmer. Put more plainly: it lets us transform Wasm modules into native executables in one step. In order for this to work we need: - [x] Ship wasm.h with Wasmer or use different mechanism to find it - [x] Ship wasmer_wasm.h with Wasmer - [x] Requires up to date libwasmer... had to build one and copy it over, may fail in CI because of this... will be fixed with next release though - [x] More gracefully handle wasmer installed without WASMER_DIR, etc (even if just error messages, should be tested) - [x] Add tests # Review - [ ] Add a short description of the the change to the CHANGELOG.md file Co-authored-by: Mark McCaskey <mark@wasmer.io> Co-authored-by: Mark McCaskey <5770194+MarkMcCaskey@users.noreply.github.com>
Build failed:
|
bors r+ |
1693: Add `wasmer create-exe` r=MarkMcCaskey a=MarkMcCaskey This adds the `wasmer create-exe` subcommand. This subcommand is a combination of `wasmer compile --object-file` and linking that compiled Wasm with a main function and libwasmer. Put more plainly: it lets us transform Wasm modules into native executables in one step. In order for this to work we need: - [x] Ship wasm.h with Wasmer or use different mechanism to find it - [x] Ship wasmer_wasm.h with Wasmer - [x] Requires up to date libwasmer... had to build one and copy it over, may fail in CI because of this... will be fixed with next release though - [x] More gracefully handle wasmer installed without WASMER_DIR, etc (even if just error messages, should be tested) - [x] Add tests # Review - [ ] Add a short description of the the change to the CHANGELOG.md file Co-authored-by: Mark McCaskey <mark@wasmer.io> Co-authored-by: Mark McCaskey <5770194+MarkMcCaskey@users.noreply.github.com>
Build failed:
|
bors r+ |
1693: Add `wasmer create-exe` r=MarkMcCaskey a=MarkMcCaskey This adds the `wasmer create-exe` subcommand. This subcommand is a combination of `wasmer compile --object-file` and linking that compiled Wasm with a main function and libwasmer. Put more plainly: it lets us transform Wasm modules into native executables in one step. In order for this to work we need: - [x] Ship wasm.h with Wasmer or use different mechanism to find it - [x] Ship wasmer_wasm.h with Wasmer - [x] Requires up to date libwasmer... had to build one and copy it over, may fail in CI because of this... will be fixed with next release though - [x] More gracefully handle wasmer installed without WASMER_DIR, etc (even if just error messages, should be tested) - [x] Add tests # Review - [ ] Add a short description of the the change to the CHANGELOG.md file Co-authored-by: Mark McCaskey <mark@wasmer.io> Co-authored-by: Mark McCaskey <5770194+MarkMcCaskey@users.noreply.github.com>
Build failed: |
bors r+ |
Build succeeded: |
Sounds great, not very turnkey or well documented from what I see so far.. |
It is true. We are going to document that more. Thanks! |
This adds the
wasmer create-exe
subcommand. This subcommand is a combination ofwasmer compile --object-file
and linking that compiled Wasm with a main function and libwasmer. Put more plainly: it lets us transform Wasm modules into native executables in one step.In order for this to work we need:
Review