News for hackers. Stuff that matters.
Re:LLVM 8.0.0 Release by Scuds on Wednesday March 20, 2019 @10:35AM (#19442630)
Does this mean wasm is effectively just another ISA to compile to and emscripten is no longer needed?
Re:LLVM 8.0.0 Release by steveklabnik on Wednesday March 20, 2019 @12:17PM (#19443686)
It's a bit more complex than that. emscripten tries to provide a full environment; it adds a runtime with features like a libc. It also produces some HTML and JavaScript to load up the wasm, etc. The new wasm target gives you none of that. This means smaller binaries for some things, but it's harder to get existing desktop codebases up and running.

(In Rust, we've had this new target for a while, and it's where we're putting in all of our development efforts. We still technically support the emscripten target as well.)

Re:LLVM 8.0.0 Release by Orphis on Wednesday March 20, 2019 @10:51AM (#19442777)
If you need really small functions, yes. emscripten is providing all the libc functions, WASM loading code and binding generators. You will probably need some of that when porting existing libraries or applications to the web!
Re:LLVM 8.0.0 Release by e12e on Wednesday March 20, 2019 @01:34PM (#19444595)
Well, you generally need a libc when compiling for any platform, so that shouldn't be too special?
Re:LLVM 8.0.0 Release by steveklabnik on Wednesday March 20, 2019 @02:03PM (#19444954)
You don't inherently need a libc for wasm. That is, libc is usually the API for the platform; wasm doesn't have such a thing really. Your wasm module says "hey, these are the functions I expose, and these are the functions that I am planning to call from the environment" and it's the host's job to wire that up properly. In the browser, that means when you instantiate a wasm module, you need to provide all the required functions, and then you can call the exposed functions from JS. Outside the browser, what things you can call and will be called is defined by the host.

A libc can be useful inside of wasm for existing C or C++ code (or whatever) that is built for another platform, so that you can more easily compile to wasm as well. But it's an option, not required.

Re:LLVM 8.0.0 Release by e12e on Wednesday March 20, 2019 @04:13PM (#19446362)
Well, I meant that if you want to cross compile general code, you might want malloc, printf etc...

I'm not sure the primary appeal of wasm is treating it as a low level target (even if that is possible and sometimes useful).

Re:LLVM 8.0.0 Release by steveklabnik on Wednesday March 20, 2019 @04:42PM (#19446626)
You can get that stuff without a libc, if you’re not literally compiling C or C++. If you are, you’re right, though.
Re:LLVM 8.0.0 Release by Orphis on Wednesday March 20, 2019 @04:59PM (#19446855)
You don't necessarily need it. You could have some math focused code you want to call from JS.
Re:LLVM 8.0.0 Release by petters on Wednesday March 20, 2019 @12:19PM (#19443704)
No, it is not needed any more. I have a demo here: https://github.com/PetterS/clang-wasm

But be prepared to work without libc if you don't use emscripten. Writing a malloc is fun though!

Re:LLVM 8.0.0 Release by s_tec on Wednesday March 20, 2019 @05:18PM (#19447042)
Nice demo, thanks.

It's funny how technology go in waves. This reminds me more of programming microcontrollers than writing Web stuff, and yet this is the hot new thing!

Re:LLVM 8.0.0 Release by BubRoss on Wednesday March 20, 2019 @12:07PM (#19443567)
That is a good question, but as I understand it (from reading only) emscripten does a few other things, such as convert opengl calls to webgl, as well as use special integrated versions of SDL and GLFW so that native programs that use those libraries can be compiled directly.

Both of those would include input and I think audio is dealt with in a similar way.