facebook / hermes

A JavaScript engine optimized for running React Native.
https://hermesengine.dev/
MIT License
9.86k stars 632 forks source link

iphoneos framework very large size issue (build-apple-framework.sh) #1353

Closed wonhee-jeong closed 2 weeks ago

wonhee-jeong commented 7 months ago

Problem

When building the iphoneos framework in the build-apple-framework.sh script, bitcode is enabled and the binary size is very large (more than 500MB). Bitcode is disabled in scripts in the react native repository.

Solution

In build-apple-framework.sh, set -DHERMES_ENABLE_BITCODE:BOOLEAN=false

cmake -S . -B "build_$1" -G "$BUILD_SYSTEM" \
    -DHERMES_APPLE_TARGET_PLATFORM:STRING="$1" \
    -DCMAKE_OSX_ARCHITECTURES:STRING="$2" \
    -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING="$3" \
    -DHERMES_ENABLE_DEBUGGER:BOOLEAN="$enable_debugger" \
    -DHERMES_ENABLE_INTL:BOOLEAN=true \
    -DHERMES_ENABLE_LIBFUZZER:BOOLEAN=false \
    -DHERMES_ENABLE_FUZZILLI:BOOLEAN=false \
    -DHERMES_ENABLE_TEST_SUITE:BOOLEAN=false \
    -DHERMES_ENABLE_BITCODE:BOOLEAN=false \
    -DHERMES_BUILD_APPLE_FRAMEWORK:BOOLEAN=true \
    -DHERMES_BUILD_APPLE_DSYM:BOOLEAN=true \
    -DHERMES_ENABLE_TOOLS:BOOLEAN="$build_cli_tools" \
    -DIMPORT_HERMESC:PATH="$PWD/build_host_hermesc/ImportHermesc.cmake" \
    -DCMAKE_INSTALL_PREFIX:PATH=../destroot \
    -DCMAKE_BUILD_TYPE="$BUILD_TYPE"
tmikov commented 7 months ago

The iOS build scrips in the Hermes directory are outdated and unmaintained. We should just delete them.

wonhee-jeong commented 7 months ago

Thank you for the kind explanation. That was just an example script.

ZkGator commented 6 months ago

What is the correct/recommended way to build ios framework if those scripts under utils are no longer relevant?

tmikov commented 6 months ago

https://github.com/facebook/react-native/tree/main/packages/react-native/sdks/hermes-engine

ZkGator commented 6 months ago

Thanks a lot! P.S. What'd be the option for those who want to build and use Hermes as a standalone artifact?

tmikov commented 6 months ago

@ZkGator Hermes uses CMake and can be built for any supported OS and likely for some unsupported ones. That hasn't changed. Check our CI scripts for examples. The only thing we are no longer doing is providing a packaged configuration script for iOS framework and a podspec, but those are available from React Native in the link above.

ZkGator commented 6 months ago

Thanks!