Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not build JSI in React-jsi when Hermes is enabled, resolve JSI ODR violation #35038

Closed
wants to merge 4 commits into from

Conversation

hramos
Copy link
Contributor

@hramos hramos commented Oct 20, 2022

Summary:
React-jsi provides JSI to allow React Native to interface with JavaScriptCore.
The hermes-engine Pod provides a second copy of JSI, as Hermes is built and linked statically with JSI.
This second copy of JSI would lead to an ODR Violation.

To resolve this, when Hermes is enabled:

  • React-hermes and hermes-engine are installed.
  • React-jsc is not installed.
  • React-jsi continues to be installed.
  • React-jsi will not build JSI.
  • React-jsi will declare a dependency on hermes-engine.

The result is that the JSI dependency for React Native is satisfied by hermes-engine, and there is no duplicate JSI library in the project.

When Hermes is disabled:

  • React-jsi and React-jsc are installed.
  • React-hermes and hermes-engine are not installed.
  • React-jsi will build JSI.

Changelog:
[iOS][Changed] Resolve JSI ODR violation, make hermes-engine the JSI provider when Hermes is enabled

Reviewed By: cipolleschi

Differential Revision: D40334913

hramos and others added 4 commits October 20, 2022 06:55
Differential Revision: D40442603

fbshipit-source-id: 1690377f76bc7227a1e77e542059e6efac259b47
Summary:
The React-Hermes and hermes-engine headers are only needed when Hermes is enabled.

Changelog: [internal]

Differential Revision: D40451162

fbshipit-source-id: bdebd418aeb36254fbaabfa460dacf86e7cb1f3a
Summary:
Move JSC and Hermes CocoaPods configuration to scripts/cocoapods/jsengine.rb. This file provides a setup_jsc function and a setup_hermes function.

Changelog: [internal]

Differential Revision: D40459234

fbshipit-source-id: bd76472ef604ec6b930d7e353eba61f7a962103d
… violation

Summary:
React-jsi provides JSI to allow React Native to interface with JavaScriptCore.
The hermes-engine Pod provides a second copy of JSI, as Hermes is built and linked statically with JSI.
This second copy of JSI would lead to an [ODR Violation](https://en.cppreference.com/w/cpp/language/definition).

To resolve this, when Hermes is enabled:
- React-hermes and hermes-engine are installed.
- React-jsc is not installed.
- React-jsi continues to be installed.
- React-jsi will not build JSI.
- React-jsi will declare a dependency on hermes-engine.

The result is that the JSI dependency for React Native is satisfied by hermes-engine, and there is no duplicate JSI library in the project.

When Hermes is disabled:
- React-jsi and React-jsc are installed.
- React-hermes and hermes-engine are not installed.
- React-jsi will build JSI.

Changelog:
[iOS][Changed] Resolve JSI ODR violation, make hermes-engine the JSI provider when Hermes is enabled

Reviewed By: cipolleschi

Differential Revision: D40334913

fbshipit-source-id: c108f258dfe9eefb5b755bc38dc63eea9f3a02b3
@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Facebook Partner: Facebook Partner fb-exported labels Oct 20, 2022
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D40334913

@analysis-bot
Copy link

Platform Engine Arch Size (bytes) Diff
ios - universal n/a --

Base commit: be6f656
Branch: main

@analysis-bot
Copy link

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 7,754,795 +0
android hermes armeabi-v7a 7,159,067 +0
android hermes x86 8,066,601 +0
android hermes x86_64 8,037,253 +0
android jsc arm64-v8a 9,612,937 +0
android jsc armeabi-v7a 8,379,072 +0
android jsc x86 9,559,947 +0
android jsc x86_64 10,152,843 +0

Base commit: be6f656
Branch: main

@pull-bot
Copy link

PR build artifact for a5f3728 is ready.
To use, download tarball from "Artifacts" tab in this CircleCI job then run yarn add <path to tarball> in your React Native project.

@pull-bot
Copy link

PR build artifact for a5f3728 is ready.
To use, download tarball from "Artifacts" tab in this CircleCI job then run yarn add <path to tarball> in your React Native project.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @hramos in a68c418.

When will my fix make it into a release? | Upcoming Releases

@react-native-bot react-native-bot added the Merged This PR has been merged. label Oct 20, 2022
OlimpiaZurek pushed a commit to OlimpiaZurek/react-native that referenced this pull request May 22, 2023
… violation (facebook#35038)

Summary:
Pull Request resolved: facebook#35038

React-jsi provides JSI to allow React Native to interface with JavaScriptCore.
The hermes-engine Pod provides a second copy of JSI, as Hermes is built and linked statically with JSI.
This second copy of JSI would lead to an [ODR Violation](https://en.cppreference.com/w/cpp/language/definition).

To resolve this, when Hermes is enabled:
- React-hermes and hermes-engine are installed.
- React-jsc is not installed.
- React-jsi continues to be installed.
- React-jsi will not build JSI.
- React-jsi will declare a dependency on hermes-engine.

The result is that the JSI dependency for React Native is satisfied by hermes-engine, and there is no duplicate JSI library in the project.

When Hermes is disabled:
- React-jsi and React-jsc are installed.
- React-hermes and hermes-engine are not installed.
- React-jsi will build JSI.

Changelog:
[iOS][Changed] Resolve JSI ODR violation, make hermes-engine the JSI provider when Hermes is enabled

Reviewed By: cipolleschi

Differential Revision: D40334913

fbshipit-source-id: 409407a193a35cbd21b0e8778537b3627e4c54a2
dmytrorykun added a commit to dmytrorykun/react-native that referenced this pull request Nov 15, 2023
…1499)

Summary:

After facebook#38922 we consume JSI from `ReactCommon/jsi`, and ignore JSI that is distributed with `hermes-engine`.

This diff removes `include/jsi` from `source_files` of `hermes-engine` so we don't get two sets of JSI headers - one from `ReactCommon`, and the other one from `hermes-engine`.

This diff also fixes accidental breakage of ODR violation, which was first fixed here facebook#35038
We will no longer compile JSI into `react-native` when linking against `hermes-engine`, which already has JSI in it.

Changelog: [iOS][Fixed] - Exclude JSI headers when using hermes-engine prebuilt.

Differential Revision: D51347562
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. fb-exported Merged This PR has been merged. p: Facebook Partner: Facebook Partner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants