alexcrichton opened PR #1391 from wast-linker
to master
:
By default
Linker
disallows shadowing previously defined items, but it
looks like the*.wast
test suites rely on this so this commit adds a
boolean flag toLinker
as well indicating whether duplicates are
allowed.
bjorn3 submitted PR Review.
bjorn3 created PR Review Comment:
On most systems the symbols loaded first have priority I believe. (Otherwise
LD_PRELOAD
would be pretty much useless.)
bjorn3 submitted PR Review.
bjorn3 created PR Review Comment:
"import of `{}::{}` with kind {:?} defined twice",
peterhuene submitted PR Review.
peterhuene created PR Review Comment:
I agree that in the context of
LD_PRELOAD
that makes sense, but from from an API perspective, last-in-wins might be more intuitive for developers (a la virtual inheritance). For example, I'd probably tell the linker to link in an engine-provided WASI implementation and then my host functions, which could potentially override the WASI implementation.
peterhuene submitted PR Review.
peterhuene created PR Review Comment:
Teensy naming nit: perhaps
allow_shadowing
orenable_shadowing
? The singularshadow
reads a little strange to me for some reason.
peterhuene submitted PR Review.
peterhuene edited PR Review Comment.
sunfishcode created PR Review Comment:
LD_PRELOAD
-style symbol preemption is fairly limited and awkward though. It's possible for libraries to make calls to their own symbols which can't be preempted, or to make assumptions that break if their symbols get preempted. So you have to depend on the library not doing those things.I think it would be better to encourage wasm programs and tools to focus on interposition rather than preemption. Load the replacement after the thing it is replacing rather than before. One nice thing about this approach is that it means you can easy wrap functions and call them from your wrappers. For things like
malloc
replacements, it may require libraries to be structured differently, but it has the advantage of not depending on any implicit contracts with the libc to only access the malloc heap through the public interface.
sunfishcode submitted PR Review.
alexcrichton updated PR #1391 from wast-linker
to master
:
By default
Linker
disallows shadowing previously defined items, but it
looks like the*.wast
test suites rely on this so this commit adds a
boolean flag toLinker
as well indicating whether duplicates are
allowed.
alexcrichton created PR Review Comment:
FWIW I think all behaviors are fine to implement. They're all simple enough and it's largely just a matter of defaults. If necessary it would be quite easy to implement a
LD_PRELOAD
-style first-one-always-wins, but I think it's best to wait for a use case to come up first.
alexcrichton submitted PR Review.
alexcrichton updated PR #1391 from wast-linker
to master
:
By default
Linker
disallows shadowing previously defined items, but it
looks like the*.wast
test suites rely on this so this commit adds a
boolean flag toLinker
as well indicating whether duplicates are
allowed.
alexcrichton updated PR #1391 from wast-linker
to master
:
By default
Linker
disallows shadowing previously defined items, but it
looks like the*.wast
test suites rely on this so this commit adds a
boolean flag toLinker
as well indicating whether duplicates are
allowed.
sunfishcode submitted PR Review.
sunfishcode created PR Review Comment:
Can you reformat this to avoid tab characters?
sunfishcode created PR Review Comment:
It feels awkward to have both
instances
andlinker
, since they're largely overlapping. Code likefn invoke
currently looks up a method to invoke by doingget_instance
and then looking up the export. Can it user thelinker
to do this instead? It seems like we should be able to completely eliminateinstances
.
sunfishcode submitted PR Review.
alexcrichton updated PR #1391 from wast-linker
to master
:
By default
Linker
disallows shadowing previously defined items, but it
looks like the*.wast
test suites rely on this so this commit adds a
boolean flag toLinker
as well indicating whether duplicates are
allowed.
alexcrichton created PR Review Comment:
I agree yeah it's a bit awkward but I don't think we can easily change this. This would involve adding some sort of accesor to
Linker
and it wouldn't work well for theregister
command which takes a whole instance and puts it in the linker. Would you be ok trying to clean this up at a later date?
alexcrichton submitted PR Review.
sunfishcode submitted PR Review.
sunfishcode created PR Review Comment:
Yeah. In fact, I think I have an idea of how to do it, so let's go ahead and land this and I'll see if my idea works in a separate PR.
sunfishcode submitted PR Review.
alexcrichton merged PR #1391.
sunfishcode submitted PR Review.
sunfishcode created PR Review Comment:
I took a quick look at this, and it turns out to be harder than I thought. The Linker interface doesn't have a way to look up a function without knowing its return types, which is something that the wast
invoke
command does. We may eventually want to add a way to do this, but we can figure that out later.
Last updated: Dec 23 2024 at 12:05 UTC