Fix Android build: enable linux-raw-sys
and exclude Android-unsupported Linux userspace features
#1528
+16
−15
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.
Enable access to Linux kernel types on Android targets while excluding a small set of Linux userspace features that are not available on Android (XDP, io_uring, certain
STATX
constants), restoring Android builds without changing Linux behavior.Motivation / Background
Recently the crate started failing to build for Android targets with errors like:
Root cause: Android had been explicitly excluded from the
linux_raw_dep
/linux-raw-sys
path inbuild.rs
/Cargo.toml
, which prevented Android builds from getting Linux kernel constant / syscall/type definitions that are required even when using the libc backend. Bionic (Android libc) does not expose all kernel-level constants and some syscalls/constants are only available vialinux-raw-sys
. At the same time, Android’s userspace is missing a few advanced Linux-only features and constants (e.g.SOL_XDP
,RWF_*
) — those should remain disabled on Android rather than enabled.This PR restores Android builds by enabling access to
linux-raw-sys
on Android targets, and then selectively disables features that truly require Linux userspace support not present in Bionic.What this PR changes
High level
linux-raw-sys
kernel types for Android targets so Android can access kernel constants/types it needs.#[cfg(...)]
guards so features not supported by Bionic (XDP, io_uring, certain STATX usages) remain disabled on Android.Rationale / Technical explanation
Android uses the Linux kernel, so kernel-level types and syscall constants are valid on Android and MUST be available to the crate (via
linux-raw-sys
) so code paths that depend on kernel definitions compile.However, Android’s userspace (Bionic) does not expose certain Linux userspace constants and features:
SOL_XDP
and related constants are not present in Bionic. XDP is a Linux networking acceleration feature that is not applicable to Android userspace; those code paths are guarded so they are only enabled for desktop/server Linux.RWF_*
(e.g.,RWF_NOWAIT
,RWF_DSYNC
) flags and other io_uring-related userspace support may be absent in Bionic. io_uring code is therefore excluded on Android targets.linux-raw-sys
, causing ambiguity; adding Android to the exclusion list resolves the ambiguity and keeps the definitions consistent.Net effect: Android gets what it needs from kernel types; Linux retains full feature set. No behavior changes for Linux targets.
Testing performed
All CI workflow targets tested locally/in-workflow:
Android (all passing)
aarch64-linux-android
(default &use-libc
features)armv7-linux-androideabi
(use-libc
)x86_64-linux-android
(use-libc
)i686-linux-android
(use-libc
)Linux (all passing)
all-apis
feature buildsuse-libc,all-apis
buildslinux_latest,all-apis
builds(These are the results from my test runs; CI logs are attached in the workflow that exercised all Android and Linux variants.)
Changes are intentionally minimal and scoped:
Linux behavior is unchanged —
#[cfg(all(linux_raw_dep, target_os = "linux"))]
keeps full Linux feature set intact.Tests and CI flows covering both Android and Linux have been exercised and pass.
References (for reviewer verification)