最近在移植SDM450 Android 11的项目,新建device的过程中发现一个编译报错,模块为高通GPS相关的slim_daemon,默认的target为msm8953_64编译ok. 新建的device编译就是失败,错误log如下:
[ 12% 3353/26214] target Executable: slim_daemon (out/target/product/xxx/obj/EXECUTABLES/slim_daemon_intermediates/LINKED/slim_daemon)
FAILED: out/target/product/xxx/obj/EXECUTABLES/slim_daemon_intermediates/LINKED/slim_daemon
/bin/bash -c "prebuilts/clang/host/linux-x86/clang-r383902b1/bin/clang++ -pie -nostdlib -Bdynamic -Wl,-dynamic-linker,/system/bin/linker64 -Wl,--gc-sections -Wl,-z,nocopyreloc out/soong/.intermediates/bionic/libc/crtbegin_dynamic/android_vendor.30_arm64_armv8-a/crtbegin_dynamic.o out/target/product/xxx/obj/EXECUTABLES/slim_daemon_intermediates/apss/daemon/SlimDaemonManager.o out/target/product/xxx/obj/EXECUTABLES/slim_daemon_intermediates/apss/listener/ClientListener.o out/target/product/xxx/obj/EXECUTABLES/slim_daemon_intermediates/provider/common/ProviderBase.o out/target/product/xxx/obj/EXECUTABLES/slim_daemon_intermediates/provider/common/MultiplexingProvider.o out/target/product/xxx/obj/EXECUTABLES/slim_daemon_intermediates/provider/common/SlimProviderConf.o out/target/product/xxx/obj/EXECUTABLES/slim_daemon_intermediates/provider/common/KalmanFilter.o out/target/product/xxx/obj/EXECUTABLES/slim_daemon_intermediates/provider/ndk/SlimNDKProvider.o out/target/product/xxx/obj/EXECUTABLES/slim_daemon_intermediates/apss/listener/QLClientListener.o -Wl,--whole-archive -Wl,--no-whole-archive out/target/product/xxx/obj/STATIC_LIBRARIES/libslimcommon_intermediates/libslimcommon.a out/target/product/xxx/obj/STATIC_LIBRARIES/libslimutils_intermediates/libslimutils.a out/target/product/xxx/obj/STATIC_LIBRARIES/libc++demangle.vendor_intermediates/libc++demangle.vendor.a out/target/product/xxx/obj/STATIC_LIBRARIES/libclang_rt.ubsan_minimal-aarch64-android.vendor_intermediates/libclang_rt.ubsan_minimal-aarch64-android.vendor.a prebuilts/clang/host/linux-x86/clang-r383902b1/lib64/clang/11.0.2/lib/linux//libclang_rt.builtins-aarch64-android.a out/target/product/xxx/obj/STATIC_LIBRARIES/libatomic_intermediates/libatomic.a -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--build-id=md5 -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--no-undefined-version -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libgcc_stripped.a -Wl,--exclude-libs,libunwind_llvm.a -fuse-ld=lld -Wl,--hash-style=gnu -Wl,-z,separate-code -Wl,--icf=safe -Wl,-z,max-page-size=4096 -Bprebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/aarch64-linux-android/bin -Wl,--pack-dyn-relocs=none -pie -flto -fsanitize-cfi-cross-dso -fsanitize=cfi -Wl,-plugin-opt,O1 -Wl,--version-script,build/soong/cc/config/cfi_exports.map -Wl,--exclude-libs,libclang_rt.ubsan_minimal-aarch64-android.a -Wl,--no-undefined -target aarch64-linux-android30 out/target/product/xxx/obj/SHARED_LIBRARIES/libgps.utils_intermediates/libgps.utils.so out/target/product/xxx/obj/SHARED_LIBRARIES/liblog.vendor_intermediates/liblog.vendor.so out/target/product/xxx/obj/SHARED_LIBRARIES/libdiag_intermediates/libdiag.so out/target/product/xxx/obj/SHARED_LIBRARIES/libqmi_csi_intermediates/libqmi_csi.so out/target/product/xxx/obj/SHARED_LIBRARIES/libqmi_cci_intermediates/libqmi_cci.so out/target/product/xxx/obj/SHARED_LIBRARIES/libqmi_common_so_intermediates/libqmi_common_so.so out/target/product/xxx/obj/SHARED_LIBRARIES/libqmi_encdec_intermediates/libqmi_encdec.so out/target/product/xxx/obj/SHARED_LIBRARIES/libutils.vendor_intermediates/libutils.vendor.so out/target/product/xxx/obj/SHARED_LIBRARIES/libhidlbase.vendor_intermediates/libhidlbase.vendor.so out/target/product/xxx/obj/SHARED_LIBRARIES/libsensorndkbridge_intermediates/libsensorndkbridge.so out/target/product/xxx/obj/SHARED_LIBRARIES/android.hardware.sensors@1.0.vendor_intermediates/android.hardware.sensors@1.0.vendor.so out/target/product/xxx/obj/SHARED_LIBRARIES/android.frameworks.sensorservice@1.0.vendor_intermediates/android.frameworks.sensorservice@1.0.vendor.so out/target/product/xxx/obj/SHARED_LIBRARIES/libloc_api_v02_intermediates/libloc_api_v02.so out/target/product/xxx/obj/SHARED_LIBRARIES/libloc_core_intermediates/libloc_core.so out/target/product/xxx/obj/SHARED_LIBRARIES/liblbs_core_intermediates/liblbs_core.so out/target/product/xxx/obj/SHARED_LIBRARIES/libc++.vendor_intermediates/libc++.vendor.so out/target/product/xxx/obj/SHARED_LIBRARIES/libc.vendor_intermediates/libc.vendor.so out/target/product/xxx/obj/SHARED_LIBRARIES/libm.vendor_intermediates/libm.vendor.so out/target/product/xxx/obj/SHARED_LIBRARIES/libdl.vendor_intermediates/libdl.vendor.so -o out/target/product/xxx/obj/EXECUTABLES/slim_daemon_intermediates/LINKED/slim_daemon out/soong/.intermediates/bionic/libc/crtend_android/android_vendor.30_arm64_armv8-a/obj/bionic/libc/arch-common/bionic/crtend.o"
ld.lld: error: undefined symbol: QSQmiSvcTask_SvcCbInit
>>> referenced by qmislim_qmi_service_task.c:664 (vendor/qcom/proprietary/gps-noship/slim/qmislim/common/src/qmislim_qmi_service_task.c:664)
>>> lto.tmp:(slim_QSQmiSvcTask_Init)
>>> referenced by qmislim_qmi_service_task.c:665 (vendor/qcom/proprietary/gps-noship/slim/qmislim/common/src/qmislim_qmi_service_task.c:665)
>>> lto.tmp:(slim_QSQmiSvcTask_Init)
>>> referenced by qmislim_qmi_service_task.c:666 (vendor/qcom/proprietary/gps-noship/slim/qmislim/common/src/qmislim_qmi_service_task.c:666)
>>> lto.tmp:(slim_QSQmiSvcTask_Init)
ld.lld: error: undefined symbol: QSQmiSvcTaskSvcCb_I2O
>>> referenced by qmislim_qmi_service_task.c:411 (vendor/qcom/proprietary/gps-noship/slim/qmislim/common/src/qmislim_qmi_service_task.c:411)
初步怀疑点是device目录下及vendor/qcom/proprietary下的msm8953相关的配置,是否都考虑到了. 反复确认,没找到下手的变量的差异可以排除,最终通过比较out目录下对应的编译
out\target\product\oemdevice\obj\STATIC_LIBRARIES\libslimutils_intermediates\src\qmislim_target.d
发现问题所在,发现编译报错使用的工具链为
prebuilts/clang/host/linux-x86/clang-r383902b1/bin/clang++ -pie -nostdlib -Bdynamic -Wl,-dynamic-linker,/system/bin/linker64 -Wl,--gc-sections -Wl,
msm8953_64编译正常编译的工具链为:
vendor/qcom/proprietary/llvm-arm-toolchain-ship/10.0/lib/clang/10.0.7/include/stddef.h \
然后简单追踪了下调用流程:
vendor\qcom\proprietary\common\config\sdclang.json
{
"default": {
"FORCE_SDCLANG_OFF": false,
"SDCLANG": false,
"SDCLANG_PATH": "vendor/qcom/proprietary/llvm-arm-toolchain-ship/8.0/bin",
"SDCLANG_FLAGS": ""
},
..
..
..
..
"msm8953_64": {
"SDCLANG": true,
"SDCLANG_PATH": "vendor/qcom/proprietary/llvm-arm-toolchain-ship/10.0/bin",
"SDCLANG_FLAGS": "-Wno-reorder-init-list -Wno-implicit-fallthrough -Wno-c99-designator -Wno-implicit-int-float-conversion -Wno-int-in-bool-context -Wno-alloca -Wno-dangling-gsl -Wno-pointer-compare -Wno-final-dtor-non-final-class -Wno-incomplete-setjmp-declaration -Wno-sizeof-array-div -Wno-xor-used-as-pow -fsplit-lto-unit -Wno-c++17-extensions -flax-vector-conversions=all -Wno-tautological-overlap-compare -Wno-range-loop-analysis -Wno-invalid-partial-specialization -Wno-deprecated-copy -Wno-misleading-indentation -Wno-zero-as-null-pointer-constant -Wno-deprecated-enum-enum-conversion -Wno-deprecated-anon-enum-enum-conversion -Wno-bool-operation -Wno-unused-comparison -Wno-string-compare -Wno-wrong-info -Wno-thread-safety-analysis -Wno-unsequenced -Wno-unknown-warning-option"
},
"oemdevice": {
"SDCLANG": true,
"SDCLANG_PATH": "vendor/qcom/proprietary/llvm-arm-toolchain-ship/10.0/bin",
"SDCLANG_FLAGS": "-Wno-reorder-init-list -Wno-implicit-fallthrough -Wno-c99-designator -Wno-implicit-int-float-conversion -Wno-int-in-bool-context -Wno-alloca -Wno-dangling-gsl -Wno-pointer-compare -Wno-final-dtor-non-final-class -Wno-incomplete-setjmp-declaration -Wno-sizeof-array-div -Wno-xor-used-as-pow -fsplit-lto-unit -Wno-c++17-extensions -flax-vector-conversions=all -Wno-tautological-overlap-compare -Wno-range-loop-analysis -Wno-invalid-partial-specialization -Wno-deprecated-copy -Wno-misleading-indentation -Wno-zero-as-null-pointer-constant -Wno-deprecated-enum-enum-conversion -Wno-deprecated-anon-enum-enum-conversion -Wno-bool-operation -Wno-unused-comparison -Wno-string-compare -Wno-wrong-info -Wno-thread-safety-analysis -Wno-unsequenced -Wno-unknown-warning-option"
},
"msm8953_32": {
"SDCLANG": true,
"SDCLANG_PATH": "vendor/qcom/proprietary/llvm-arm-toolchain-ship/10.0/bin",
"SDCLANG_FLAGS": "-Wno-reorder-init-list -Wno-implicit-fallthrough -Wno-c99-designator -Wno-implicit-int-float-conversion -Wno-int-in-bool-context -Wno-alloca -Wno-dangling-gsl -Wno-pointer-compare -Wno-final-dtor-non-final-class -Wno-incomplete-setjmp-declaration -Wno-sizeof-array-div -Wno-xor-used-as-pow -fsplit-lto-unit -Wno-c++17-extensions -flax-vector-conversions=all -Wno-tautological-overlap-compare -Wno-range-loop-analysis -Wno-invalid-partial-specialization -Wno-deprecated-copy -Wno-misleading-indentation -Wno-zero-as-null-pointer-constant -Wno-deprecated-enum-enum-conversion -Wno-deprecated-anon-enum-enum-conversion -Wno-bool-operation -Wno-unused-comparison -Wno-string-compare -Wno-wrong-info -Wno-thread-safety-analysis -Wno-unsequenced -Wno-unknown-warning-option"
},
},
"qssi": {
"SDCLANG": false,
"SDCLANG_PATH": "vendor/qcom/proprietary/llvm-arm-toolchain-ship/10.0/bin",
"SDCLANG_FLAGS": "-Wno-reorder-init-list -Wno-implicit-fallthrough -Wno-c99-designator -Wno-implicit-int-float-conversion -Wno-int-in-bool-context -Wno-alloca -Wno-dangling-gsl -Wno-pointer-compare -Wno-final-dtor-non-final-class -Wno-incomplete-setjmp-declaration -Wno-sizeof-array-div -Wno-xor-used-as-pow -fsplit-lto-unit -Wno-c++17-extensions -flax-vector-conversions=all -Wno-tautological-overlap-compare -Wno-range-loop-analysis -Wno-invalid-partial-specialization -Wno-deprecated-copy -Wno-misleading-indentation -Wno-zero-as-null-pointer-constant -Wno-deprecated-enum-enum-conversion -Wno-deprecated-anon-enum-enum-conversion -Wno-bool-operation -Wno-unused-comparison -Wno-string-compare -Wno-wrong-info -Wno-thread-safety-analysis -Wno-unsequenced -Wno-unknown-warning-option"
},
"qssi_32": {
"SDCLANG": false,
"SDCLANG_PATH": "vendor/qcom/proprietary/llvm-arm-toolchain-ship/10.0/bin",
"SDCLANG_FLAGS": "-Wno-reorder-init-list -Wno-implicit-fallthrough -Wno-c99-designator -Wno-implicit-int-float-conversion -Wno-int-in-bool-context -Wno-alloca -Wno-dangling-gsl -Wno-pointer-compare -Wno-final-dtor-non-final-class -Wno-incomplete-setjmp-declaration -Wno-sizeof-array-div -Wno-xor-used-as-pow -fsplit-lto-unit -Wno-c++17-extensions -flax-vector-conversions=all -Wno-tautological-overlap-compare -Wno-range-loop-analysis -Wno-invalid-partial-specialization -Wno-deprecated-copy -Wno-misleading-indentation -Wno-zero-as-null-pointer-constant -Wno-deprecated-enum-enum-conversion -Wno-deprecated-anon-enum-enum-conversion -Wno-bool-operation -Wno-unused-comparison -Wno-string-compare -Wno-wrong-info -Wno-thread-safety-analysis -Wno-unsequenced -Wno-unknown-warning-option"
},
"qssi_32go": {
"SDCLANG": false,
"SDCLANG_PATH": "vendor/qcom/proprietary/llvm-arm-toolchain-ship/10.0/bin",
"SDCLANG_FLAGS": "-Wno-reorder-init-list -Wno-implicit-fallthrough -Wno-c99-designator -Wno-implicit-int-float-conversion -Wno-int-in-bool-context -Wno-alloca -Wno-dangling-gsl -Wno-pointer-compare -Wno-final-dtor-non-final-class -Wno-incomplete-setjmp-declaration -Wno-sizeof-array-div -Wno-xor-used-as-pow -fsplit-lto-unit -Wno-c++17-extensions -flax-vector-conversions=all -Wno-tautological-overlap-compare -Wno-range-loop-analysis -Wno-invalid-partial-specialization -Wno-deprecated-copy -Wno-misleading-indentation -Wno-zero-as-null-pointer-constant -Wno-deprecated-enum-enum-conversion -Wno-deprecated-anon-enum-enum-conversion -Wno-bool-operation -Wno-unused-comparison -Wno-string-compare -Wno-wrong-info -Wno-thread-safety-analysis -Wno-unsequenced -Wno-unknown-warning-option"
},
"cuttlestone_x86_phone": {
"SDCLANG": false,
"SDCLANG_PATH": "prebuilts/clang/host/linux-x86/clang-r377782/bin",
"SDCLANG_FLAGS": ""
}
}
vendor/qcom/proprietary/common/vendorsetup.sh引入
export QCPATH="vendor/qcom/proprietary"
9 export QCPATH_COMMONSYS="${QCPATH}/commonsys"
10 export SDCLANG_AE_CONFIG="${QCPATH}/common-noship/etc/sdclang.json"
11 export SDCLANG_CONFIG="${QCPATH}/common/config/sdclang.json"
12 if [ -f "$(pwd)/${QCPATH}/qrsp/mpgen/mpgen.py" ]; then
13 export RTIC_MPGEN="python $(pwd)/${QCPATH}/qrsp/mpgen/mpgen.py"
14 fi
此处先简单记录,后续需要对SDLANG编译工具这一块做下详细的了解(Todo).