4 ms·
> I struggled a lot using Emscripten to port FFmpeg to wasm - you have to compile EVERY dependency to wasm This is a scenario where the Bazel model is a good f
by haberman 6y ago
> I struggled a lot using Emscripten to port FFmpeg to wasm - you have to compile EVERY dependency to wasm
This is a scenario where the Bazel model is a good fit IMHO. Bazel rebuilds all of your dependencies from source. This makes it easy to compile all of your dependencies with an extra flag (eg -fsanitize=address for ASAN) or using a different compiler (eg Emscripten).
While it can be annoying to wait for the world to rebuild every time, this is a use case where it shines.
- jez 6y agoDo you have an example of getting bazel to work with emscripten? I’ll share mine if you share yours: https://github.com/sorbet/sorbet/tree/master/tools/toolchain/webasm-linux https://github.com/sorbet/sorbet/tree/master/tools/toolchain... When we set this up to compile Sorbet (C++ codebase) for https://sorbet.run https://sorbet.run, it involved what I considered an inordinate amount of boilerplate and arcana. To be fair since we set it up it’s hardly ever needed to be touched, and I could probably cargo cult this into future projects where I wanted to use it, but I wouldn’t exactly say that bazel magically makes the pain of emscripten go away. Curious to hear otherwise.
- haberman 6y agoYikes. That definitely seems more complicated than it should be. I have not used Emscripten in this way before, I was going from my experience of passing custom flags like -fsanitize=address. I was under the impression that Emscripten was just an alternative compiler binary, such that you could just use CC=emcc. Is that not the case?
- jez 6y agoThe trick is that to provide Bazel with a custom toolchain involves way more than just setting an environment variable, because Bazel wants to control installing and making available the compiler reliably (e.g., what if `emcc` is not present on the system where Bazel was invoked? Bazel solves that problem by fetching it and building it for that system) There are projects that provide drop-in support for custom toolchains (e.g., we use this project[0] in Sorbet to fetch and build a custom LLVM/Clang toolchain for every host we build on (rather than relying on the system toolchain). But I'm not aware of a project that has done that for Emscripten. Maybe it would be as easy as plucking out what we've done in our project into a project that others could depend on, but to quote a colleague: > Setting up a cc toolchain in Bazel is a unique sort of pain. [0] https://github.com/grailbio/bazel-toolchain/ https://github.com/grailbio/bazel-toolchain/