Page MenuHomePhabricator

[WebAssembly] Implement "Reactor" mode
ClosedPublic

Authored by sunfish on Jun 5 2019, 11:01 AM.

Details

Summary

This is an experimental patch which adds a -mexec-model= command-line flag. The default value is "command" which is no change from the current behavior. The other option is "reactor" which enables an experimental Reactor ABI.

By default, clang/LLVM don't do much differently for Reactors -- it just picks a different crt1.o and entry point name -- so I won't go into detail here. I'll open a PR for wasi-libc to add the libc side of this, and I'll describe the ABI in detail there, and I expect most of the discussion will happen there.

Diff Detail

Event Timeline

sunfish created this revision.Jun 5 2019, 11:01 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 5 2019, 11:01 AM

The wasi-libc PR is here.

sbc100 added a comment.Jun 5 2019, 3:40 PM

Add a test case to clang/test/Driver/wasm-toolchain.c?

clang/lib/Driver/ToolChains/WebAssembly.cpp
88

Maybe call this Crt1 so it doesn't looks so much like crtZero?

92

I have a slight preference for crt1-foo.o over foo-crt1.o. But I've tell where that preference comes from :)

96

Shouldn't this be nullptr?

Also, maybe move the if Entry block inside this condition so this line can declare entry avoid the extra declaration above?

102

I assume that all he users -Wl args come after.. so its still possible to set --entry on the command line?

sbc100 added a comment.Jun 5 2019, 3:41 PM

lgtm with some comments

sunfish updated this revision to Diff 257171.Apr 13 2020, 5:34 PM

Rebase, update, add a test, and add basic error reporting.

Herald added a project: Restricted Project. · View Herald TranscriptApr 13 2020, 5:34 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript

This addresses the review feedback from earlier. To answer this question:

I assume that all he users -Wl args come after.. so its still possible to set --entry on the command line?

Yes, that is what happens.

sbc100 accepted this revision.Apr 13 2020, 7:49 PM
This revision is now accepted and ready to land.Apr 13 2020, 7:49 PM
This revision was automatically updated to reflect the committed changes.
bjope added a subscriber: bjope.Jun 4 2020, 7:01 AM
bjope added inline comments.
clang/test/Driver/wasm-toolchain.c
116

This isn't working for me on redhat 7 servers. I get

"wasm-ld" "-L/lib" "/lib/crt1.o" ...

No idea why I get the full patch to crt1.o. But it's not matching with the FileCheck pattern.

bjope added inline comments.Jun 4 2020, 7:03 AM
clang/test/Driver/wasm-toolchain.c
116

/full patch/full path/

sunfish marked an inline comment as done.Jun 4 2020, 7:44 AM
sunfish added inline comments.
clang/test/Driver/wasm-toolchain.c
116

Would you be able to test whether the following patch fixes it?

diff
diff --git a/clang/test/Driver/wasm-toolchain.c b/clang/test/Driver/wasm-toolchain.c
index 8300a81614e..332e6048cc5 100644
--- a/clang/test/Driver/wasm-toolchain.c
+++ b/clang/test/Driver/wasm-toolchain.c
@@ -110,11 +110,11 @@

 // Basic exec-model tests.

-// RUN: %clang %s -### -no-canonical-prefixes -target wasm32-unknown-unknown -mexec-model=command 2>&1 \
+// RUN: %clang %s -### -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=%s/no-sysroot-there -mexec-model=command 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-COMMAND %s
 // CHECK-COMMAND: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // CHECK-COMMAND: wasm-ld{{.*}}" "crt1.o" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"

-// RUN: %clang %s -### -no-canonical-prefixes -target wasm32-unknown-unknown -mexec-model=reactor 2>&1 \
+// RUN: %clang %s -### -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=%s/no-sysroot-there -mexec-model=reactor 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-REACTOR %s
 // CHECK-REACTOR: wasm-ld{{.*}}" {{.*}} "--entry" "_initialize" {{.*}}
bjope added inline comments.Jun 4 2020, 8:19 AM
clang/test/Driver/wasm-toolchain.c
116

Yes, that is working.

sunfish marked an inline comment as done.Jun 4 2020, 4:48 PM
sunfish added inline comments.
clang/test/Driver/wasm-toolchain.c
116

Thanks for confirming! I've now committed this fix.