From 23eb06f6623f6831ff5f6a2f12e22884de4c1326 Mon Sep 17 00:00:00 2001 From: Krzysztof Piaskowy Date: Thu, 19 Dec 2024 16:23:41 -0800 Subject: [PATCH] Static Hermes for React Native (#48327) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/48327 This PR introduces necessary changes to let React Native uses latest version of static Hermes. ## Explanation ### Part 1 ```cmake append("/d2UndefIntOverflow-" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) ``` 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 ``` fatal error C1007: unrecognized flag '-UndefIntOverflow-' in 'p2' ``` ### Part 2 ```cmake if("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC") # MSVC needs C++20 set(CMAKE_CXX_STANDARD 20) else() set(CMAKE_CXX_STANDARD 17) endif() ``` Some of the new syntax in static Hermes requires the newer C++ standard on MSVC. ### Part 3 ```cmake # Changes in lib/CMakeLists.txt ``` These updates are necessary to successfully build the Hermes Framework for iOS. ### Part 4 ```diff namespace hermes { namespace hbc { namespace { class BytecodeSerializer { - friend void visitBytecodeSegmentsInOrder( + friend void hermes::hbc::visitBytecodeSegmentsInOrder( ``` Due to additional additional anonymous namespace, the MSVC wasn't able to recognise proper symbol without explicite definition. X-link: https://github.com/facebook/hermes/pull/1566 Test Plan: Build RNTester app from here - https://github.com/piaskowyk/react-native/tree/%40piaskowyk/build-static-hermes Reviewed By: tmikov, cipolleschi Differential Revision: D67316013 Pulled By: neildhar fbshipit-source-id: cf03850f94a75acd827b68794700a8f143a90e09 --- packages/react-native/ReactCommon/jsi/jsi/CMakeLists.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/react-native/ReactCommon/jsi/jsi/CMakeLists.txt b/packages/react-native/ReactCommon/jsi/jsi/CMakeLists.txt index 3d2959e54914aa..28c661c9832061 100644 --- a/packages/react-native/ReactCommon/jsi/jsi/CMakeLists.txt +++ b/packages/react-native/ReactCommon/jsi/jsi/CMakeLists.txt @@ -21,9 +21,6 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC") # when they go out of scope due to exceptions. list(APPEND jsi_compile_flags "/EHsc") endif() -if (HERMES_ENABLE_BITCODE) - list(APPEND jsi_compile_flags "-fembed-bitcode") -endif () target_compile_options(jsi PRIVATE ${jsi_compile_flags}) install(DIRECTORY "${PROJECT_SOURCE_DIR}/API/jsi/" DESTINATION include