adampetro opened PR #6673 from adampetro:versioned-exports
to bytecodealliance:main
:
<!--
Please make sure you include the following information:
- Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->issue #6660
This change enables support for including multiple versions of
wasmtime
in a crate by adding suffixes to the symbols produced to assembly that currently producemultiple definition
errors when attempting to use multiplewasmtime
versions.Starting this in draft to get feedback on the general approach before adding tests, tackling removing
links
from thefiber
crate, and other refinements.
alexcrichton submitted PR review:
Thanks for working on this!
One suggestion I might have though is that instead of changing the literal identifier used in Rust code to one with a version appended I think this would be a good use for
#[export_name = "foo"]
or#[link_name = "foo"]
(depending on context). That way the symbol in Rust wouldn't change, but only the symbol at the binary level (which is what we care about the most here)
alexcrichton submitted PR review:
Thanks for working on this!
One suggestion I might have though is that instead of changing the literal identifier used in Rust code to one with a version appended I think this would be a good use for
#[export_name = "foo"]
or#[link_name = "foo"]
(depending on context). That way the symbol in Rust wouldn't change, but only the symbol at the binary level (which is what we care about the most here)
alexcrichton created PR review comment:
If possible I think it'd be best to avoid the macro here and instead apply it on usages. For example when the
impl_*
symbols are defined they'd have#[versioned_fn]
, but otherwise this macro wouldn't be tampered with and the normal identifiers would be used everywhere.
alexcrichton created PR review comment:
Ideally this could always be enabled and handled internally, so could the goal for the end state of this PR be to remove this as an option?
If this is only an issue on s390x I think that's a targeted problem which can be fixed in isolation in the build script for the outlined assembly files.
alexcrichton created PR review comment:
One idea for handling this is to use preprocessor magic on s390x which supports I think
foo ## bar
to create the symbolfoobar
so Wasmtime could invoke the C compiler with something like-DSYMBOL_APPEND=10_0_0
or something like that.
alexcrichton created PR review comment:
This is one location where I think it'd be good to avoid this attribute because these are normal Rust functions whose symbols don't matter, so ideally versioning shouldn't come into play here.
adampetro updated PR #6673.
adampetro created PR review comment:
I think it could makes sense not to use a feature for this. That being said, in discussion with @saulecabrera he mentioned that we likely want to support
ModuleVersionStrategy::Custom
and alsoModuleVersionStrategy::None
, and having this enabled by default would, from my understanding, break those two settings. Should it be opt-in, such as enabled with aWASMTIME_VERSIONED_EXPORTS
environment variable to use the version-based suffix andWASMTIME_EXPORT_SUFFIX
for a custom suffix?
alexcrichton created PR review comment:
Oh? In my mind this setting is purely about how we need some unmangled symbol names for things written in assembly and we need to be able to have "mangled" symbols per-wasmtime-version. That I would not expect to be related to the
ModuleVersionStrategy
which is only about what compiled artifacts look like, and as long as the right artifact is paired with the right wasmtime everything should work there as expected.
alexcrichton submitted PR review:
Nice! I like how this simplified things well. If you're up for it as well it'd be awesome to include this dependency in the
wasmtime-fiber
crate as well which would allow removing thelinks
attribute there and enable multi-version linkage.
alexcrichton submitted PR review:
Nice! I like how this simplified things well. If you're up for it as well it'd be awesome to include this dependency in the
wasmtime-fiber
crate as well which would allow removing thelinks
attribute there and enable multi-version linkage.
alexcrichton created PR review comment:
I think technically this
versioned_export
is only required on s390x?
alexcrichton created PR review comment:
I also think this may be causing the segfault on CI since the "mangled" symbols here should be the inline-assembly-generated trampolines, not the Rust-defined functions (e.g. the functions generated in the
wasm_to_libcall_trampoline
macro invocation)
alexcrichton created PR review comment:
I think this (and others on the top-level functions in this file) can be removed because these symbols aren't exported from the wasmtime library
adampetro updated PR #6673.
saulecabrera created PR review comment:
My line of thought here was mostly around verifying if the usage of
ModuleVersionStrategy
would be in conflict with versioning the symbols with the crate's version. But I don't necessarily have a particular use-case that demonstrates such conflict, I mostly wanted to make sure that we're all aligned that this is not a concern, which I think @alexcrichton has clarified in the previous comment.
adampetro created PR review comment:
Sounds good, I removed these and instead did the renaming inside of the
wasmtime_asm_macros::asm_func!
calls
adampetro created PR review comment:
Got it, sounds good. Thanks!
alexcrichton created PR review comment:
Ah yeah I think we're all good then because the names of symbols in Wasmtime doesn't actually end up relating to compiled artifacts at all, so these end up being orthogonal knobs.
adampetro updated PR #6673.
adampetro updated PR #6673.
adampetro updated PR #6673.
adampetro updated PR #6673.
alexcrichton created PR review comment:
Oh this is actually the one symbol which needs to not be versioned since IIRC gdb sets a breakpoint on this or something like that. That's ok though due to the
weak
linkage which should enable this to exist with other definitions ok.
adampetro updated PR #6673.
adampetro created PR review comment:
Makes sense, removed, thanks!
alexcrichton submitted PR review.
adampetro updated PR #6673.
adampetro updated PR #6673.
adampetro updated PR #6673.
adampetro updated PR #6673.
github-merge-queue[bot] updated PR #6673.
adampetro updated PR #6673.
adampetro updated PR #6673.
adampetro has marked PR #6673 as ready for review.
adampetro requested wasmtime-core-reviewers for a review on PR #6673.
adampetro requested itsrainy for a review on PR #6673.
adampetro requested wasmtime-default-reviewers for a review on PR #6673.
alexcrichton submitted PR review.
adampetro updated PR #6673.
alexcrichton has enabled auto merge for PR #6673.
adampetro updated PR #6673.
adampetro updated PR #6673.
adampetro updated PR #6673.
alexcrichton merged PR #6673.
Last updated: Nov 22 2024 at 16:03 UTC