facebook / hermes

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

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

Open wonhee-jeong opened 1 month ago

wonhee-jeong commented 1 month 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 1 month ago

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

wonhee-jeong commented 1 month ago

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

ZkGator commented 2 days ago

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

tmikov commented 2 days ago

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

ZkGator commented 2 days ago

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