-
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
[ANDROID] [ENHANCEMENT] [build] - Use clang to build Android libraries #21863
Conversation
@Kudo it seems that folly is merged your PR, so that you can proceed with upgrading folly 👍 |
@dulmandakh Updated to folly 2018.10.22 that included the fix. |
Cool, did you tried to upgrade folly for iOS?
|
@dulmandakh 61f8b05 and cdc70e7 upgrade folly for iOS and checked CocoaPods not broken. Please also take a look. Thank you. |
You should continue with making android-jsc build with libc++, with the assumption that jsc-android-buildscripts will not be ready for a while. See #19536 (comment) |
@@ -19,11 +19,9 @@ APP_MK_DIR := $(dir $(lastword $(MAKEFILE_LIST))) | |||
# etc.) are defined inside build.gradle. | |||
NDK_MODULE_PATH := $(APP_MK_DIR)$(HOST_DIRSEP)$(THIRD_PARTY_NDK_DIR)$(HOST_DIRSEP)$(REACT_COMMON_DIR)$(HOST_DIRSEP)$(APP_MK_DIR)first-party$(HOST_DIRSEP)$(REACT_SRC_DIR) | |||
|
|||
APP_STL := gnustl_shared | |||
APP_STL := c++_shared |
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 think that it might be better to stick to gnustl when we still use gcc
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.
Well, the main purpose of this PR is to use clang build, so here to drop gnustl_shared and gcc.
@hey99xx I see @gengjiawen's changes from facebookarchive/android-jsc#30 and the Dockerfile at https://github.com/gengjiawen/android-ndk. Thanks for @gengjiawen's awesome work. I am trying to build JSC with clang but pretty not sure if the old JSC r174650 could build with clang or not. |
Unfortunately, JSC r174650 does not directly support clang. |
If we don't upgrade jsc, will it cause problem ? |
@gengjiawen If we use android-jsc as is, we'd need both libgnustl_shared.so and libc++_shared.so in the app as mentioned in Kudo's workaround in the PR. Not sure if that causes any problem in runtime or not (*), but certainly a pointless app size increase. So updating existing android-jsc to use libc++_shared.so is the best looking option for me. @Kudo Nothing in WebKit/WebKit@d656310 or https://bugs.webkit.org/show_bug.cgi?id=146833 tells me r174650 didn't support clang. Edit: (*) I see @dulmandakh also mentioned in #20342 (comment)
|
@Kudo thank you for your effort to land latest folly and clang migration. Just now, I fetched your branch and did some quick tests. I can build RN and RNTester app without any problems, but RNTester app is failing on startup. A while ago I managed to compile RN with clang against libc++, and RNTester app was failing to launch. I think that cause is described at #21863 (comment). Also I learned that small and specific PRs are reviewed/merged sooner than a PR that touches many things. So I would like to ask you to split this PR into smaller ones that only upgrades folly, migrates to clang and libc++, Gradle cleanup and so on. |
@hey99xx Yes, just as you understood, @dulmandakh You could check the adb log, if there are errors like libgnustl_shared.so not found, that is the problem. |
@dulmandakh Opened PRs for just upgrade folly. #21976 for iOS and #21977 for Android. |
@Kudo thank you for your hard work, folly is now up to date. |
@dulmandakh Thanks for your coordinating. |
@Kudo do you have experience with CMake? If yes, will it make Android development and build easier, faster? |
@dulmandakh
In summary, I don't see much benefits in the short term. Migrate to CMake currently is just to rewrite Android.mk with CMakeLists.txt. |
cdc70e7
to
68024f4
Compare
I've updated this PR to only for clang build support and remove previous folly changes. With some enhancements from original work:
CI build log: https://travis-ci.org/Kudo/android-jsc/builds/448793745 Migration Guide:
|
WOW this is absolutely fantastic, truly well done. I don't know if anyone will land Kudo/android-jsc@0437216 in main facebook/android-jsc repo. You're building on top of facebookarchive/android-jsc#30 but they're not taking that PR either, that's why @gengjiawen had checked in the pre-built AAR in #18754. So in this case it may make sense for you to do the same thing. The only thing is file hashes for all pre-built libjsc.so files would be changing this time, and I don't know if Facebook would trust on .so files built on someone else's computer and put them in their OSS builds. |
Also quick question: The new JSC in NPM ships with libjsc and libc++_shared ( |
personally I cannot use it because it's minSDK is 21, but I want support for Android 4.x |
@hey99xx Nice finding for your libc++_shared.so. Yes, after this PR, there should have a libc++_shared.so conflict if going to apply The new JSC in NPM . @dulmandakh |
@Kudo it's about android-jsc package on NPM, which requires to set minSdkVersion to 21. |
@dulmandakh Oops, I see and sorry for my misunderstood. |
@Kudo is it possible to have CMake configuration for Folly in RN repo, so we don't have wait for folly developers if we need change? |
Yeah, agreed. This is probably something we can ask the folly repo for? E.g. have a subset specifically for mobile? |
I think it might be better to maintain CMake configuration for Folly in RN repo if possible, because we don't have to wait for a new folly release if we need some change. Maintaining configuration in folly repo might be normal for FB RN, but sometimes it breaks open source CI due to fact that some changes might not be released to open source. FYI, case with Buck b40e23d. |
This is a fair point, and I'm okay with having RN-specific config (that can be shared across all platforms as needed - ios/anroid/others) |
Well, I could try to investigate the possibility to CMake migration for both iOS/Android later. |
@Kudo I personally prefer more incremental approach to a technical solution. I was thinking if it's possible to build current JSC with clang, then update JSC version. |
@dulmandakh Yes, my commit is current JSC r174650 build with clang. |
It seems it would be easier to have a fb employee bundle a prebuilt jsc as is done on master right now... |
#22231 |
@akshetpandey This PR plans to handle android-jsc's dependency on gnustl. See the checklist at the top:
The other PR seems to have the same goal as this, but doesn't address android-jsc's dependency on gnustl at all, I don't know if that's correct thing to do. @Kudo @gengjiawen what do you think? |
Doesn't look like the jsc PR is going to land. I am using this PR with a locally compiled android-jsc in my fork. |
Close this in favor of #22263 |
Fixes #20342 and support for future NDK r18
TODO:
- [x] Wait folly merged with this fixWait android-jsc with clang built. See [META] Upgrading Folly #20302 (comment) for details.Workaround to test without clang android-jsc: put libgnustl_shared.so directly into apk, i.e. will have both libstd++ (for JSC) and libc++ (for libreactnativejni.so) runtime.
Or maybe try to use community maintained android-jsc which is built by clang.
JSC should also built by clang. Wait for Kudo/android-jsc@0437216 landed.
- [x] Upgrade iOS folly version as wellTest Plan:
Test by RNTester
Release Notes:
[ANDROID] [ENHANCEMENT] [build] - Use clang to build Android libraries