add emscripten builds, with and without SIMD
These build, and hit each side of __wasm_simd128__.
I can disassemble the wasm and see v128 used where appropriate:
~/skcms (emcc↑1|✔) $ wasm-objdump -d out/emscripten/skcms.o | grep -q v128 && echo ok || echo no
no
~/skcms (emcc↑1|✔) $ wasm-objdump -d out/emscripten.simd/skcms.o | grep -q v128 && echo ok || echo no
ok
I should note that in order to build the .simd version,
I had to follow these directions to get a bleeding-edge toolchain:
https://brionv.com/log/2019/03/03/simd-in-webassembly-tales-from-the-bleeding-edge/
Setting exe=.html creates some handy html/js/wasm files as
the output that you can serve up locally (python -m SimpleHTTPServer)
and run. Currently failing due to filesystem IO, but it's a start.
expect(load_file(filename, &buf, &len)) failed at tests.c:615
Change-Id: Ib9473584b43ec35ea2bb81d9765c6814b5084e89
Reviewed-on: https://skia-review.googlesource.com/c/skcms/+/197180
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
diff --git a/build/emscripten b/build/emscripten
new file mode 100644
index 0000000..eef3b25
--- /dev/null
+++ b/build/emscripten
@@ -0,0 +1,12 @@
+cc = emcc
+cxx = em++
+cflags = -s WASM=1
+ldflags = -s WASM=1
+exe = .html
+out = out/emscripten$mode
+
+rule run
+ command = touch $out
+ description = skipping $in
+
+include build/common
diff --git a/build/emscripten.simd b/build/emscripten.simd
new file mode 100644
index 0000000..f8279fa
--- /dev/null
+++ b/build/emscripten.simd
@@ -0,0 +1,5 @@
+mode = .simd
+extra_cflags = -s SIMD=1
+extra_ldflags = -s SIMD=1
+
+include build/emscripten
diff --git a/skcms.cc b/skcms.cc
index f41376e..b965c56 100644
--- a/skcms.cc
+++ b/skcms.cc
@@ -1806,15 +1806,6 @@
Op_store_ffff,
} Op;
-// Without this wasm would try to use the N=4 128-bit vector code path,
-// which while ideal, causes tons of compiler problems. This would be
-// a good thing to revisit as emcc matures (currently 1.38.5).
-#if 1 && defined(__EMSCRIPTEN_major__)
- #if !defined(SKCMS_PORTABLE)
- #define SKCMS_PORTABLE
- #endif
-#endif
-
#if defined(__clang__)
template <int N, typename T> using Vec = T __attribute__((ext_vector_type(N)));
#elif defined(__GNUC__)
@@ -1829,7 +1820,8 @@
// First, instantiate our default exec_ops() implementation using the default compiliation target.
namespace baseline {
-#if defined(SKCMS_PORTABLE) || !(defined(__clang__) || defined(__GNUC__))
+#if defined(SKCMS_PORTABLE) || !(defined(__clang__) || defined(__GNUC__)) \
+ || (defined(__EMSCRIPTEN_major__) && !defined(__wasm_simd128__))
#define N 1
using F = float;
using U64 = uint64_t;