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

Build minimum size ChakraCore for embedding? #4278

Closed
tommyZZM opened this issue Nov 18, 2017 · 10 comments
Closed

Build minimum size ChakraCore for embedding? #4278

tommyZZM opened this issue Nov 18, 2017 · 10 comments

Comments

@tommyZZM
Copy link

default ChakraCore size uses over 41.7mb size, can i make it smaller?

@tommyZZM tommyZZM changed the title Build minium size ChakraCore for embedding Build minium size ChakraCore for embedding ? Nov 18, 2017
@tommyZZM tommyZZM changed the title Build minium size ChakraCore for embedding ? Build minimum size ChakraCore for embedding? Nov 18, 2017
@obastemur
Copy link
Collaborator

41.7? Is that the .a file ? It gets smaller after linker. You may also do ‘strip -x’ to ditch debug symbols.

++
@curtisman had added a smaller binary option that should help further. IIRC that option needs to be enabled with build.sh/CMake for *nix. I will look at that.

@tommyZZM
Copy link
Author

reply @obastemur

41.7 is the size of chakracore for macOS (a binary name ch) that i download from the release page (https://github.com/Microsoft/ChakraCore/releases),

in embedding project, .a file got even larger, nearly 250mb

@obastemur
Copy link
Collaborator

@tommyZZM makes sense. That’s not stripped nor optimized for size.

@obastemur
Copy link
Collaborator

BTW; we include ICU + stdlibc++ embedded into ch and .so in order to make things easy for end users.

++ strip -x reduces extra ~6Mb.. IIRC ChakraCore related part should be around ~20 .

@rhuanjl
Copy link
Collaborator

rhuanjl commented Nov 19, 2017

If Unicode support is not required running the build script with the --no-icu option shrinks it a lot (around 16mb).

@liminzhu
Copy link
Collaborator

liminzhu commented Nov 28, 2017

You can also build without JIT if you want the bare minimum. Trade-off here is obviously performance.

@obastemur @curtisman what's the flag for that again?

@digitalinfinity
Copy link
Contributor

I don't think the build flags are exposed nicely through build.sh but the flag needed is CHAKRACORE_LITE - you can define it in CommonDefines.h or also perhaps also in CFLAGS/CXXFLAGS. I haven't tested the latter though.

See #3553 for details

@obastemur
Copy link
Collaborator

obastemur commented Nov 29, 2017

build.sh supports turning of JIT and disabling ICU. --no-jit --no-icu yet CHAKRACORE_LITE comes with additional perks those I've been planning to enable via build.sh.

We need to merge #4285 first

@liminzhu
Copy link
Collaborator

// cc @curtisman

Lite mode seems very useful that we should document it perhaps in Building ChakraCore.

I did #define CHAKRACORE_LITE in CommonDefines.h and made a x64 release build from today's master but I only see the binary size go down from 6663kb to 6014kb. Am I missing anything?

@curtisman
Copy link
Contributor

#define is not enough, because it also disable JIT and ScriptDebug in the project files.

On windows build, pass /p:BuildLite=true to msbuild to build Lite mode.

Latest master x64 binary size:
Default: 6.71MB
Lite: 3.16MB

We need to do a little work for Linux build to enable Lite mode.
I believe it need to add the NoScriptDebug build and have lite build to turn off both JIT and ScriptDebug in additional to defining CHAKRACORE_LITE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants