-
Notifications
You must be signed in to change notification settings - Fork 15
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
Add support for using conditionally available NDK APIs #27
Open
cpsauer
wants to merge
2
commits into
bazelbuild:main
Choose a base branch
from
cpsauer:conditional-availability
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is this the default? If you care, this differs from the NDK's build systems. We have no plans to ever make this the default in the NDK
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.
Hey, Dan! Thanks again for engaging over 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.
Yep! Was proposing we enable by default in this toolchain because (from the Build System Maintainers Guide) it seemed sufficiently valuable, safe, and reverse-compatible that you all had concluded that "most developers will likely prefer weak APIs" (i.e. this).
But you're certainly the expert. Could I ask to compare notes? Are there unsafe edges I've missed that should make it off by default? Perhaps more of the problems from earlier on in the issue remain than are listed in the guide?
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.
Some finer points for comparing notes, separated into an appendix to save round trips, while keeping the above skimmable for others with less context :)
-Werror=unguarded-availability
and not a runtime error on older devices.It seems like the docs conclude it's unsafe without that flag, but good and safe with.
Hence y'all's decision to keep it off by default in the headers, leaving enabling weak symbols to the build system, which can ensure use of that flag?
I'm trying to understand whether the reluctance elsewhere has to do with strict compatibility inertia and caution around a full, official Android release (which wouldn't apply so much on this new, experimental toolchain that breaks from the previous in a number of ways), or whether there are other problems you know about that make this unsafe to use.
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.
If there's a really compelling reason to enable this by default, I'm open to that, but overall my intuition is to match what the NDK does.
Yes if we decide to move forward, it would be good to add a test. Basically add another example like https://github.com/bazelbuild/rules_android_ndk/tree/main/examples/basic and update https://github.com/bazelbuild/rules_android_ndk/blob/main/.bazelci/presubmit.yml to build it
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 short answer is that we don't know yet. This is not supported in any released NDK, which alone seems like a reason to not enable this by default. Maybe this is a sensible default for bazel in the future, but I think it'd be wise to wait until the feature has had some time in the wild so we can be sure there aren't any surprises lurking before making that change.
Whether or not this is useful is going to depend a lot on the exact use case. Some apps won't need it at all, and some apps won't be able to use it because it has limitations. We don't expect it to cause issues for either of those groups, but there's also no benefit. If it turns out that there are no downsides to enabling this it's probably a good default, but we don't really know yet.
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.
+1
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.
Makes sense! Thanks for being great @DanAlbert.
So, proposing a plan: I'll change it to off by default momentarily, we'll land the optional bazel feature so people can try it safely upon release, and then we'll revisit the default status when we've got more usage data?
Dan, could I ask you to ping us back somehow as you learn more about how it's working in the wild, maybe just on that other issue thread, since I presume that's where people are mostly following?
[And if useful as a communications backtrace: I think the miscommunication here was my mistaking the soft launch for an upcoming, higher-conviction hard launch.]
Cheers,
Chris
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.
Looks good to make it optional -- could you add a test to ensure this continues to work?
you could add another example that makes use of one of the conditionally available APIs based on the basic example:
https://github.com/bazelbuild/rules_android_ndk/tree/main/examples/basic and update https://github.com/bazelbuild/rules_android_ndk/blob/main/.bazelci/presubmit.yml to build it
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.
Always optional! But now off by default for the soft-launch.
Re tests: Happy to in spirit, but for them to pass, I think we'll have to wait until r26 is released and used for these tests, right? We could block on that, but this seems handy early for folks playing around with the feature pre-released and on launch. So I'd propose merge now and add tests on r26 launch, esp since it's now disabled by default and a soft-launch?