diff --git a/crates/core/Cargo.toml b/crates/core/Cargo.toml index 1ba4e0fb..5a1002fe 100644 --- a/crates/core/Cargo.toml +++ b/crates/core/Cargo.toml @@ -106,12 +106,14 @@ smallvec = { version = "1.15.1", features = ["union"] } strum = { version = "0.28.0", features = ["derive"] } zstd = "0.13.3" -[target.'cfg(not(windows))'.dependencies] +[target.'cfg(not(any(windows, all(target_os="android", target_arch="x86"))))'.dependencies] sha2 = { version = "0.10.9", features = ["asm"] } -[target.'cfg(windows)'.dependencies] +[target.'cfg(any(windows, all(target_os="android", target_arch="x86")))'.dependencies] # unfortunately, the asm extensions do not build on Windows, see https://github.com/RustCrypto/asm-hashes/issues/17 # and https://github.com/RustCrypto/asm-hashes/pull/issues/78 +# Android x86 links this crate into a JNI shared library. sha2-asm's 32-bit x86 objects contain text +# relocations, which Android rejects when loading shared libraries. sha2 = "0.10.9" [target.'cfg(not(any(windows, target_os="openbsd")))'.dependencies] diff --git a/crates/core/src/backend/local_destination.rs b/crates/core/src/backend/local_destination.rs index 9d7bcc90..99b2f11f 100644 --- a/crates/core/src/backend/local_destination.rs +++ b/crates/core/src/backend/local_destination.rs @@ -40,7 +40,11 @@ pub enum LocalDestinationErrorKind { DirectoryCreationFailed(std::io::Error), /// file `{0:?}` should have a parent FileDoesNotHaveParent(PathBuf), - #[cfg(any(target_os = "macos", target_os = "openbsd"))] + #[cfg(any( + target_os = "macos", + target_os = "openbsd", + all(target_os = "android", target_pointer_width = "32") + ))] /// `DeviceID` could not be converted to other type `{target}` of device `{device}`: `{source}` DeviceIdConversionFailed { target: String, @@ -655,7 +659,11 @@ impl LocalDestination { })?; } NodeType::Dev { device } => { - #[cfg(not(any(target_os = "macos", target_os = "openbsd")))] + #[cfg(not(any( + target_os = "macos", + target_os = "openbsd", + all(target_os = "android", target_pointer_width = "32") + )))] let device = *device; #[cfg(any(target_os = "macos", target_os = "openbsd"))] let device = i32::try_from(*device).map_err(|err| { @@ -665,11 +673,23 @@ impl LocalDestination { source: err, } })?; + #[cfg(all(target_os = "android", target_pointer_width = "32"))] + let device = u32::try_from(*device).map_err(|err| { + LocalDestinationErrorKind::DeviceIdConversionFailed { + target: "u32".to_string(), + device: *device, + source: err, + } + })?; mknod(&filename, SFlag::S_IFBLK, Mode::empty(), device) .map_err(LocalDestinationErrorKind::FromErrnoError)?; } NodeType::Chardev { device } => { - #[cfg(not(any(target_os = "macos", target_os = "openbsd")))] + #[cfg(not(any( + target_os = "macos", + target_os = "openbsd", + all(target_os = "android", target_pointer_width = "32") + )))] let device = *device; #[cfg(any(target_os = "macos", target_os = "openbsd"))] let device = i32::try_from(*device).map_err(|err| { @@ -679,6 +699,14 @@ impl LocalDestination { source: err, } })?; + #[cfg(all(target_os = "android", target_pointer_width = "32"))] + let device = u32::try_from(*device).map_err(|err| { + LocalDestinationErrorKind::DeviceIdConversionFailed { + target: "u32".to_string(), + device: *device, + source: err, + } + })?; mknod(&filename, SFlag::S_IFCHR, Mode::empty(), device) .map_err(LocalDestinationErrorKind::FromErrnoError)?; }