Avoid renameat2 on Android#2627
Conversation
|
@finagolfin could you verify this fixes your build? |
|
I'll apply it locally and let you know in a little bit, thanks. |
|
This isn't building either, some issues with optionals, will try modifying this patch and let you know within an hour. |
Suspect you'll need this commit too: 600a210 |
|
Another problem is that Bionic doesn't have I think this pull works to fix the |
We can workaround
Great, thanks for looking! |
|
I don't see other issues related to I will work through the remaining compilation issues related to optionals, because the latest Android NDK added nullability annotations all over Bionic that your pull will have to be slightly modified for, and submit another pull for that later. |
Great, will do!
Do you have any timeline on this? We'd like to tag a release and would rather not break you! |
| from: createdPath, | ||
| to: desiredPath, | ||
| options: materialization.exclusive ? [.exclusive] : [] | ||
| ) |
There was a problem hiding this comment.
Turns out this doesn't compile on Android, because rename(from:to:options:) is only defined on Darwin.
There was a problem hiding this comment.
Oops, yes, this variant is Darwin only as it has the .exclusive flag. I think we can avoid this by not supporting "atomic" file creation on Android when exclusive create is set (when it isn't set we can do a normal rename without the exclusive flag).
Most likely later today.
I mostly build trunk right now, so shouldn't be an issue. |
|
Applied this locally and all the remaining errors appear to be type and optional mismatches related to slightly different Android declarations, so you can go ahead and merge this when you like. |
Lukasa
left a comment
There was a problem hiding this comment.
I just want to sync up here a bit: musl also lacks renameat2 as a libc function, but it does have it as a system call. I'm thinking that we'll want to omit the call through libc and instead make the system call directly. @finagolfin do we think that's gonna cause any problems on android?
|
No, I think that should work, as I don't think that syscall is filtered out on Android. |
|
See #2628 |
|
Tried that Musl syscall pull out, seems to work well after adding my patch for the type/optional mismatches and the |
|
I will look into the |
Motivation:
Until very recently Android didn't support the
renameat2syscall, this means that on most systems NIO will fail to compile.renameat2is used to delay the materialization of files on Linux. On Darwin a different code path is used which we can make use of on Android too.Modifications:
Result:
NIO builds on Android