3
votes

Is it possible to build/compile Opus/libopus with optimization using Emscripten?I'm unsure if this is a current limitation of Emscripten and WebAssembly in general or if options exist to ensure the decoder is optimized in WebAssembly (wasm).


I receive the following warning below for opus_decoder:
  CC       src/opus_decoder.lo
src/opus_decoder.c:37:10: warning: You appear to be compiling without optimization, if so
opus will be very slow. [-W#pragma-messages]

This warning is not produced when compiling Opus normally without the Emscripten wrappers:

$ ./configure --disable-intrinsics --disable-rtcd
$ make

The warning is introduced when wrapping:

$ emconfigure ./configure --disable-intrinsics --disable-rtcd
$ emmake make

Using:

  • emcc 1.37.35
  • Opus v1.3-beta - also tested today's master (d01199b)
3
You can pass in CFLAGS to make or configure like $ emconfigure ./configure --disable-intrinsics --disable-rtcd CFLAGS='-O2' - Gray

3 Answers

3
votes

You can pass in CFLAGS into the configure step like this:

emconfigure ./configure --disable-intrinsics --disable-rtcd CFLAGS='-O2'

This will enable optimizations and hide the message.

1
votes

Well, you're running it in emscripten, so it isn't going to be fast anyway ... :)

The issue is that if you fake being gcc but aren't actually an x86 target, you get hit with this message.

You can either ignore the message (the optimizations appear to only be for x86) or define OPUS_WILL_BE_SLOW (-DOPUS_WILL_BE_SLOW) to make it go away.

0
votes

I haven't tested webassembly yet, but I've compiled in the past using emscripten to create code to be used with asm.js and I've used this options for emcc

EMCC_OPTS=-O3 --memory-init-file 0 -s BUILD_AS_WORKER=1 -s NO_EXIT_RUNTIME=1 -s NO_FILESYSTEM=1 -s EXPORTED_FUNCTIONS="['_malloc']" -s EXPORTED_RUNTIME_METHODS="['setValue', 'getValue']"