1、问题描述

同步上游仓库的OpenHarmony-v4.0-Release版本的源代码,安装prebuilts工具链后,选择standard->rk3568产品,执行hb build编译,最终报以下错误:

  LD      .tmp_vmlinux.btf
+ shift
+ [ .tmp_vmlinux.btf != .tmp_vmlinux.btf ]
+ [ arm64 != um ]
+ [ -n y ]
+ objects=--whole-archive                                               vmlinux.o                                                       --no-whole-archive
+ ld.lld -EL -maarch64elf -z norelro --thinlto-cache-dir=.thinlto-cache -mllvm -import-instr-limit=5 -z noexecstack --no-undefined -X -shared -Bsymbolic -z notext --no-apply-dynamic-relocs --fix-cortex-a53-843419 --build-id=sha1 --pack-dyn-relocs=relr --use-android-relr-tags --orphan-handling=warn -o .tmp_vmlinux.btf -T ./arch/arm64/kernel/vmlinux.lds --whole-archive vmlinux.o --no-whole-archive
ld.lld: error: undefined symbol: __aarch64_cas4_acq_rel
>>> referenced by hdf_vnode_adapter.c:294 (/home/sam/src/openharmony/out/kernel/OBJ/linux-5.10/../../../../drivers/hdf_core/framework/core/adapter/vnode/src/hdf_vnode_adapter.c:294)
>>>               vmlinux.o:(HdfVNodeAdapterIoctl)
>>> referenced by hdf_vnode_adapter.c:303 (/home/sam/src/openharmony/out/kernel/OBJ/linux-5.10/../../../../drivers/hdf_core/framework/core/adapter/vnode/src/hdf_vnode_adapter.c:303)
>>>               vmlinux.o:(HdfVNodeAdapterIoctl)
>>> referenced by hdf_vnode_adapter.c:428 (/home/sam/src/openharmony/out/kernel/OBJ/linux-5.10/../../../../drivers/hdf_core/framework/core/adapter/vnode/src/hdf_vnode_adapter.c:428)
>>>               vmlinux.o:(HdfDeviceSendEventToClient)
>>> referenced 1 more times
+ info BTF .btf.vmlinux.bin.o
+ [  != silent_ ]
+ printf   %-7s %s\n BTF .btf.vmlinux.bin.o
  BTF     .btf.vmlinux.bin.o
+ LLVM_OBJCOPY=llvm-objcopy pahole -J --skip_encoding_btf_vars .tmp_vmlinux.btf
pahole: .tmp_vmlinux.btf: No such file or directory

 编译环境

$ uname -a
Linux builder 5.15.0-84-generic #93~20.04.1-Ubuntu SMP Wed Sep 6 16:15:40 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

$ prebuilts/clang/ohos/linux-x86_64/llvm/bin/clang --version
OHOS (dev) clang version 15.0.4 (llvm-project d1aa604d90b55a96aa22af9992d170fccbd41938)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/sam/src/openharmony/prebuilts/clang/ohos/linux-x86_64/llvm/bin

$ prebuilts/clang/ohos/linux-x86_64/llvm/bin/ld.lld --version
LLD 15.0.4 (compatible with GNU linkers)

日志是做了以下修改后从编译日志里采集的

~/src/openharmony/kernel/linux/patches$ git diff
diff --git a/linux-5.10/rk3568_patch/kernel.patch b/linux-5.10/rk3568_patch/kernel.patch
index 1efa5ff..9843413 100644
--- a/linux-5.10/rk3568_patch/kernel.patch
+++ b/linux-5.10/rk3568_patch/kernel.patch
@@ -1663098,7 +1663098,7 @@ index 000000000..4f6b72d23
 +ENABLE_LTO_O0=${3}
 +
 +CPUs=`sed -n "N;/processor/p" /proc/cpuinfo|wc -l`
-+MAKE="make LLVM=1 LLVM_IAS=1 CROSS_COMPILE=aarch64-linux-gnu-"
++MAKE="make V=1 LLVM=1 LLVM_IAS=1 CROSS_COMPILE=aarch64-linux-gnu-"
 +[ "${ENABLE_LTO_O0}" == "enable_lto_O0" ] && MAKE="${MAKE} KCFLAGS=-Wl,--lto-O0"
 +BUILD_PATH=boot_linux
 +EXTLINUX_PATH=${BUILD_PATH}/extlinux

另外,更新到master分支编译会报相同的错误。

 

2、解决办法

新创建了一个容器,按照这个步骤全新下载代码、工具链,编译成功了。之前的编译环境是编译3.2.2版本的,只是升级了prebuilts工具链。

Logo

社区规范:仅讨论OpenHarmony相关问题。

更多推荐