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

Fix openNoInt building error after android ndk r21 #1593

Closed
wants to merge 1 commit into from

Conversation

Kudo
Copy link
Contributor

@Kudo Kudo commented May 30, 2021

Android NDK bionic with FORTIFY will override original open() definition and making folly wrapNoInt template failed to deduct.
The issue may happen only after NDK r21 because this commit landed after r21

References:
android/ndk#1328
llvm/llvm-project@0a0e411

@Ashoat
Copy link

Ashoat commented May 30, 2021

Thanks for this PR @Kudo! Our team has a React Native app with some C++ code mixed in, and we use the Folly library. We've had to patch around this issue for a while, so will be great to have a long-term fix. It's something that a lot of other people seem to be experiencing too!

Excited to see a Folly release with this and #1584 merged, so we can get rid of our custom patches.

@gengjiawen
Copy link
Contributor

@yfeldblum Can you review this ? Thanks.

// The solution is referenced from
// https://github.com/llvm/llvm-project/commit/0a0e411204a2baa520fd73a8d69b664f98b428ba
//
auto Open = [&]() { return open(name, flags, mode); };
Copy link
Contributor

@yfeldblum yfeldblum Jun 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's write this as:

auto openWrap = +[](const char* name_, int flags_, mode_t mode_) {
  return open(name_, flags_, mode_);
}
auto openFunc = kIsAndroid ? openWrap : open;
return int(wrapNoInt(openFunc, name, flags, mode));

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be simpler to just use the lambda in all cases, and don't bother checking kIsAndroid. The use of the lambda doesn't appear to affect the code generated by either gcc or clang in optimized builds.

I think we can just say

auto openWrapper = [&] { return open(name, flags, mode); };
return int(wrapNoInt(openWrapper));

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the review.
should i revise changes in this pr, as imported to facebook internal phabricator already?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to revise.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the import blocked due to some reason ? I see it has been blocked for two days.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is merged internally. The syncing from the internal repo to github is not working at the moment, but once it is working again this change will be merged on github as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When this synced to github. Can you draft a new release for this ? react-native has been stuck for a while.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@simpkins Looks the import is stuck.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@simpkins ping

@facebook-github-bot
Copy link
Contributor

@simpkins has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

facebook-github-bot pushed a commit to facebook/react-native that referenced this pull request Jun 17, 2021
Summary:
This PR bumps NDK_VERSION to 21.4.7075529, and patches FileUtil.cpp from folly based on patch from facebook/folly#1593. We can remove the patch once PR lands in Folly and bump Folly version in RN.

FYI, NDK 20 is deprecated and 21 is LTS release.

## Changelog

[Android] [Changed] - Bump NDK to 21.4.7075529

Pull Request resolved: #31731

Reviewed By: mdvacca

Differential Revision: D29166690

Pulled By: ShikaSD

fbshipit-source-id: 0792691404f718aaf5af1369f66f0cba046b4e20
@facebook-github-bot
Copy link
Contributor

@simpkins merged this pull request in 7312385.

facebook-github-bot pushed a commit to facebook/react-native that referenced this pull request Jul 6, 2021
Summary:
Upgrade folly for the facebook/folly#1593 fix for NDK 21 failure

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[Android] [Changed] - Upgrade folly to 2021.06.28.00

Pull Request resolved: #31802

Test Plan:
`./gradlew :ReactAndroid:installArchives`
`./gradlew packages:rn-tester:android:app:installJscRelease`
`./gradlew packages:rn-tester:android:app:installHermesRelease`

Reviewed By: RSNara

Differential Revision: D29547027

Pulled By: ShikaSD

fbshipit-source-id: a10c7c65f459091bd0e7cca750a9b9e067189b73
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants