-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
[META] Upgrading Folly #20302
Comments
Ideally, we'd want to pull the latest folly directly from https://github.com/facebook/folly - or at least use the latest version for each RN release - automatically. This will involve updating/changing the integration with CocoaPods + gradle that react-native repo has today, e.g. making them run the build scripts already provided by folly repo, instead of making their own wrapper scripts / build steps. |
I would like to volunteer to upgrade Folly in Android, and I think this experience will help me better learn C++. Also it might be better to prepare RN for Clang and libc++ support, as it'll be the only compiler and STL in next NDK release. I tried to build RN with Clang and got many warnings, errors in Folly. So I think that it might be better to upgrade C++ or native tools beforehand, maybe merge #20357 which would land latest Android NDK version. |
maybe it's better to switch to CMake to build jni code on Android, because boost, glob and folly supports it, but also many C++ libraries. |
@dulmandakh Good idea. And with it we can also have better IDE support. |
I have tried building with cmake for the convenience of testing I put all the libraries in ReactAndroid/third-party-ndk problem:
|
@yinhangfeng could you please try to build master with CMake as is, or without bumping libraries. Once finished it will be easy to bump libraries to latest versions. Thank you. |
I am going to upgrade folly and build the code with clang. It seems that the community maintained android-jsc builder could build JSC with clang. |
I think that it might be better to start with clang then upgrade folly,
because clang is default toolchain for XCode so we'll have identical
toolchains for Folly upgrade.
But it's your choice, good luck 👍
|
I've tried before and the old folly does not support NDK with clang build. |
Just create #21863 to show my changes in case if someone has interests. |
Summary: According to this android/ndk#647, posix_memalign may not exist on Android API 16. From Android NDK r17c, the API exists for Android API 17+. ``` #if __ANDROID_API__ >= 17 int posix_memalign(void** __memptr, size_t __alignment, size_t __size) __INTRODUCED_IN(17); #endif /* __ANDROID_API__ >= 17 */ ``` Change the code to use posix_memalign only after Android API 17+. This would also fix issue for OSS React Native to pack latest folly and building with clang. See: facebook/react-native#20302 and facebook/react-native#20342 Pull Request resolved: #953 Reviewed By: yfeldblum Differential Revision: D10469757 Pulled By: Orvid fbshipit-source-id: c63838f3f6e723ef3de77187f39597a4063043db
Summary: Fixes #20302 (For iOS) Note: ------ 1. Checked the changes did not break CocoaPods integration. 2. The change for glog copying header into exported/ is to prevent build break for folly. `folly/detail/Demangle.h` will try to use libstdc++'s demangle.h. Unfortunately, glog also has a demangle.h in source code. So I copy exported headers and only search headers in exported/ folder during build. Pull Request resolved: #21976 Reviewed By: hramos Differential Revision: D12818131 Pulled By: fkgozali fbshipit-source-id: b3c637d09d1b3adde0ea15c82eb56e28f846885b
I've merged both #21976 and #21977 - this should get us moving for the time being. However, I'd like to see if we can come up with a more scalable/automated way of upgrading Folly. For instance, right now we list out relevant files manually like so: https://github.com/facebook/react-native/pull/21977/files#diff-ae2383f344153a01ce1b6130b453a8e1R5 This list usually changes release by release (not always, tho). I think to make it more maintainable (e.g. if we decide to upgrade it again 1 year from now), it would be great if somehow we can use whatever configuration folly repo already has. Perhaps there's no specific cmake/config for mobile builds atm, but maybe that's one way to approach this:
This will make upgrades much easier in the future. Thoughts? |
Btw @Kudo, thank you for the PRs! They should unblock us for making Fabric C++ code compilable with gradle/cocoapods/xcode. |
@fkgozali Thank you for the review and landing. Just for your information, in the Android PR, I wrote a folly patch in gradle to support gcc 4.9. I am working on #21863 and hopefully we could use clang build soon. |
Summary: According to this android/ndk#647, posix_memalign may not exist on Android API 16. From Android NDK r17c, the API exists for Android API 17+. ``` #if __ANDROID_API__ >= 17 int posix_memalign(void** __memptr, size_t __alignment, size_t __size) __INTRODUCED_IN(17); #endif /* __ANDROID_API__ >= 17 */ ``` Change the code to use posix_memalign only after Android API 17+. This would also fix issue for OSS React Native to pack latest folly and building with clang. See: facebook/react-native#20302 and facebook/react-native#20342 Pull Request resolved: facebook#953 Reviewed By: yfeldblum Differential Revision: D10469757 Pulled By: Orvid fbshipit-source-id: c63838f3f6e723ef3de77187f39597a4063043db
Just wanted to ask what is the status of this issue? Are we still looking for somebody to figure out a way to make folly upgrades easier in the future or are we alright with the current state of things? |
@cpojer I think you can close it for now. Folly has been upgraded. Upgrade easier or migrate to CMake is another issue. |
Summary: Fixes facebook#20302 (For Android) Note: ------ 1. New folly will have build break for a gcc-4.9 and gcc-4.9 seems to be deprecated for latest folly. As we only use partial folly implementations, I just fixed the build break part. To support building RN on Windows, the patches are written by gradle ReplaceTokens. 2. The change for glog copying header into exported/ is to prevent build break for folly. `folly/detail/Demangle.h` will try to use libstdc++'s demangle.h. Unfortunately, glog also has a demangle.h in source code. So I copy exported headers and only search headers in exported/ folder during build. Pull Request resolved: facebook#21977 Reviewed By: hramos Differential Revision: D12818133 Pulled By: fkgozali fbshipit-source-id: 2c1f6f012663204581a86141d0c9ed0eb9d8c698
Summary: Fixes facebook#20302 (For iOS) Note: ------ 1. Checked the changes did not break CocoaPods integration. 2. The change for glog copying header into exported/ is to prevent build break for folly. `folly/detail/Demangle.h` will try to use libstdc++'s demangle.h. Unfortunately, glog also has a demangle.h in source code. So I copy exported headers and only search headers in exported/ folder during build. Pull Request resolved: facebook#21976 Reviewed By: hramos Differential Revision: D12818131 Pulled By: fkgozali fbshipit-source-id: b3c637d09d1b3adde0ea15c82eb56e28f846885b
Summary: Fixes facebook#20302 (For Android) Note: ------ 1. New folly will have build break for a gcc-4.9 and gcc-4.9 seems to be deprecated for latest folly. As we only use partial folly implementations, I just fixed the build break part. To support building RN on Windows, the patches are written by gradle ReplaceTokens. 2. The change for glog copying header into exported/ is to prevent build break for folly. `folly/detail/Demangle.h` will try to use libstdc++'s demangle.h. Unfortunately, glog also has a demangle.h in source code. So I copy exported headers and only search headers in exported/ folder during build. Pull Request resolved: facebook#21977 Reviewed By: hramos Differential Revision: D12818133 Pulled By: fkgozali fbshipit-source-id: 2c1f6f012663204581a86141d0c9ed0eb9d8c698
For Discussion
The Folly version used in open source is very old. We're looking for volunteers interested in making the necessary changes to upgrade Folly in React Native.
Known Incompatibilities
This is in no way an exhaustive list, but be aware you'll need to tackle the following when upgrading Folly:
No template named 'Optional' in namespace 'folly'
stuffThe text was updated successfully, but these errors were encountered: