Skip to content

Fix Hermes configuration after the source directory changes - #59514

Open
shamilovtim wants to merge 1 commit into
react:mainfrom
shamilovtim:codex/fix-hermes-cmake-cache-relocation
Open

shamilovtim wants to merge 1 commit into
react:mainfrom
shamilovtim:codex/fix-hermes-cmake-cache-relocation

Conversation

@shamilovtim

@shamilovtim shamilovtim commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Author's note

Hello maintainers, I have to run this patch on react-native@0.88.0, otherwise Android source builds won't compile. Please consider a patch release addressing this issue so other users can benefit.

Summary

Fixes #59513

Building Hermes from source fails when its CMake build directory contains a cache from a previous source location. CMake rejects the old path before compilation starts.

Clear CMakeCache.txt and CMakeFiles before either Hermes configure task executes. Gradle still skips the task when nothing changes. Use file cleanup so the CMAKE_VERSION=3.22.1 override continues to work. That CMake version does not support --fresh.

The reported failure came from a pnpm 12.3.4 monorepo with ccache 4.14.2 enabled for native compilation. The source-only reproducer runs in an upstream checkout.

Changelog

[ANDROID] [FIXED] - Fix Hermes source builds failing after the source directory changes.

Test plan

  • Ran the source relocation reproducer. The original code fails on the second configure call. The fix passes all calls, and the unchanged call reports UP-TO-DATE.
  • Ran ./gradlew -p packages/gradle-plugin build -PenableWarningsAsErrors=true. All 285 tests passed. Set JAVA_TOOL_OPTIONS=-Djava.io.tmpdir=/private/tmp/react-native-hermes-gradle-tests to avoid an existing macOS /var versus /private/var path assertion failure.
  • Ran yarn format-check-kotlin and git diff --check.
  • Ran configureBuildForHermes and configureBuildForHermesWithDebugger with CMAKE_VERSION=3.22.1 and CMAKE_VERSION=3.30.5. Both variants passed, and repeated calls stayed UP-TO-DATE.
  • Ran :packages:react-native:ReactAndroid:hermes-engine:buildHermesC and compiled a JavaScript file to bytecode with the resulting compiler.
  • Ran :packages:react-native:ReactAndroid:hermes-engine:assembleRelease for arm64. The release AAR built successfully. Repeated host configuration and compiler tasks stayed UP-TO-DATE.
  • Changed a CMake input comment and reran buildHermesC. All 239 existing Hermes object files kept their modification times.
  • Verified the cleanup task action can store and reuse Gradle's configuration cache in an isolated task fixture.

Native commands used -Preact.internal.useHermesNightly=false -PreactNativeArchitectures=arm64-v8a. Validation ran on macOS arm64 with JDK 17.0.20. Windows and Linux builds were not run.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 26, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Oct 26, 2026
@cipolleschi

Copy link
Copy Markdown
Contributor

Thanks for submitting the fix. But can I ask why do you compile hermes from source instead of consuming the precompiled binary we ship?

@meta-codesync

meta-codesync Bot commented Oct 27, 2026

Copy link
Copy Markdown

@cipolleschi has imported this pull request. If you are a Meta employee, you can view this in D127786953.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android source builds fail after the Hermes source directory changes

2 participants