PureWhiteWu opened PR #4252 from fix/config_overwrite
to main
:
This commit refactored
Config
to use a seperateCompilerConfig
field instead of operating onCompilerBuilder
directly to make all its methods idempotent.
Fixes #4189
PureWhiteWu updated PR #4252 from fix/config_overwrite
to main
.
PureWhiteWu updated PR #4252 from fix/config_overwrite
to main
.
PureWhiteWu updated PR #4252 from fix/config_overwrite
to main
.
bjorn3 created PR review comment:
These should be added to the 0.39.0 section I think.
bjorn3 submitted PR review.
bjorn3 created PR review comment:
bjorn3 submitted PR review.
bjorn3 created PR review comment:
This would need to be updated. Also where would the error occur now?
bjorn3 submitted PR review.
PureWhiteWu updated PR #4252 from fix/config_overwrite
to main
.
PureWhiteWu created PR review comment:
Thanks for your review!
The error occurs atEngine::new
now.
PureWhiteWu submitted PR review.
cfallin submitted PR review.
cfallin submitted PR review.
cfallin created PR review comment:
In place of the "Errors" section in the old doc comment, we should note here that flags are validated when the engine is built, and so any errors will be deferred, I think. Likewise elsewhere where an "Errors" section is removed.
cfallin created PR review comment:
A slightly more verbose name would make this a bit clearer I think: maybe something like
ensure_unset_or_given_setting
? Then in the doc-comment we should say what this returns: "Returns true if successfully set or already had the given setting value, or false if the setting was explicitly set to something else previously."
cfallin created PR review comment:
Could we do the same sort of deferred validation for the combination of reference types and bulk memory that we do for compiler options? I'm somewhat uncomfortable with this assert existing, given that we have the right API signatures elsewhere to return the error.
cfallin created PR review comment:
Can we say a bit more here? Something about how some Wasm features require certain compiler features, and they will turn on the relevant compiler features by default, but explicitly disabling some compiler features or setting them in an incompatible way may cause errors. I think we should also note a guarantee/promise that default compiler options (i.e., if the user does not add any specific setting overrides) will always work if the underlying hardware supports what is needed.
PureWhiteWu updated PR #4252 from fix/config_overwrite
to main
.
alexcrichton submitted PR review.
alexcrichton submitted PR review.
alexcrichton created PR review comment:
If you're up for it this explicit
Clone for Config
can I believe now be entirely deleted in favor of#[derive(Clone)]
on theConfig
type. If you're feeling extra-ambitious as well theCompilerBuilder::clone
method can also be removed. Either of these are fine to defer to a future PR though if you'd prefer.
alexcrichton created PR review comment:
I think it's ok to remove
pub(crate)
on all these methods and related fields since it should be able to isolate all the usages to just this file.
alexcrichton created PR review comment:
Agreed about expanding the error documentation a bit here, but I also think it would be best to keep documentation on the original config methods as well. For example
Config::cranelift_flag_set
could retain some documentation indicating that if an invalid setting is specified that the error will pop out duringEngine::new
here.
alexcrichton created PR review comment:
I think that this enable-other-wasm-feature-if-this-is-enabled would be better left to
Engine::new
as well as otherwise this can cause confusing behavior depending on the order of the method calls.
alexcrichton created PR review comment:
If you'd like I think that this is now the only usage of the
compiler_builder
function so it should be fine to inline directly into this function.
PureWhiteWu updated PR #4252 from fix/config_overwrite
to main
.
PureWhiteWu submitted PR review.
PureWhiteWu created PR review comment:
Thanks for pointing out! I think
ensure_setting_unset_or_given
is better, so I used that name.
PureWhiteWu created PR review comment:
Added, except for the
strategy
method, because it will not return error in any situation (previously and now).
PureWhiteWu submitted PR review.
PureWhiteWu created PR review comment:
Can we say a bit more here? Something about how some Wasm features require certain compiler features, and they will turn on the relevant compiler features by default, but explicitly disabling some compiler features or setting them in an incompatible way may cause errors.
Fixed.
I think we should also note a guarantee/promise that default compiler options (i.e., if the user does not add any specific setting overrides) will always work if the underlying hardware supports what is needed.
I don't think it necessary to add this note explicitly, because the default options should work is intuition for users.
PureWhiteWu created PR review comment:
Fixed.
PureWhiteWu updated PR #4252 from fix/config_overwrite
to main
.
PureWhiteWu updated PR #4252 from fix/config_overwrite
to main
.
PureWhiteWu updated PR #4252 from fix/config_overwrite
to main
.
PureWhiteWu updated PR #4252 from fix/config_overwrite
to main
.
PureWhiteWu updated PR #4252 from fix/config_overwrite
to main
.
PureWhiteWu requested alexcrichton for a review on PR #4252.
PureWhiteWu requested cfallin for a review on PR #4252.
PureWhiteWu edited PR review comment.
PureWhiteWu edited PR review comment.
alexcrichton submitted PR review.
alexcrichton merged PR #4252.
thibaultcha created PR review comment:
On https://docs.wasmtime.dev/c-api/config_8h.html#ada735dd95cbee6854fc6bb27dc9591c6 it says:
If the compilation strategy selected could not be enabled then an error is returned.
I've been looking everywhere in the docs to try and find what happened to config errors, I don't think it is very clear today without looking into this PR.
thibaultcha submitted PR review.
thibaultcha edited PR review comment.
thibaultcha edited PR review comment.
thibaultcha edited PR review comment.
PureWhiteWu submitted PR review.
PureWhiteWu created PR review comment:
Hi, thanks for your remind.
I changed the doc and the signature of the rust code, but I forgot the doc for c.
I've submitted #4550 to fix this.
thibaultcha submitted PR review.
thibaultcha created PR review comment:
@PureWhiteWu That's great! Very prompt, thank you!
A question still remains on my end but I am not sure if here's the right place for it, I'll shoot it again though:
Since
wasm.h
'swasm_engine_new_with_config
does not return any error, where are the engine initialization errors reported when using the C API? :thinking:
PureWhiteWu submitted PR review.
PureWhiteWu created PR review comment:
Sorry, I'm not familiar with the c api, @alexcrichton do you know about this?
alexcrichton submitted PR review.
alexcrichton created PR review comment:
You can take a look at the implementation and right now it looks like no error handling happens and if something otherwise would result in an error it would cause the process to abort.
This is probably something that would be good to fix, returning a null pointer there and perhaps adding a Wasmtime-specific API for the same operation but one that returns an error message.
Last updated: Dec 23 2024 at 12:05 UTC