-
Notifications
You must be signed in to change notification settings - Fork 645
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
Static Hermes for React Native #1566
base: static_h
Are you sure you want to change the base?
Static Hermes for React Native #1566
Conversation
sounds cool. how should I try it? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome, thank you for working on this! I want to make sure I understand how this works, so I have some questions and suggestion.
Is there some simple e2e CI we can set up that builds an RN app to make sure this doesn't break?
lib/CMakeLists.txt
Outdated
endif() | ||
set(DSYM_PATH "${DSYM_PATH}.dSYM") | ||
|
||
if(NOT CMAKE_DSYMUTIL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is CMAKE_DSYMUTIL
something that is provided by cmake? If not, we should either remove it (if it can't be configured) or name it something else to avoid confusion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can just rename it to something else. Like HERMES_DSYMUTIL
, so we know that it is hermes specific, but may be configured.
A cleaner solution, if you're changing the RN build scripts anyway, may be to remove the HERMES_BUILD_APPLE_DSYM
flag altogether, and instead just pass in -DCMAKE_CXX_FLAGS=-gdwarf
from the RN build script, and then manually run the dsymutil from the script. (since this stuff can easily be done in the RN build script instead of in CMake)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, so I'll try to move that part to the React Native build script. I'll let you know here when it's ready 🫡
lib/CMakeLists.txt
Outdated
set_target_properties(hermesvm PROPERTIES | ||
FRAMEWORK TRUE | ||
VERSION ${PROJECT_VERSION} | ||
SOVERSION ${PROJECT_VERSION} | ||
FRAMEWORK_VERSION ${PROJECT_VERSION_MAJOR} | ||
MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${PROJECT_VERSION} | ||
MACOSX_FRAMEWORK_BUNDLE_VERSION ${PROJECT_VERSION} | ||
MACOSX_FRAMEWORK_IDENTIFIER dev.hermesengine.${HERMES_APPLE_TARGET_PLATFORM} | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This builds only for MacOS. In React Native we support also iOS, Catalyst, XR and TvOS... 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review! 🎉
I think there isn't anything like that currently. Would you prefer to include it in this PR, or would it be better to handle it in a separate PR to avoid expanding the scope of the current one? |
Thanks for updating the changes! It mostly looks good, just some minor things. Does this work with the existing RN build scripts as-is? I'm wondering if we should eliminate
That can be in a separate PR. For reference, we have one for Android in the main branch. (link) |
Update here: #1566 (comment)
Thanks for the reference! I'll add it 🫡 |
TODO tasks in progress:
|
I've tried to replace |
@@ -48,7 +48,7 @@ set(CMAKE_OSX_SYSROOT ${HERMES_APPLE_TARGET_PLATFORM}) | |||
|
|||
if(HERMES_APPLE_TARGET_PLATFORM MATCHES "catalyst") | |||
set(CMAKE_OSX_SYSROOT "macosx") | |||
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-target x86_64-arm64-apple-ios14.0-macabi -isystem ${CMAKE_OSX_SYSROOT}/System/iOSSupport/usr/include") | |||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -target x86_64-arm64-apple-ios14.0-macabi -isystem ${CMAKE_OSX_SYSROOT}/System/iOSSupport/usr/include") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes are intended to avoid concatenation with a semicolon; for example, to prevent strings from merging like -gdwarf;-target x86_64...
.
@neildhar has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just noting that we need to set CMAKE_C_FLAGS as well
seems we need more information about the target than just the build system
Could you say more about this? I'm not suggesting any changes on this PR, just trying to understand the situation slightly better. CMAKE_SYSTEM_NAME is set to the platform you are targeting. According to the documentation, it has support for iOS
, Darwin
, tvOS
, and visionOS
. Is Catalyst
the issue?
-DHERMES_BUILD_APPLE_FRAMEWORK:BOOLEAN=true \ | ||
-DHERMES_BUILD_APPLE_DSYM:BOOLEAN=true \ | ||
-DCMAKE_CXX_FLAGS="-gdwarf" \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hermes also contains some C sources, we should set CMAKE_C_FLAGS
as well
Summary
This PR introduces necessary changes to let React Native uses latest version of static Hermes.
Explanation
Part 1
It seems like this flag doesn’t exist anymore in the MSVC 16 compiler.
CI logs - https://github.com/piaskowyk/react-native/actions/runs/11815096269/job/32915591004
Part 2
Some of the new syntax in static Hermes requires the newer C++ standard on MSVC.
Part 3
# Changes in lib/CMakeLists.txt
These updates are necessary to successfully build the Hermes Framework for iOS.
Part 4
Due to additional additional anonymous namespace, the MSVC wasn't able to recognise proper symbol without explicite definition.
Test Plan
Build RNTester app from here - https://github.com/piaskowyk/react-native/tree/%40piaskowyk/build-static-hermes