wolfpld / tracy

Frame profiler
https://tracy.nereid.pl/
Other
10.25k stars 692 forks source link

Emscripten build not working #849

Closed FloydZ closed 2 months ago

FloydZ commented 4 months ago

Hi, i have build tracy with the following commands with emscripten:

cd profiler
mkdir build 
cd build
emcmake cmake .. -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON
emmake make 

afterwards I started the webserver with:

python httpd.py

which results in the following errors: Screenshot_20240728_201900

wolfpld commented 4 months ago

Emscripten builds are broken due to

[wasm-validator error in function X86_getInstruction] call param types must match, on 
(call $glGetIntegerv
 (local.get $5)
 (select
  (i32.const 0)
  (select
   (i32.const 1)
   (i32.const 2)
   (i32.and
    (local.tee $2
     (i32.load offset=4
      (local.get $0)
     )
    )
    (i32.const 4)
   )
  )
  (i32.and
   (local.get $2)
   (i32.const 2)
  )
 )
)
(on argument 0)
Fatal: error validating input
em++: error: '/usr/bin/wasm-opt --strip-target-features --post-emscripten -O3 --low-memory-unused --zero-filled-memory --pass-arg=directize-initial-contents-immutable tracy-profiler.wasm -o tracy-profiler.wasm --mvp-features --enable-threads --enable-bulk-memory --enable-multivalue --enable-mutable-globals --enable-sign-ext' failed (returned 1)

It's possible that some flags from the old makefile based build system haven't been properly ported, I'm not able to test that.

FloydZ commented 4 months ago

Thanks for the fast answer. Sorry for my questions, but I never looked into the details of either wasm or emscripten. Is it correct that the error happens in X86_getInstruction in capstone?

It's possible that some flags from the old makefile based build system haven't been properly ported, I'm not able to test that.

That is a good guess. In https://github.com/wolfpld/tracy/blob/master/profiler/CMakeLists.txt the emscripten compiler flags are just set for tracy-profiler project, but not for the other projects.

For quick testing I added the following flags to enforce them globally:

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3 -Wall -DDEBUG -sUSE_FREETYPE=1 -pthread -DIMGUI_ENABLE_FREETYPE -DIMGUI_IMPL_OPENGL_ES2")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g3 -Wall -DDEBUG -sUSE_FREETYPE=1 -pthread -DIMGUI_ENABLE_FREETYPE -DIMGUI_IMPL_OPENGL_ES2")

which didn't change the behavior. Do you have an educated guess which flag is wrong/missing or where should I start looking?

wolfpld commented 2 months ago

Emscripten builds are now fully operational. If in doubt, refer to the CI build setup.

FloydZ commented 2 months ago

Works perfectly, thanks!