Skip to content

Commit 4971a4b

Browse files
authored
fix(hermes): Resolve Hermes commits from main (#2794)
Resolves #2789 ## Summary: Upstream, the Hermes repo changed their default branch from `main` (Legacy Hermes) to `static_h` (HermesV1). Our scripts to look up and build Hermes from source (used on our `main` branch) started pulling in HermesV1 instead of legacy hermes, which we won't support till RN 0.84. Let's fix the lookup logic so always look up the commit from Hermes' `main` branch instead. Let's also update cmake to a version that supports visionOS ## Test Plan: Revert my commit to use JSC on CI so we can see if Hermes passes.
1 parent d1ca0af commit 4971a4b

File tree

5 files changed

+411
-86
lines changed

5 files changed

+411
-86
lines changed

.github/actions/microsoft-setup-toolchain/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ runs:
2525
- name: Install cmake
2626
uses: jwlawson/actions-setup-cmake@v2
2727
with:
28-
cmake-version: '3.26.4'
28+
cmake-version: '3.31.9'
2929
- name: Set up Ccache
3030
id: setup-ccache
3131
if: ${{ inputs.platform == 'ios' || inputs.platform == 'macos' || inputs.platform == 'visionos' }}

.github/workflows/microsoft-build-rntester.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,6 @@ jobs:
5555
RCT_NEW_ARCH_ENABLED: ${{ matrix.new_arch_enabled }}
5656
run: |
5757
set -eox pipefail
58-
if [[ "${{ github.ref }}" == "refs/heads/main" || "${{ github.base_ref }}" == "main" ]]; then
59-
yarn add @react-native-community/javascriptcore
60-
export USE_HERMES=0
61-
export USE_THIRD_PARTY_JSC=1
62-
fi
6358
bundle install
6459
bundle exec pod install --verbose
6560

packages/react-native/sdks/hermes-engine/hermes-utils.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,10 @@ def podspec_source_build_from_github_main()
186186
# Since react-native-macos lags slightly behind facebook/react-native, we can't always use
187187
# the latest Hermes commit because Hermes and JSI don't always guarantee backwards compatibility.
188188
# Instead, we take the commit hash of Hermes at the time of the merge base with facebook/react-native.
189-
commit = hermes_commit_at_merge_base()
190-
hermes_log("Using Hermes commit from the merge base with facebook/react-native: #{commit}")
189+
tuple = hermes_commit_at_merge_base()
190+
commit = tuple[:commit]
191+
timestamp = tuple[:timestamp]
192+
hermes_log("Using Hermes commit from the merge base with facebook/react-native: #{commit} and timestamp: #{timestamp}")
191193
return {:git => HERMES_GITHUB_URL, :commit => commit}
192194
# macOS]
193195
end
@@ -239,21 +241,19 @@ def hermes_commit_at_merge_base()
239241
commit = nil
240242
Dir.mktmpdir do |tmpdir|
241243
hermes_git_dir = File.join(tmpdir, "hermes.git")
242-
# Unfortunately we can't use git rev-list on HERMES_GITHUB_URL directly since we're not in that repo.
243-
# Instead, we create a shallow clone to avoid downloading the entire history.
244-
`git clone -q --bare --shallow-since="#{timestamp}" #{HERMES_GITHUB_URL} "#{hermes_git_dir}"`
245-
`git --git-dir="#{hermes_git_dir}" fetch -q --deepen=1`
244+
# Explicitly use Hermes 'main' branch since the default branch changed to 'static_h' (Hermes V1)
245+
`git clone -q --bare --filter=blob:none --single-branch --branch main #{HERMES_GITHUB_URL} "#{hermes_git_dir}"`
246246

247-
# If all goes well, this will be the commit hash of Hermes at the time of the merge base
248-
commit = `git --git-dir="#{hermes_git_dir}" rev-list -1 --before="#{timestamp}" HEAD`.strip
247+
# If all goes well, this will be the commit hash of Hermes at the time of the merge base on branch 'main'
248+
commit = `git --git-dir="#{hermes_git_dir}" rev-list -1 --before="#{timestamp}" refs/heads/main`.strip
249249
if commit.empty?
250250
abort <<-EOS
251-
[Hermes] Unable to find the Hermes commit hash at time #{timestamp}.
251+
[Hermes] Unable to find the Hermes commit hash at time #{timestamp} on branch 'main'.
252252
EOS
253253
end
254254
end
255255

256-
return commit
256+
return { :commit => commit, :timestamp => timestamp}
257257
end
258258
# macOS]
259259

0 commit comments

Comments
 (0)