Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reactor support. #74

Merged
merged 5 commits into from
May 29, 2020
Merged

Reactor support. #74

merged 5 commits into from
May 29, 2020

Conversation

sunfishcode
Copy link
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
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

Makefile Outdated Show resolved Hide resolved
basics/crt/crt1.c Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
@sunfishcode
Copy link
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

@sunfishcode
Copy link
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
Member Author

Rebased and ready for review!

@@ -3,6 +3,7 @@ extern void __wasm_call_ctors(void);
extern int __original_main(void);
extern void __prepare_for_exit(void);

__attribute__((export_name("_start")))
void _start(void) {
Copy link
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
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
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
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
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