| Cross-compile for Android, with an NDK nobody has to install 14a30c0 nandi 19d ago | 1 | //! The Rust half of what the Android toolchain is asked to prove. |
| 2 | //! |
| 3 | //! No dependencies, first-party or third: the third-party graph has no Android |
| 4 | //! platform yet, so this is what can cross-compile today. It fails to build |
| 5 | //! unless rustc was given the device's libstd — `std::os::android` exists on |
| 6 | //! no other target — and unless the sysroot also still holds the host's, which |
| 7 | //! is what the stitching in toolchains//dist is for. |
| 8 | |
| 9 | #[cfg(target_os = "android")] |
| 10 | pub use std::os::android as _platform; |
| 11 | |
| 12 | #[cfg(not(target_os = "android"))] |
| 13 | compile_error!("not an Android target"); |
| 14 | |
| 15 | /// Named so the symbol is visible in the object; nothing calls it. |
| 16 | #[unsafe(no_mangle)] |
| 17 | pub extern "C" fn jolt_android_std_ok() -> u32 { |
| 18 | // Reaching libstd's allocator and its formatting machinery is the point: |
| 19 | // a target libstd that failed to load would not get this far. |
| 20 | format!("{}", u32::from(cfg!(target_arch = "aarch64"))).len() as u32 |
| 21 | } |
| 22 | |