Git Product home page Git Product logo

Comments (17)

tbfleming avatar tbfleming commented on August 16, 2024 1

@kripken that fixed it. Nice branch name :)

from cib.

kripken avatar kripken commented on August 16, 2024

Oh wait, is this using emscripten with the LLVM wasm backend, and not fastcomp/asm2wasm? Seems so from the list of repos in build.py. If so, then the 15-20% size difference is not that surprising, as the wasm backend tends to emit larger code. Might be worth adding a build step to run binaryen's optimizer, then.

from cib.

tbfleming avatar tbfleming commented on August 16, 2024

is this using emscripten with the LLVM wasm backend

Yes.

Might be worth adding a build step to run binaryen's optimizer, then.

Sounds good.

from cib.

juj avatar juj commented on August 16, 2024

If using CMake and e.g. Unix Makefiles generator, then one should pass -DCMAKE_BUILD_TYPE=Release to the build if not otherwise specified, as CMake defaults to building Debug build type, which is unoptimized. emcmake does not reach the linking phase to do any adjustments.

from cib.

tbfleming avatar tbfleming commented on August 16, 2024

Here's what it currently uses:

  • -DCMAKE_BUILD_TYPE=Release to build llvm's *.a
  • -DCMAKE_BUILD_TYPE=Debug to build the final executable. Release crashes during build.

from cib.

tbfleming avatar tbfleming commented on August 16, 2024

It's now down to 43M.

from cib.

kripken avatar kripken commented on August 16, 2024

I'm a little confused by

@juj: emcmake does not reach the linking phase to do any adjustments.

@tbfleming -DCMAKE_BUILD_TYPE=Debug to build the final executable.

Is cmake issuing the final emcc command to link and generate the executable? I don't see an emcc command in the build script, so it seems like that's the case, but if I understand you @juj that shouldn't be possible?

Release crashes during build.

Oh, do you have an error message or stack trace from that? EMCC_DEBUG=1 in the env could give more info.

from cib.

tbfleming avatar tbfleming commented on August 16, 2024

Is cmake issuing the final emcc command to link and generate the executable?

Yes. Here's the commands which create the app. I'm running it through release to give you a log.

cd /mnt/cib/build/clang-browser-Release/ && emcmake cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DLLVM_BUILD=/mnt/cib/build/llvm-browser-Release/ -DEMSCRIPTEN=on ../../src

cd /mnt/cib/build/clang-browser-Release/ && ninja clang

-DLLVM_BUILD=... and -DEMSCRIPTEN=on are variables in my CMakeLists.txt.

from cib.

tbfleming avatar tbfleming commented on August 16, 2024

Oops. Sorry; I remembered wrong. It builds but hits this at runtime:

stackAlloc is not defined

from cib.

kripken avatar kripken commented on August 16, 2024

1: That stackAlloc issue might be fixed by emscripten-core/emscripten#5986 (Please let me know either way if you check.)

2: Is the relevant CMakeLists.txt this one? https://github.com/tbfleming/cib/blob/master/src/CMakeLists.txt#L105

If so then it looks like cmake is picking the -Ox optimization level for the final link stage. (@juj, is that odd?) Some notes on the flags:

from cib.

tbfleming avatar tbfleming commented on August 16, 2024

1: I'll try it
2: Yes

I forgot to remove the SAFE_HEAP after debugging.

This reminds me of an issue: NO_EXIT_RUNTIME doesn't stop it from closing stdio. I had to do this instead: https://github.com/tbfleming/cib/blob/master/src/process.js#L137

from cib.

tbfleming avatar tbfleming commented on August 16, 2024

emscripten-core/emscripten#5986 fixed the stackAlloc issue. I also removed SAFE_HEAP, ASSERTIONS, DEMANGLE_SUPPORT, and NO_EXIT_RUNTIME.

Step 1 Release build 41M
Step 2 wasm-opt -Os 36M
Step 3 combine data segments 37M

Step 3 is because the builds sometimes produce around 130,000 data segments, which exceed Firefox's and Chrome's 100,000 limit. I combine them into a single segment.

from cib.

kripken avatar kripken commented on August 16, 2024

Is that stdio issue fixed by emscripten-core/emscripten#6038 ?

About wasm having a 100,000 segment limitation, I wasn't aware of that limit. @lukewagner , is that a temporary thing, or should binaryen work around it?

from cib.

tbfleming avatar tbfleming commented on August 16, 2024

emscripten-core/emscripten#6038 fixed it.

from cib.

lukewagner avatar lukewagner commented on August 16, 2024

It's a permanent limit and should be the same across browsers since it is in the list of constant limits. If there was a hard reason to relax it, it could be relaxed.

from cib.

kripken avatar kripken commented on August 16, 2024

Ok, thanks for the info, I'll handle it in binaryen.

from cib.

kripken avatar kripken commented on August 16, 2024

@tbfleming WebAssembly/binaryen#1350 should work around the 100K segment limit, please verify it works if you can.

from cib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.