Compiling Bullet Physics with llvm

262 views
Skip to first unread message

madhav

unread,
Dec 23, 2010, 12:16:22 AM12/23/10
to emscripten-discuss
Hello all,

Followed the tests/bullet/readme.txt to build bulletphysics engine
using llvm. The compilation had no issues. How do we generate
bulletTest.ll file from the built libraries libBulletDynamics.a, ....
Is there any specific steps need to be followed?.

-madhav

Alon Zakai

unread,
Dec 23, 2010, 1:30:00 PM12/23/10
to emscripte...@googlegroups.com
The CMakeLists.txt changes mentioned in the readme.txt
will get the compiler to generate LLVM bitcode. So those
.a files are really LLVM bitcode, not normal binaries.
To get .ll files from them, you should run llvm-dis
(with -show-annotations).

- azakai

madhav

unread,
Dec 23, 2010, 2:44:22 PM12/23/10
to emscripten-discuss
Bullet library has few libraries like libBulletDynamics.a,
libBulletCollision.a, libBulletMultithread.a..
so u mean to link it, as below
$>llvm-link libBulletDynamics.a, libBulletCollision.a,
libBulletMultithread.a -o libBullet.bc
and dissemble to get .ll
$> llvm-dis -show-annotations libBullet.bc

Also, was wondering how the bullet/webgl demo is built. doit.sh script
contains build details related to Helloworld.cpp(bullet/webgl), built
the HelloWorld.js with changes to settings.py, modified HelloWorld.js
arguments[], commented main function call and added Bullet=Module();
The modified file is not running on browser, there are errors in
preparev....
Any suggestion on how to get bullet/webgl build properly.

Basically im trying to make changes to bullet/webgl demo. Changes like
adding left/right/top walls and more stack of boxes

- madhav

Alon Zakai

unread,
Dec 24, 2010, 3:32:05 PM12/24/10
to emscripte...@googlegroups.com
We discussed this on IRC, but just to summarize for
other people's benefit:

1. Build bullet. Get .a files, which are llvm bitcode.
2. Build HelloWorld. Get .o file, which is llvm bitcode.
3. Link bullet dynamics and bullet collision with HelloWorld.
4. llvm-dis -show-annotations on that.
5. Run Emscripten on that.

- azakai


----- Original Message -----
> From: "madhav" <venu....@gmail.com>
> To: "emscripten-discuss" <emscripte...@googlegroups.com>

madhav

unread,
Dec 27, 2010, 7:58:35 AM12/27/10
to emscripten-discuss
Done the following steps
1) built successfully the HelloWorld.cpp with bullet.ll(generated from
libBulletCollision.a, libBulletDynamics.a).
2) generated bullet.js using Emscripten with v8
3) Modified bullet.js,
i) added Module = {}, args=[] and commented the earlier source
ii) added var Bullet = Module; @last line of file
ii) commented calls to main() and __shutownRuntime__

Have used the same html source(demo.html, bullet_demo.js) to test
webgl/bullet. There are few issues now,
- in js console there are errors
a) related to line tempVector3 = Bullet._.btVector3.__new__(); ->
cannot read property btVector3 of undefined. it seems that there is no
object Bullet._.* defined
b) Uncaught reached an unreachable: Original .ll

Are there any other steps that ive missed?

By the way on comparision of bullet.js(original) with generated one,
found that Module['_'] was defined in original one, so guess there
might have been some more changes done manually to generated .js other
than the ones mentioned above.

- madhav

Alon Zakai

unread,
Dec 28, 2010, 1:11:44 PM12/28/10
to emscripte...@googlegroups.com
Sorry, I forgot about the additional namespace
stuff that needs to be done. Basically,

1. Run third_party/demangler.py on the source. It
will generate unmangled names for all the functions.
I think it needs . as a commandline parameter.
2. Run tools/namespacer.py on that. It will generate the
'_' thing, and fill it with some useful boilerplate,
that allows writing things like

Bullet._.btVector3

and so forth.

See comments in both of those files for more
details. Also the test_scriptaclass test (in
tests/runner.py) is a test for the process of
using both of these, so it's an example of their
use.

- azakai


----- Original Message -----
> From: "madhav" <venu....@gmail.com>
> To: "emscripten-discuss" <emscripte...@googlegroups.com>

madhav

unread,
Dec 29, 2010, 1:18:48 AM12/29/10
to emscripten-discuss
Thank you for the reply.

Generated the .js with the namespace added as defined in
test_scriptaclass. It fixed the issue(a).

Related to another issue(b), after enabling EXCEPTION_DEBUG, from the
stack trace found,

__Z22btAlignedAllocInternalji is not defined.

on comparision with orignal .js found the function was defined there
and not defined in generated one.
any suggestion/pointer on that?

Also found "//Addition Demo stuff $" defined after the set of lines of
namespaces Module['_'].
Is that required?

Alon Zakai

unread,
Dec 29, 2010, 12:54:12 PM12/29/10
to emscripte...@googlegroups.com
>
> Generated the .js with the namespace added as defined in
> test_scriptaclass. It fixed the issue(a).
>
> Related to another issue(b), after enabling EXCEPTION_DEBUG, from the
> stack trace found,
>
> __Z22btAlignedAllocInternalji is not defined.
>
> on comparision with orignal .js found the function was defined there
> and not defined in generated one.
> any suggestion/pointer on that?

I see that function in tests/bullet/bulletTest.ll. I
guess in the one you made it doesn't exist, the question
is where is it being referenced? Is it from compiled bullet,
or from some of the 'glue' code for the demo (if so, that
would need to be updated)?

If you want, put up all the relevant files and I'll
take a look.

>
> Also found "//Addition Demo stuff $" defined after the set of lines of
> namespaces Module['_'].
> Is that required?

That's just a placeholder comment, it's used in some
tests. You can ignore it or remove it.

- azakai

madhav

unread,
Dec 29, 2010, 1:05:42 PM12/29/10
to emscripten-discuss
Thanks for the response.

The issue is fixed.
we need libLinearMath.a also during linking dynamics & collision
libraries.

There is small bug, few of the variables defined are using
$variablename, but are while they were used it is _variablename,
modifying this is needed.
Finally, Bullet/WebGL works now.

Few Queries:
1) How can we use WebWorkers for simulation using physics engine. Does
emscripten(generated js) supporting workers?
2) All demos in bulletphysics trunk can be transformed to JS version?

- madhav

Alon Zakai

unread,
Dec 29, 2010, 2:00:40 PM12/29/10
to emscripte...@googlegroups.com
>
> The issue is fixed.
> we need libLinearMath.a also during linking dynamics & collision
> libraries.

Thanks for figuring this out!

>
> There is small bug, few of the variables defined are using
> $variablename, but are while they were used it is _variablename,
> modifying this is needed.

Ah, this changed last month, that's why there is
a difference here in the older demo code.

> Finally, Bullet/WebGL works now.

Great!

>
> Few Queries:
> 1) How can we use WebWorkers for simulation using physics engine. Does
> emscripten(generated js) supporting workers?

Not yet. The main issue is that web workers do not
have shared state - they are like another process,
not another thread, in that sense. So we might want
to have a C++ API for multiprocessing, that is
implemented using web workers.

> 2) All demos in bulletphysics trunk can be transformed to JS version?

That should be possible, yes, just a matter of
doing the work I think.

- azakai

jimmy

unread,
Sep 11, 2014, 3:48:46 AM9/11/14
to emscripte...@googlegroups.com
hi ,may i know how do you build the bullet,I followed these steps,but failed:
 1.emconfigure ./configure
2.emmake make

do you know why?

在 2010年12月23日星期四UTC+8下午1时16分22秒,madhav写道:

Alon Zakai

unread,
Sep 11, 2014, 12:29:25 PM9/11/14
to emscripte...@googlegroups.com
https://github.com/kripken/ammo.js builds bullet, see make.py

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages