Firefox appears to utilize a custom clang toolchain to enable this without documenting how to make such toolchain (wasi sysroot). And expects you to just download the precompiled version from their servers.
Fedora and Fennec F-Droid have since disabled this feature.
https://src.fedoraproject.org/rpms/firefox/c/4cb1381d80a94c9...
https://gitlab.com/relan/fennecbuild/-/commit/12cdb51bb045c3...
Pretty sure you can build it yourself from https://github.com/WebAssembly/wasi-libc given that https://github.com/WebAssembly/wasi-libc/commit/ad5133410f66... is a contribution from a MoCo employee doing a lot of work around toolchains.
But in FreeBSD we build all the pieces directly, here's our build recipes (with some hacks due to llvm's cmake code being stupid sometimes):
compiler-rt (from llvm): https://github.com/freebsd/freebsd-ports/blob/main/devel/was...
libc (from what you linked): https://github.com/freebsd/freebsd-ports/blob/main/devel/was...
libc++ (from llvm): https://github.com/freebsd/freebsd-ports/blob/main/devel/was...