From 5ef68569b3dafd74e555f02e49e4ecebec3f080a Mon Sep 17 00:00:00 2001 From: Nicola Corti Date: Fri, 11 Apr 2025 03:03:09 -0700 Subject: [PATCH] Bump CMake to 3.30.x and Enable INTERPROCEDURAL_OPTIMIZATION for libhermes.so in OSS Summary: PR is here https://github.com/facebook/react-native/pull/50581 This enables INTERPROCEDURAL_OPTIMIZATION for Hermes in OSS, similar to how we did for libreactnative.so I also had to bump CMake to 3.30.x to unblock the build failure with `-fuse-ld=gold` Changelog: [Internal] [Changed] - Reviewed By: alanleedev Differential Revision: D72696879 fbshipit-source-id: e842f6cdf41f6936ef4baeb70e4833a1a0c2d19b --- packages/react-native/ReactAndroid/build.gradle.kts | 2 +- .../ReactAndroid/hermes-engine/build.gradle.kts | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/react-native/ReactAndroid/build.gradle.kts b/packages/react-native/ReactAndroid/build.gradle.kts index 531637e937d..fe74e3a6200 100644 --- a/packages/react-native/ReactAndroid/build.gradle.kts +++ b/packages/react-native/ReactAndroid/build.gradle.kts @@ -45,7 +45,7 @@ extra["publishing_version"] = project.findProperty("VERSION_NAME")?.toString()!! // This is the version of CMake we're requesting to the Android SDK to use. // If missing it will be downloaded automatically. Only CMake versions shipped with the // Android SDK are supported (you can find them listed in the SDK Manager of Android Studio). -val cmakeVersion = System.getenv("CMAKE_VERSION") ?: "3.22.1" +val cmakeVersion = System.getenv("CMAKE_VERSION") ?: "3.30.5" extra["cmake_version"] = cmakeVersion diff --git a/packages/react-native/ReactAndroid/hermes-engine/build.gradle.kts b/packages/react-native/ReactAndroid/hermes-engine/build.gradle.kts index 9fa746dff89..377afdb2edd 100644 --- a/packages/react-native/ReactAndroid/hermes-engine/build.gradle.kts +++ b/packages/react-native/ReactAndroid/hermes-engine/build.gradle.kts @@ -136,19 +136,22 @@ val configureBuildForHermes by workingDir(hermesDir) inputs.dir(hermesDir) outputs.files(hermesBuildOutputFileTree) - commandLine( + var cmakeCommandLine = windowsAwareCommandLine( cmakeBinaryPath, // Suppress all warnings as this is the Hermes build and we can't fix them. "--log-level=ERROR", "-Wno-dev", - if (Os.isFamily(Os.FAMILY_WINDOWS)) "-GNMake Makefiles" else "", "-S", ".", "-B", hermesBuildDir.toString(), "-DJSI_DIR=" + jsiDir.absolutePath, - )) + ) + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + cmakeCommandLine = cmakeCommandLine + "-GNMake Makefiles" + } + commandLine(cmakeCommandLine) standardOutputFile.set(project.file("$buildDir/configure-hermesc.log")) } @@ -236,9 +239,9 @@ android { "-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON", "-DIMPORT_HERMESC=${File(hermesBuildDir, "ImportHermesc.cmake").toString()}", "-DJSI_DIR=${jsiDir}", - "-DHERMES_SLOW_DEBUG=False", "-DHERMES_BUILD_SHARED_JSI=True", "-DHERMES_RELEASE_VERSION=for RN ${version}", + "-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=True", // We intentionally build Hermes with Intl support only. This is to simplify // the build setup and to avoid overcomplicating the build-type matrix. "-DHERMES_ENABLE_INTL=True")