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

Foundation: repair the build for Android API level 28+ #4889

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

compnerd
Copy link
Collaborator

The newer level introduces APIs with additional nullability attribution. This causes issues as the attribution sometimes collides with expectations. Unwrap more cases to appease the nullability attributes. One problematic area of this change is the handling for Process.run(). The posix spawn APIs are described as:

typedef struct __posix_spawnattr* posix_spawnattr_t;
int posix_spawnattr_init(posix_spawnattr_t _Nonnull * _Nonnull __attr);

As the inner _Nonnull appertains to posix_spawnattr_t, it expects a non-null pointer to a non-null pointer. However, as struct __posix_spawnattr is opaque, we cannot allocate space for it and thus must be acceptable to take a pointer to null to permit the allocation.

@compnerd
Copy link
Collaborator Author

CC: @drodriguez @finagolfin @etcwilde

@compnerd
Copy link
Collaborator Author

@swift-ci please test

@finagolfin
Copy link
Contributor

I have a similar pull submitted months ago, #4850, that simply has not been reviewed, which only doesn't have your posix_spawn modifications here.

compnerd and others added 2 commits April 29, 2024 16:39
The newer level introduces APIs with additional nullability
attribution. This causes issues as the attribution sometimes collides
with expectations. Unwrap more cases to appease the nullability
attributes. One problematic area of this change is the handling for
`Process.run()`. The posix spawn APIs are described as:

```
typedef struct __posix_spawnattr* posix_spawnattr_t;
int posix_spawnattr_init(posix_spawnattr_t _Nonnull * _Nonnull __attr);
```

As the inner `_Nonnull` appertains to `posix_spawnattr_t`, it expects a
non-null pointer to a non-null pointer. However, as
`struct __posix_spawnattr` is opaque, we cannot allocate space for it
and thus must be acceptable to take a pointer to null to permit the
allocation.
@hyp
Copy link

hyp commented Apr 30, 2024

@swift-ci please test

@finagolfin
Copy link
Contributor

Oh, nice, I was just going to try building this repo natively on Android with your recent compiler pulls, will apply your Glibc-replacing changes here.

I also need to reconcile my earlier pull #4850 for the nullability annotations in NDK 26 with Saleem's first commit here, will try to get to that this week.

@usableFromInline let free = Android.free
@usableFromInline let memset = Android.memset
@usableFromInline let memcpy = Android.memcpy
@usableFromInline let memcmp = Android.memcmp
Copy link
Contributor

Choose a reason for hiding this comment

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

Trying to build with this commit now, looks like you missed an import Android 17 lines below this block.

@@ -25,6 +25,10 @@ import WinSDK
import WASILibc
#endif

#if os(Android)
Copy link
Contributor

Choose a reason for hiding this comment

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

canImport(Android)

@@ -13,6 +13,7 @@ import WinSDK
#endif

#if os(Android)
Copy link
Contributor

Choose a reason for hiding this comment

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

canImport(Android)

@@ -13,6 +13,7 @@ import WinSDK
#endif

#if os(Android)
import Android
// Android Glibc differs a little with respect to the Linux Glibc.
Copy link
Contributor

Choose a reason for hiding this comment

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

Android Glibc -> Android Bionic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants