This is an archive of the discontinued LLVM Phabricator instance.

[clang][WebAssembly] Link crt1 even in case of -shared
ClosedPublic

Authored by yamt on Jul 24 2023, 10:26 PM.

Details

Summary

This allows -mexec-model=reactor -shared produces a library module
with _initialize entrypoint, which is preferrable over __wasm_call_ctors.

This partially reverts https://reviews.llvm.org/D153293

Discussion: https://github.com/dicej/component-linking-demo/issues/3

Diff Detail

Event Timeline

yamt created this revision.Jul 24 2023, 10:26 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 24 2023, 10:26 PM
yamt requested review of this revision.Jul 24 2023, 10:26 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 24 2023, 10:26 PM

I think we are vearing into somewhat uncharted territory here, but we should probably push forward and document the direction we choose.

Should -shared modules also link with crt1-reactor.o by default then? Or should we add crt1-shared.o and use the whenever -shared is passed. Should we also make -shared incompatible with -mexec-model? It seems like -mexec-model should only apply to the main module, and not to the shared library that it loads.

yamt added a comment.Jul 25 2023, 1:47 AM

Should -shared modules also link with crt1-reactor.o by default then? Or should we add crt1-shared.o and use the whenever -shared is passed. Should we also make -shared incompatible with -mexec-model? It seems like -mexec-model should only apply to the main module, and not to the shared library that it loads.

wasi reactor model is for libraries.
i feel it's natural to make it cover shared libraries as well.

but i agree it can be done as you described too.

yamt updated this revision to Diff 544275.Jul 26 2023, 2:57 AM

update test

yamt updated this revision to Diff 546417.Aug 2 2023, 5:14 AM

when -shared, use the reactor model by default

sbc100 accepted this revision.Aug 2 2023, 6:33 AM
sbc100 added inline comments.
clang/lib/Driver/ToolChains/WebAssembly.cpp
80–81

LLCM coding style is IsCommand (at last for now: https://llvm.org/docs/Proposals/VariableNames.html)

This revision is now accepted and ready to land.Aug 2 2023, 6:33 AM
yamt updated this revision to Diff 546525.Aug 2 2023, 10:01 AM

isCommand -> IsCommand

clang/lib/Driver/ToolChains/WebAssembly.cpp
80–81

oops. fixed. thank you.

yamt marked an inline comment as done.Aug 13 2023, 8:13 PM

can this land?

This revision was automatically updated to reflect the committed changes.
sbc100 retitled this revision from wasm: link crt1 even in case of -shared to [clang][WebAssembly] Link crt1 even in case of -shared.Aug 14 2023, 11:10 AM

(update change title to use the [clang][WebAssembly]convention)