Skip to content

Commit f88ba76

Browse files
cortinicofacebook-github-bot
authored andcommitted
Enable INTERPROCEDURAL_OPTIMIZATION for React Native (#50529)
Summary: This enables INTERPROCEDURAL_OPTIMIZATION for the CMake build of React Native. Changelog: [Android] [Changed] - Enable INTERPROCEDURAL_OPTIMIZATION for React Native Reviewed By: NickGerleman Differential Revision: D72574119
1 parent ea2fbd4 commit f88ba76

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

.github/actions/build-android/action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ runs:
1919
uses: ./.github/actions/setup-node
2020
- name: Install node dependencies
2121
uses: ./.github/actions/yarn-install
22+
- name: Install llvm-linker-tools
23+
run: sudo apt update && sudo apt install -y llvm-linker-tools
24+
shell: bash
2225
- name: Set React Native Version
2326
shell: bash
2427
run: node ./scripts/releases/set-rn-artifacts-version.js --build-type ${{ inputs.release-type }}

packages/react-native/ReactAndroid/hermes-engine/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ android {
230230
arguments(
231231
"--log-level=ERROR",
232232
"-Wno-dev",
233+
"-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=True",
233234
"-DHERMES_IS_ANDROID=True",
234235
"-DANDROID_STL=c++_shared",
235236
"-DANDROID_PIE=True",

packages/react-native/ReactAndroid/src/main/jni/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ set(CMAKE_VERBOSE_MAKEFILE on)
88

99
project(ReactAndroid)
1010

11+
include(CheckIPOSupported)
12+
check_ipo_supported(RESULT IPO_SUPPORT)
13+
if (IPO_SUPPORT)
14+
message(STATUS "LTO support is enabled")
15+
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
16+
endif()
17+
1118
include(${REACT_COMMON_DIR}/cmake-utils/react-native-flags.cmake)
1219

1320
# Convert input paths to CMake format (with forward slashes)

0 commit comments

Comments
 (0)