Android P版本解决VNDK library: XXX’s ABI has EXTENDING CHANGES
前言
??此时的我吃着火锅唱着歌,进行着Android P(此P非彼P,Android 9)的适配工作。我真的只能说每次Android版本的迭代更新,都是对我们的一次炼狱般的摧残啊,各种适配啊,我真的想说fuck the coding。但是吐槽归吐槽,为了我热爱的coding事业,让我们愉快的适配起来。这不问题又来了,当我们修改liblog源码时提示error: VNDK library: liblog’s ABI has EXTENDING CHANGES,木得办法兵来将挡水来土掩,只能上了。
注意:本文演示的代码是Android P高通msm8953平台。
一.问题现象
当我们尝试对Android源码下面的system/core/liblog源码目录下面的文件添加一些接口时,适配问题出现了,编译一直报错,如下所示:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | QSSI: not enabled for msm8953_64 target as vendor/qcom/proprietary/release/QSSI/QSSI_enforced_targets_list.txt was not found. ninja: no work to do. ninja: no work to do. No need to regenerate ninja file No need to regenerate ninja file [ 50% 1/2] glob . [ 16% 1/6] //system/core/liblog:liblog header-abi-diff liblog.so.abidiff FAILED: out/soong/.intermediates/system/core/liblog/liblog/android_arm64_armv8-a_core_shared/liblog.so.abidiff (prebuilts/clang-tools/linux-x86/bin/header-abi-diff -allow-unreferenced-changes -allow-unreferenced-elf-symbol-changes -lib liblog -arch arm64 -o out/soong/.intermediates/system/core/liblog/liblog/android_arm64_armv8-a_core_shared/liblog.so.abidiff -new out/soong/.intermediates/system/core/liblog/liblog/android_arm64_armv8-a_core_shared/liblog.so.lsdump -old out/soong/.intermediates/system/core/liblog/liblog/android_arm64_armv8-a_core_shared/liblog.so_ref.lsdump)|| (echo ' ---- Please update abi references by running platform/development/vndk/tools/header-checker/utils/create_reference_dumps.py -l liblog ----' && exit 1) ****************************************************** error: VNDK library: liblog's ABI has EXTENDING CHANGES Please check compatiblity report at : out/soong/.intermediates/system/core/liblog/liblog/android_arm64_armv8-a_core_shared/liblog.so.abidiff ****************************************************** ---- Please update abi references by running platform/development/vndk/tools/header-checker/utils/create_reference_dumps.py -l liblog ---- ninja: build stopped: subcommand failed. 09:34:59 ninja failed with: exit status 1 |
不用怀疑,这个不是你源码的问题。这个是由于Android P增加了VNDK的限制。
二.VNDK是什么
VNDK(Vendor Native Development Kit)是一组专门用于vendor实现其HAL的lib库,因为自Android 8.0以来,Google引入了Treble架构,希望对vendor和system分区进行解耦处理,期待实现:framwork进程不加载vendor共享库,vendor进程仅加载vendor共享库(和部分framework共享库),而framework进程和vendor进程之间通过HIDL和hwbinder来通信。总结为如下几点:
- platform和Vendor的构建是相互隔离的;
- platform lib对应 system.img;
- vendor lib对应 vendor.img;
- 大多数情况下,Vendor lib跟系统核心不能相互使用;Vendor lib不允许dlopen私有的系统库;
- 合作伙伴不允许为自己的产品在VNDK新增lib,只能贡献到AOSP;
关于VNDK的具体介绍可以参见如下博客:
ABI 稳定性
Android : 供应商原生开发套件 (VNDK)
供应商原生开发套件 (VNDK)
三.怎么解决
在代码中搜索,发现 development/vndk/tools/header-checker/header-abi-diff/src 中的 header_abi_diff.cpp 报出的错误。错误提示如下:
1 2 3 4 5 6 7 8 9 10 11 12 | 184 if (should_emit_warning_message) { 185 llvm::errs() << "******************************************************\n" 186 << error_or_warning_str 187 << "VNDK library: " 188 << lib_name 189 << "'s ABI has " 190 << status_str 191 << unreferenced_change_str 192 << " Please check compatiblity report at : " 193 << compatibility_report << "\n" 194 << "******************************************************\n"; 195 } |
于是,直接修改代码,让里面的 main 直接返回 abi_util::CompatibilityStatusIR::Compatible; 然后重新编译这个文件,覆盖到代码中的检查库。全编译。通过!!
下面让我们详细讲解一下步骤:
-修改development/vndk/tools/header-checker/header-abi-diff/src/header_abi_diff.cpp,改动如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | --- a/development/vndk/tools/header-checker/header-abi-diff/src/header_abi_diff.cpp +++ b/development/vndk/tools/header-checker/header-abi-diff/src/header_abi_diff.cpp @@ -182,21 +182,21 @@ int main(int argc, const char **argv) { bool should_emit_warning_message = ShouldEmitWarningMessage(status); if (should_emit_warning_message) { - llvm::errs() << "******************************************************\n" - << error_or_warning_str - << "VNDK library: " - << lib_name - << "'s ABI has " - << status_str - << unreferenced_change_str - << " Please check compatiblity report at : " - << compatibility_report << "\n" - << "******************************************************\n"; +// llvm::errs() << "******************************************************\n" +// << error_or_warning_str +// << "VNDK library: " +// << lib_name +// << "'s ABI has " +// << status_str +// << unreferenced_change_str +// << " Please check compatiblity report at : " +// << compatibility_report << "\n" +// << "******************************************************\n"; } - if (!advice_only && should_emit_warning_message) { - return status; - } |
- 重新编译 development/vndk/tools/header-checker,编译命令如下:
1 2 3 4 5 6 | mmm development/vndk/tools/header-checker/ -j32 616+0 records in 616+0 records out 630784 bytes (631 kB, 616 KiB) copied, 0.0032836 s, 192 MB/s [ 66% 2/3] glob . [100% 5/5] Install: out/host/linux-x86/bin/header-abi-diff |
- 复制 out/host/linux-x86/bin/header-abi-diff 到 prebuilts/clang-tools/linux-x86/bin 中覆盖,命令如下:
1 | cp out/host/linux-x86/bin/header-abi-diff prebuilts/clang-tools/linux-x86/bin/header-abi-diff |
- 重新souurce lunhcer,再执行你需要修改的so文件,譬如我们这里的是liblog,我们编译一把:
1 2 3 4 5 6 | make -j32 liblog //编译结果 vendor/qcom/build/tasks/generate_extra_images.mk:558: warning: overriding commands for target `kernelclean' device/qcom/common/generate_extra_images.mk:558: warning: ignoring old commands for target `kernelclean' [100% 76/76] build out/host/linux-x86/obj32/SHARED_LIBRARIES/liblog_intermediates/liblog.so.toc |
好了,大功告成可以愉快的修改VNDK的相关改动了。
结语
各位乡亲们,Android P版本解决VNDK library: XXX’s ABI has EXTENDING CHANGES就结束了,整的我腰酸背痛啊。Android版本升级之时就是我等受苦之时啊。
写在最后
??好了如上就是Android P版本解决VNDK library: XXX’s ABI has EXTENDING CHANGES的所有,如有问题或者有任何疑问请及时沟通或者交流,也可点个赞或者吐槽一番也是可以的。so goodbye。