Skip to content

Add canImport(Android) alongside Bionic in remaining libc import sites#3584

Open
networkextension wants to merge 1 commit intoapple:mainfrom
networkextension:android-bionic-shim-patch
Open

Add canImport(Android) alongside Bionic in remaining libc import sites#3584
networkextension wants to merge 1 commit intoapple:mainfrom
networkextension:android-bionic-shim-patch

Conversation

@networkextension
Copy link
Copy Markdown

@networkextension networkextension commented May 1, 2026

Swift 6.3 Android SDK (finagolfin/swift-android-sdk) ships the libc shim as the Android module only; the Bionic module was removed. Files that had only #elseif canImport(Bionic) in their top-level #if chain hit #error("… unable to identify your C library.").

Add #elseif canImport(Android) before each #elseif canImport(Bionic) in the 20 remaining top-level import sites, and add || canImport(Android) to the 44 inline canImport(Glibc) || canImport(Musl) || canImport(Bionic) boolean guards. Both branches are kept so older SDKs that still ship Bionic continue to work.

FileDescriptor+Syscalls.swift and Syscall.swift Android branches also import CNIOLinux because those files use CNIOLinux_O_TMPFILE, CNIOLinux_RENAME_NOREPLACE, etc. inside the newly-gated blocks.

https://claude.ai/code/session_01Gmec6R8WK6XsSSwecZ9AAm

Support Android Bionic

Motivation:

Porting Swift-NIO project to Android Bionic

Modifications:

-#if canImport(Glibc) || canImport(Musl) || canImport(Bionic)
+#if canImport(Glibc) || canImport(Musl) || canImport(Android) || canImport(Bionic)

Result:

Swift-NIO project porting to Android Bionic success

@finagolfin

Swift 6.3 Android SDK (finagolfin/swift-android-sdk) ships the libc
shim as the `Android` module only; the `Bionic` module was removed.
Files that had only `#elseif canImport(Bionic)` in their top-level
`#if` chain hit `#error("… unable to identify your C library.")`.

Add `#elseif canImport(Android)` before each `#elseif canImport(Bionic)`
in the 20 remaining top-level import sites, and add `|| canImport(Android)`
to the 44 inline `canImport(Glibc) || canImport(Musl) || canImport(Bionic)`
boolean guards. Both branches are kept so older SDKs that still ship
Bionic continue to work.

FileDescriptor+Syscalls.swift and Syscall.swift Android branches also
import CNIOLinux because those files use CNIOLinux_O_TMPFILE,
CNIOLinux_RENAME_NOREPLACE, etc. inside the newly-gated blocks.

https://claude.ai/code/session_01Gmec6R8WK6XsSSwecZ9AAm
@finagolfin
Copy link
Copy Markdown
Contributor

You sure about this? Builds fine on my CI, including passing most tests.

@finagolfin
Copy link
Copy Markdown
Contributor

@Lukasa, I suspect this is AI slop...

@networkextension
Copy link
Copy Markdown
Author

I'm porting iOS/Mac app which use Swift-NIO, you can view my github profile.

@finagolfin
Copy link
Copy Markdown
Contributor

OK, whatever AI, which you yourself admit to using in your profile, you employ doesn't work, as my linked Android CI runs show.

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.

3 participants