-
Notifications
You must be signed in to change notification settings - Fork 648
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
arm64 simulators & catalyst support #475
Conversation
Hi @Arkkeeper! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
@Arkkeeper Thanks for contributing! While cc-ing @grabbou to review this, I noticed that The |
hermes-engine.podspec
Outdated
@@ -20,13 +20,13 @@ Pod::Spec.new do |spec| | |||
# The podspec would be serialized to JSON and people will download prebuilt binaries instead of the source. | |||
# TODO(use the hash field as a validation mechanism when the process is stable) | |||
spec.source = ENV['hermes-artifact-url'] ? { http: ENV['hermes-artifact-url'] } : { git: "https://github.com/facebook/hermes.git", tag: "v#{spec.version}" } | |||
spec.platforms = { :osx => "10.13", :ios => "10.0" } | |||
spec.platforms = { :osx => "11.0", :ios => "10.0" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe because of this version bump?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reverted that bump, I don't think that it's essential for Catalyst support.
Now CircleCI fails on Android tests, but my commits have nothing to do with the android part of code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah do not worry about the Android tests. The android emulator image is somehow missing.
Friendly ping @grabbou For context why this is extremely important: RN 0.64 now ships with iOS Hermes support, but lack of support for iOS Simulator arm64 arch makes it impossible to work with it. Additionally, RN apps using turbo modules can only be debugged with Flipper's Hermes Debugger. |
@Arkkeeper is there any easy way to use this PR before it's merged? |
You have to patch react-native/scripts/react_native_pods.rb. First, add a variable to check whether it's ARM Mac, like: Then modify definition of hermes-engine and refer to repo with my PR: if is_arm == 1 then Make sure that you have cmake and ninja installed with homebrew. Then run yarn and prepare to wait about 15-20 minutes. Building hermes-engine from sources for several archs is rather tedious. |
Thank you. Some notes regarding your instructions, in case it helps others: Ran into Also, detecting arm64 didn't work in my case because I can only run cocoapods using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, I didn’t know somebody had already done this work! Most importantly we should make sure it still works for macOS too.
local catalyst="false" | ||
local platform=$1 | ||
|
||
if [[ $1 == iphoneos || $1 == catalyst ]]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps also replace further use of $1
with the $platform
alias here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would actually not use $platform
here. Further explanation on line 62.
utils/build-apple-framework.sh
Outdated
@@ -56,11 +59,16 @@ function configure_apple_framework { | |||
else | |||
build_cli_tools="false" | |||
fi | |||
if [[ $1 == catalyst ]]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
utils/build-apple-framework.sh
Outdated
for platform in "${@:2}"; do | ||
rm -r "$platform" | ||
done | ||
xcodebuild -create-xcframework -framework iphoneos/hermes.framework -framework iphonesimulator/hermes.framework -framework macosx/hermes.framework -output iphoneos/hermes.xcframework |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The output should not assume the framework is just for iOS here, it should theoretically also be able to contain the macOS slices, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Also, it should also get the platforms from the platforms
, like the lipo
did, without hardcoding them. I just think it's nicer and doesn't require manual rm
of every folder, like it's currently done on line 112-114.
|
||
for i in "${!platforms[@]}"; do | ||
platforms[$i]="${platforms[$i]}/hermes.framework/hermes" | ||
done |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
Thanks for the PR! I left some comments to further optimise the scripts and the way we handle Catalyst, but I'd consider them minor tweaks, since overall, everything seems to be fine. |
Thank you for your suggestions! I've pushed some optimizations for the build scripts. I hope that my PR won't delay Hermes 0.8.1 and RN 0.65. |
Building third time in row, over 1 hour each time. not cool :( |
@Arkkeeper Any timeline on how soon it can get merged? |
cc @grabbou remember to check this one ;) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for addressing my previous comments. The PR looks really good! Rather than two tiny issues, it is good to go.
I will give it a shot and test it tomorrow, and if everything runs smoothly, I will merge it, reverting the deleted lines on top of your PR.
# Once all was linked into a single framework, clean destroot | ||
# from unused frameworks | ||
for platform in "${@:2}"; do | ||
rm -r "$platform" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any particular reason why this has been removed? This should be reverted. We need to clean up destroot
to only contain the artifacts that are used in production.
This is because CircleCI will package the entire destroot
folder into a tarball that is distributed along the npm
package. If we don't clean it up, we are going to ship one xcframework
and every platform separately as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I've reverted that removal
done | ||
|
||
lipo -info "${platforms[0]}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any particular reason why this has been removed? I think this is a good add-on for debugging purposes on the CI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because lipo -info fails on xcframework with a fatal error:
can't map input file: iphoneos (Invalid argument)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
Code wise, it looks good. However, I just noticed that
|
@Huxpro has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Summary: Edits build scripts to allow merging architectures into .xcframework instead of using lipo for building fat framework. Adds compatibility with arm64 iOS Simulators on Apple M1 Macs and allows using Hermes with RN apps built for Mac Catalyst. Fixes facebook#460 and facebook#468 Pull Request resolved: facebook#475 Differential Revision: D29465045 Pulled By: Huxpro fbshipit-source-id: 6291aac9ee47db83d6f78822767019ec0277a899
I believe we should be closing this one in favor of #546. Thanks for the work so far! |
Summary
Edits build scripts to allow merging architectures into .xcframework instead of using lipo for building fat framework.
Adds compatibility with arm64 iOS Simulators on Apple M1 Macs and allows using Hermes with RN apps built for Mac Catalyst.
Fixes #460 and #468