fix(rust): Android 交叉编译兼容(errno 分支 + Makefile 目标) - #84
Draft
lloydzhou wants to merge 1 commit into
Draft
Conversation
- ffi/mod.rs、agent.rs:errno 读取/重置补 target_os = "android" 分支, 使用 bionic 的 libc::__errno()(原先只有 macos/linux 分支,android 下 err 未定义导致 5 处 E0425 编译失败) - Makefile:新增独立目标 build-rustagent-android;webagent-android 依赖之。交叉编译经 env 传 CC_aarch64-linux-android/AR_aarch64-linux-android (NDK 只提供带 API level 的 clang,ring 的 cc-rs 探测不到通用名 aarch64-linux-android-clang;变量名含 "-" 须用 env 命令注入) - 移除失效的 build-rust2 目标 验证:NDK r27d 交叉编译通过,产物为 ELF aarch64 PIE (/system/bin/linker64,仅依赖 libc/libm/libdl),宿主 cargo check 不受影响
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
问题
make build-rustagent-android(aarch64-linux-android 交叉编译)失败,两层原因:1. errno 代码缺少 android 分支(编译错误 ×5)
rust/src/ffi/mod.rs与rust/src/agent.rs中 errno 读取/重置只有 macos/linux 两个 cfg 分支,android(bionic)下全部不命中:修法与
feat/rust-serve分支b4a39e9当时一致(android 用libc::__errno()),并补齐其漏掉的 agent.rs clear errno 处,共 4 处。2. cc-rs(ring 0.17.14)探测不到 NDK 编译器
aarch64-linux-android27-clang,无通用名CARGO_TARGET_AARCH64_LINUX_ANDROID_CC变量名格式 cc-rs 不识别,需用CC_aarch64-linux-android(target 横线转下划线)-,bash 无法直接赋值,须经env命令注入改动
rust/src/ffi/mod.rslibc::__errno())×2rust/src/agent.rsMakefilebuild-rustagent-android;build-webagent-android依赖之;ANDROID_ENV统一注入 CC/AR/LINKER;移除失效的build-rust2验证
make build-rustagent-android NDK=~/android-sdk/android-ndk-r27d✅dist/rustagent-android(3.4M):ELF aarch64 PIE,interpreter/system/bin/linker64,仅依赖 bionic libc/libm/libdlcargo check --release不受影响 ✅使用