Anyone expecting to want to build .wasm via GN?

810 views
Skip to first unread message

Andrew Grieve

unread,
Oct 15, 2019, 4:41:08 PM10/15/19
to chromium-dev
I've got a project (SuperSize) that I'd like to create a .wasm module for. Does anyone else have a desire / need to build .wasm modules? Trying to figure out how much effort to put into "proper" build support for it.

Ken Russell

unread,
Oct 15, 2019, 5:36:53 PM10/15/19
to Andrew Grieve, chromium-dev
Yes, I'd love it if it were easier to build parts of Chromium as .wasm modules. Thinking specifically about ANGLE's shader translator.


On Tue, Oct 15, 2019 at 1:40 PM Andrew Grieve <agr...@chromium.org> wrote:
I've got a project (SuperSize) that I'd like to create a .wasm module for. Does anyone else have a desire / need to build .wasm modules? Trying to figure out how much effort to put into "proper" build support for it.

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CABiQX1VU27suaNFhn-R8eR3bww%3DpeMmJ9SThh8Gigm-8d%3DNsOg%40mail.gmail.com.

Ken Rockot

unread,
Oct 15, 2019, 5:42:10 PM10/15/19
to Kenneth Russell, Andrew Grieve, chromium-dev
My interest isn't really relevant to Chromium, but I started hacking on a GN toolchain for wasm a few months ago. Never quite finished it, but it would be great to have one.

Dirk Pranke

unread,
Oct 15, 2019, 5:55:08 PM10/15/19
to Kenneth Russell, Andrew Grieve, chromium-dev
Ken, can you say a little more about this, e.g., why you'd want that to be wasm rather than compiled as native code?

-- Dirk

Mike Frysinger

unread,
Oct 15, 2019, 5:55:21 PM10/15/19
to Andrew Grieve, chromium-dev
i suspect CrOS will want this in the next year ...
-mike

On Tue, Oct 15, 2019 at 1:41 PM Andrew Grieve <agr...@chromium.org> wrote:
I've got a project (SuperSize) that I'd like to create a .wasm module for. Does anyone else have a desire / need to build .wasm modules? Trying to figure out how much effort to put into "proper" build support for it.

--

Ken Russell

unread,
Oct 15, 2019, 6:10:13 PM10/15/19
to Dirk Pranke, Andrew Grieve, chromium-dev
Hi Dirk,

That particular module is useful for processing incoming WebGL shaders in various ways that the browser's built-in version can't do via the web-exposed APIs. Emulating the behavior of mobile GPUs on desktop GPUs, and providing better shader editing tools as extensions, are two key use cases. (We wouldn't want to ship the .wasm module with the browser, but make it easier to generate it via the GN files.)

-Ken

Nico Weber

unread,
Oct 15, 2019, 6:57:10 PM10/15/19
to Kenneth Russell, Dirk Pranke, Andrew Grieve, chromium-dev
I looked at this a while ago too (https://chromium-review.googlesource.com/c/chromium/src/+/1282394). Please involve me in any discussions here; I want to make sure we don't end up with another copy of the LLVM toolchain.

Mike Frysinger

unread,
Oct 15, 2019, 7:00:26 PM10/15/19
to Nico Weber, Kenneth Russell, Dirk Pranke, Andrew Grieve, chromium-dev
llvm-8/llvm-9 include WASM directly now, so there's (hopefully) no need to have sep now right ?  just make sure the Chromium one enables the target.
-mike

Nico Weber

unread,
Oct 15, 2019, 7:29:41 PM10/15/19
to Mike Frysinger, Kenneth Russell, Dirk Pranke, Andrew Grieve, chromium-dev
That's what I thought, but last time we talked about this the wasm SDK needs more than just clang + lld. IIRC emscripten had both downstream diffs (for, uh, threading maybe?) and additional tools (binaryen) and C runtime bindings and whatnot.

It's important that we don't import emscripten wholesale but use the wasm stuff in Chromium's clang+lld, and then be mindful what of the rest we pull in.

Mike Frysinger

unread,
Oct 15, 2019, 7:53:25 PM10/15/19
to Nico Weber, Kenneth Russell, Dirk Pranke, Andrew Grieve, chromium-dev
yeah, "i want WASM" means different things to different people and can be quite loaded :).  might help to get a better scope of survey of what people actually want/expect out of their WASM modules.

for the additional tools (e.g. binaryen & wabt), i'm not sure you'll be able to avoid them.  but i don't think their inclusion should be that onerous beyond "it's not nothing".

integrating emscripten into the Chromium build is probably a big can of worms.  i'm not sure that'll ever work well for Chromium.
-mike

Derek Schuff

unread,
Oct 15, 2019, 8:34:35 PM10/15/19
to vap...@chromium.org, Nico Weber, Kenneth Russell, Dirk Pranke, Andrew Grieve, chromium-dev
I think clarifying what we mean by "I want wasm" is indeed the best place to start. Especially whether or not it's going to be equivalent to something you'd use on a web page (i.e. embedded in a JS environment). (And if not, you're going to build your own wasm embedding, which is a separate interesting discussion).

It's not necessary to use emscripten proper to build wasm (if this is a non-JS embedding, then it's not what you want anyway).
Emscripten does not have any downstream diffs in LLVM or lld; it does have a separate tool (binaryen, for post-compilation optimization), and its own C runtime libraries. It does not need anything else beyond what's already in the Chromium build (Python and node).

If you want a JS embedding without emscripten, then you need to implement those bindings yourself; i.e. you need a C/C++ runtime library, and you need JS code that implements the "syscalls" that your C code uses. Emscripten generates JS code customized for each wasm module it compiles (and it does dead-code elimination across the JS<->wasm boundary). You could do that, or you could implement one monolithic JS library that has every function you'll ever need, and loads the wasm module. Which approach is best depends a lot on the specifics of how you want to use the wasm modules.


Ken Russell

unread,
Oct 15, 2019, 10:06:22 PM10/15/19
to Derek Schuff, Mike Frysinger, Nico Weber, Dirk Pranke, Andrew Grieve, chromium-dev
Personally I'd love to be able to build some of Chromium's executable or library targets and easily embed them in a JS environment.

It'd be fine from my standpoint if this required additional options to be specified in .gclient, so that the majority of developers didn't have to fetch the associated toolchains.

Andrew Grieve

unread,
Oct 16, 2019, 10:56:06 AM10/16/19
to Ken Russell, Derek Schuff, Mike Frysinger, Nico Weber, Dirk Pranke, Andrew Grieve, chromium-dev
The "which wasm do you want" does seem like a tricky thing to address (emscripten vs WASI seem like the primary options?).

I think GN is well-suited to just supporting multiple options if we need to via different toolchains, but anyone have opinions on non-controversial first steps?

E.g. I believe pdfium added some minimal support in chrome for wasm:

I posted this due to wanting to add a minimal emscripten toolchain, although I think we could just as easily use WASI if that was more inline with what others want.

Yudong Han

unread,
Jun 21, 2023, 9:07:18 PM6/21/23
to Chromium-dev, Ken Rockot, Andrew Grieve, chromium-dev, Kenneth Russell
Hello! Do you have any latest updates on the progress of compiling ANGLE's shader translator to WebAssembly?

Ken Russell

unread,
Jul 13, 2023, 8:39:39 PM7/13/23
to Yudong Han, Chromium-dev, Ken Rockot, Andrew Grieve
I'd personally very much like it if a Wasm toolchain were integrated into Chromium's built-in build tools. That would motivate me to invest time figuring out how to build the shader translator as a Wasm module, reusing the existing GN files.

-Ken


流浪大法师

unread,
Aug 30, 2024, 5:01:52 PMAug 30
to Chromium-dev, Ken Russell, Chromium-dev, Ken Rockot, Andrew Grieve, Yudong Han
GN seems to support build c++/c to wasm by default.
Reply all
Reply to author
Forward
0 new messages