kripken/emscripten — Issue #252: cannot compile libspeex with optimizations
Author: paleozogt
Created: 2012-02-14 00:34:14+00:00
State: open

I'm trying to build [libspeex](http://www.speex.org/downloads/). It compiles ok, but linking it to a .js file fails with any optimizations:

```

$emcc -O0 libspeex/.libs/libspeex.a libspeex.js

$ls -l libspeex.js
-rw-r--r-- 1 asimmons staff 1766980 Feb 13 17:32 libspeex.js

$emcc -O1 libspeex/.libs/libspeex.a libspeex.js

node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Assertion failed: undefined
Traceback (most recent call last):
File "/Users/asimmons/Development/emscripten/emcc", line 641, in
final = shared.Building.eliminator(final)
File "/Users/asimmons/Development/emscripten/tools/shared.py", line 711, in eliminator
assert len(output) > 0, 'Error in eliminator: ' + err + '\n\n' + output
AssertionError: Error in eliminator:
/Users/asimmons/Development/emscripten/tools/eliminator/node_modules/coffee-script/lib/command.js:15
return process.binding('stdio').writeError(line + '\n');
^
Error: No such module
at /Users/asimmons/Development/emscripten/tools/eliminator/node_modules/coffee-script/lib/command.js:15:20
at /Users/asimmons/Development/emscripten/tools/eliminator/node_modules/coffee-script/lib/command.js:167:7
at /Users/asimmons/Development/emscripten/tools/eliminator/node_modules/coffee-script/lib/command.js:115:26
at [object Object]. (fs.js:115:5)
at [object Object].emit (events.js:64:17)
at afterRead (fs.js:1111:12)
at Object.wrapper [as oncomplete] (fs.js:254:17)

$emcc -O2 libspeex/.libs/libspeex.a libspeex.js

node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Assertion failed: undefined
Traceback (most recent call last):
File "/Users/asimmons/Development/emscripten/emcc", line 637, in
flush_js_optimizer_queue()
File "/Users/asimmons/Development/emscripten/emcc", line 618, in flush_js_optimizer_queue
final = shared.Building.js_optimizer(final, js_optimizer_queue)
File "/Users/asimmons/Development/emscripten/tools/shared.py", line 695, in js_optimizer
assert len(output) > 0 and not output.startswith('Assertion failed'), 'Error in js optimizer: ' + err + '\n\n' + output
AssertionError: Error in js optimizer:
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
TypeError: object is not a function
at Object.CALL_NON_FUNCTION (native)
at new JS_Parse_Error (/Users/asimmons/Development/emscripten/tools/eliminator/node_modules/uglify-js/lib/parse-js.js:261:20)
at js_error (/Users/asimmons/Development/emscripten/tools/eliminator/node_modules/uglify-js/lib/parse-js.js:272:15)
at croak (/Users/asimmons/Development/emscripten/tools/eliminator/node_modules/uglify-js/lib/parse-js.js:721:17)
at token_error (/Users/asimmons/Development/emscripten/tools/eliminator/node_modules/uglify-js/lib/parse-js.js:728:17)
at unexpected (/Users/asimmons/Development/emscripten/tools/eliminator/node_modules/uglify-js/lib/parse-js.js:734:17)
at Object.semicolon [as 1] (/Users/asimmons/Development/emscripten/tools/eliminator/node_modules/uglify-js/lib/parse-js.js:754:51)
at prog1 (/Users/asimmons/Development/emscripten/tools/eliminator/node_modules/uglify-js/lib/parse-js.js:1296:28)
at simple_statement (/Users/asimmons/Development/emscripten/tools/eliminator/node_modules/uglify-js/lib/parse-js.js:888:35)
at /Users/asimmons/Development/emscripten/tools/eliminator/node_modules/uglify-js/lib/parse-js.js:798:35

$emcc -O3 libspeex/.libs/libspeex.a libspeex.js
Warning: Applying some potentially unsafe optimizations! (Use -O2 if this fails.)

node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Assertion failed: undefined
Traceback (most recent call last):
File "/Users/asimmons/Development/emscripten/emcc", line 637, in
flush_js_optimizer_queue()
File "/Users/asimmons/Development/emscripten/emcc", line 618, in flush_js_optimizer_queue
final = shared.Building.js_optimizer(final, js_optimizer_queue)
File "/Users/asimmons/Development/emscripten/tools/shared.py", line 695, in js_optimizer
assert len(output) > 0 and not output.startswith('Assertion failed'), 'Error in js optimizer: ' + err + '\n\n' + output
AssertionError: Error in js optimizer:
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
TypeError: object is not a function
at Object.CALL_NON_FUNCTION (native)
at new JS_Parse_Error (/Users/asimmons/Development/emscripten/tools/eliminator/node_modules/uglify-js/lib/parse-js.js:261:20)
at js_error (/Users/asimmons/Development/emscripten/tools/eliminator/node_modules/uglify-js/lib/parse-js.js:272:15)
at croak (/Users/asimmons/Development/emscripten/tools/eliminator/node_modules/uglify-js/lib/parse-js.js:721:17)
at token_error (/Users/asimmons/Development/emscripten/tools/eliminator/node_modules/uglify-js/lib/parse-js.js:728:17)
at unexpected (/Users/asimmons/Development/emscripten/tools/eliminator/node_modules/uglify-js/lib/parse-js.js:734:17)
at Object.semicolon [as 1] (/Users/asimmons/Development/emscripten/tools/eliminator/node_modules/uglify-js/lib/parse-js.js:754:51)
at prog1 (/Users/asimmons/Development/emscripten/tools/eliminator/node_modules/uglify-js/lib/parse-js.js:1296:28)
at simple_statement (/Users/asimmons/Development/emscripten/tools/eliminator/node_modules/uglify-js/lib/parse-js.js:888:35)
at /Users/asimmons/Development/emscripten/tools/eliminator/node_modules/uglify-js/lib/parse-js.js:798:35

$
```