Skip to content

Reactor support.#74

Merged
sunfishcode merged 5 commits into
masterfrom
reactor-crt
May 29, 2020
Merged

Reactor support.#74
sunfishcode merged 5 commits into
masterfrom
reactor-crt

Conversation

@sunfishcode
Copy link
Copy Markdown
Member

@sunfishcode sunfishcode commented Jun 5, 2019

This adds support for a new "Reactor" executable model.

The "Commands" and "Reactors" concepts are introduced here:
WebAssembly/WASI#13

A companion Clang patch, which just consists of using the new
crt1-reactor.o and Reactor-specific entry point name, is here:
https://reviews.llvm.org/D62922

Instead of an entrypoint named "_start", which calls "main", which
then scopes the lifetime of the program, Reactors have a
"_initialize" function. When "_initialize" exits, the intention is that the program should
persist and be available for calling.

At present, the main anticipated use for this is in environments like
Node, where WASI-using modules can be imported and don't necessarily
want the semantics of a "main" function.

[edit: update to reflect design changes, and drop "experimental"]

Copy link
Copy Markdown
Member

@sbc100 sbc100 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

Comment thread Makefile Outdated
Comment thread basics/crt/crt1.c Outdated
Comment thread Makefile Outdated
@sunfishcode
Copy link
Copy Markdown
Member Author

I've now rewritten this patch, which is much easier now that a bunch of other pieces of startup have been factored out. The patch is now very simple.

See also the corresponding WASI PR: WebAssembly/WASI#256

Comment thread libc-bottom-half/crt/reactor-crt1.c Outdated
@sunfishcode
Copy link
Copy Markdown
Member Author

This is now updated to use _initialize, and to use "crt1-reactor.o" as suggested a while ago in https://reviews.llvm.org/D62922.

And while here, I noticed that wasi-libc was exporting a _fini function which wasn't actually used, so I added a fix for that too.

@sunfishcode
Copy link
Copy Markdown
Member Author

Rebased and ready for review!

extern void __prepare_for_exit(void);

__attribute__((export_name("_start")))
void _start(void) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remind my why this file is duplicated here and in basics/crt/crt1.c?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point; it's an artifact of the "reference sysroot" idea that isn't important anymore. I'll submit a separate PR to remove it.

@sbc100
Copy link
Copy Markdown
Member

sbc100 commented May 29, 2020

The PR description seems out-of-date.

I was kind of expecting to see some change to Makefile to build the new version of crt1?

@sunfishcode sunfishcode changed the title Experimental Reactor support. Reactor support. May 29, 2020
@sunfishcode
Copy link
Copy Markdown
Member Author

The Makefile is set up to compile all .c files in the crt directory into .o files in the sysroot, so just adding a new .c file here is sufficient.

@sunfishcode
Copy link
Copy Markdown
Member Author

Title and PR description updated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants