Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler assertion failure when building Bullet (ammo.js) with SSE support enabled. #3009

Closed
juj opened this issue Nov 20, 2014 · 5 comments
Closed
Labels

Comments

@juj
Copy link
Collaborator

juj commented Nov 20, 2014

Set up to build with the Emscripten branch https://github.com/juj/emscripten/tree/sse2 , then

git clone https://github.com/juj/ammo.js.git
cd ammo.js
git checkout sse
python make.py

Observed:

The build fails with

Linking CXX static library libBulletCollision.a
[100%] Built target BulletCollision
LLVM ERROR: I->getType() == I->getOperand(0)->getType()
Stack dump:
0.  Program arguments: C:/code/emsdk/clang/fastcomp/build_incoming_vs2010_64/bin/RelWithDebInfo\llc c:\users\jukka\appdata\local\temp\tmpcly5lc\temp.bc -march=js -filetype=asm -o c:\users\jukka\appdata\local\temp\tmp2mrtlm.4.js -O3 -emscripten-max-setjmps=20 
1.  Running pass 'Expand and lower illegal >i32 operations into 32-bit chunks' on module 'c:\users\jukka\appdata\local\temp\tmpcly5lc\temp.bc'.
Traceback (most recent call last):
  File "C:\code\emsdk\emscripten\incoming\emscripten.py", line 1655, in <module>
    _main(environ=os.environ)
  File "C:\code\emsdk\emscripten\incoming\emscripten.py", line 1643, in _main
    temp_files.run_and_clean(lambda: main(
  File "C:\code\emsdk\emscripten\incoming\tools\tempfiles.py", line 39, in run_and_clean
    return func()
  File "C:\code\emsdk\emscripten\incoming\emscripten.py", line 1651, in <lambda>
    DEBUG_CACHE=DEBUG_CACHE,
  File "C:\code\emsdk\emscripten\incoming\emscripten.py", line 1538, in main
    jcache=jcache, temp_files=temp_files, DEBUG=DEBUG, DEBUG_CACHE=DEBUG_CACHE)
  File "C:\code\emsdk\emscripten\incoming\emscripten.py", line 805, in emscript_fast
    start_funcs = backend_output.index(start_funcs_marker)
ValueError: substring not found
Traceback (most recent call last):
  File "C:\code\emsdk\emscripten\incoming\emcc", line 1281, in <module>
    final = shared.Building.emscripten(final, append_ext=False, extra_args=extra_args)
  File "C:\code\emsdk\emscripten\incoming\tools\shared.py", line 1501, in emscripten
    assert os.path.exists(filename + '.o.js'), 'Emscripten failed to generate .js'
AssertionError: Emscripten failed to generate .js
@sunfishcode
Copy link
Collaborator

Following the steps above, I get this error:

ImportError: No module named tools.shared

Is there a python package I should install for this?

@kripken
Copy link
Member

kripken commented Dec 17, 2014

tools/shared.py is in emscripten. Which make.py should find using EMSCRIPTEN_ROOT in ~/.emscripten. Is that perhaps not set up right?

@sunfishcode
Copy link
Collaborator

That was it. I was able to reproduce the failure, and I've now checked in several fixes to emscripten-fastcomp. Locally, I also made a few minor edits to the bullet source code, to eliminate _mm_move_sd in 3 places, like this:

  •    v2 = btCastdTo128f(_mm_move_sd(btCastfTo128d(v2), btCastfTo128d(vT))); // z0 z1 z2 0
    
  •    v2 = _mm_shuffle_ps(vT, v2, BT_SHUFFLE(0, 1, 2, 3)); // z0 z1 z2 0
    

(though note that I'm not yet completely confident that that's the right shuffle mask in the end). since _mm_move_sd uses float64x2 which we don't yet support.

With these fixes, the build succeeds. It doesn't validate as asm.js because it's not yet built with -s PRECISE_F32. See [0] for backgroud info; I'll look into hacking the build scripts to add that. And, it doesn't yet run successfully yet; there are errors at runtime that I haven't investigated yet.

[0] https://bugzilla.mozilla.org/show_bug.cgi?id=1077175

@sunfishcode
Copy link
Collaborator

Ok, with several more fixes checked in, plus one hack, I can now build, validate, and run bullet with SIMD. It still needs the changes to avoid _mm_move_sd mentioned above, and it needs this one hack in builds/temp.js to work around the fact that OdinMonkey doesn't support storeXYZ yet [0]:

-SIMD_float32x4_storeXYZ(HEAPU8, $scevgep, $tmpA$sroa$0$0$vec$extract);
+HEAPF32[$scevgep>>2] = $tmpA$sroa$0$0$vec$extract.x;
+HEAPF32[$scevgep + 4>>2] = $tmpA$sroa$0$0$vec$extract.y;
+HEAPF32[$scevgep + 8>>2] = $tmpA$sroa$0$0$vec$extract.z;

[0] https://bugzilla.mozilla.org/show_bug.cgi?id=1113338

@juj juj mentioned this issue Jun 20, 2015
@juj
Copy link
Collaborator Author

juj commented Sep 3, 2015

Works in current incoming.

@juj juj closed this as completed Sep 3, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants