上海古都建筑设计集团,上海办公室装修设计公司,上海装修公司高质量的内容分享社区,上海装修公司我们不是内容生产者,我们只是上海办公室装修设计公司内容的搬运工平台

OpenHarmony 4.0 Release 编译异常处理

guduadmin301月前

一、环境配置

编译环境:Ubuntu 20.04

OpenHarmony 软件版本:4.0 Release

设备平台:rk3568

二、下拉代码

参考官网步骤:

OpenHarmony 4.0 Release 源码获取

repo init -u https://gitee.com/openharmony/manifest -b OpenHarmony-4.0-Release --no-repo-verify
repo sync -c
repo forall -c 'git lfs pull'

三、编译代码

参考官网构建步骤:

v4.0 Release 编译构建

 bash build/prebuilts_download.sh
./build.sh --product-name rk3568 --ccache

如果上述步骤一切顺利,编译通过,build log如下:

...
Please modify according to README.md
[OHOS INFO] rk3568 build success
[OHOS INFO] Cost time:  0:58:44
=====build  successful=====
2023-11-08 14:48:55
++++++++++++++++++++++++++++++++++++++++

四、下拉及编译中遇到的问题

4.1、repo: error: unable to resolve “fork_flow”

下拉代码执行报错

$ repo init -u https://gitee.com/openharmony/manifest -b master --no-repo-verify
Downloading Repo source from https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/
remote: Enumerating objects: 4885, done.
remote: Counting objects: 100% (4885/4885), done.
remote: Compressing objects: 100% (2425/2425), done.
remote: Total 8626 (delta 4312), reused 2460 (delta 2460), pack-reused 3741
Receiving objects: 100% (8626/8626), 4.16 MiB | 9.25 MiB/s, done.
Resolving deltas: 100% (5577/5577), done.
repo: warning: verification of repo code has been disabled;
repo will not be able to verify the integrity of itself.
repo: error: unable to resolve "fork_flow"
fatal: cloning the git-repo repository failed, will remove '.repo/repo'

unable to resolve “fork_flow”" 表明repo工具无法解析名为 “fork_flow”,实际上fork_flow是repo仓库的一个分支

repo源码:开源中国/repo

解决方案:修改REPO_REV默认值为stable

$ which repo	#查看repo安装路径
/home/xxx/bin/repo
$ sudo vim /home/xxx/bin/repo 
#REPO_REV = 'fork_flow' 改为 REPO_REV = 'stable' 

4.2 ERROR: HTTP error 404 while getting http://repo.huaweicloud.com/repository/pypi/…

执行bash build/prebuilts_download.sh后出现如下报错

$ bash build/prebuilts_download.sh 
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: http://repo.huaweicloud.com/repository/pypi/simple
Collecting rich
  Obtaining dependency information for rich from http://repo.huaweicloud.com/repository/pypi/packages/8d/5f/21a93b2ec205f4b79853ff6e838e3c99064d5dbe85ec6b05967506f14af0/rich-13.5.2-py3-none-any.whl.metadata
  ERROR: HTTP error 404 while getting http://repo.huaweicloud.com/repository/pypi/packages/8d/5f/21a93b2ec205f4b79853ff6e838e3c99064d5dbe85ec6b05967506f14af0/rich-13.5.2-py3-none-any.whl.metadata
ERROR: 404 Client Error: Not Found for url: http://repo.huaweicloud.com/repository/pypi/packages/8d/5f/21a93b2ec205f4b79853ff6e838e3c99064d5dbe85ec6b05967506f14af0/rich-13.5.2-py3-none-any.whl.metadata
prebuilts_download start
...

无效url:http://repo.huaweicloud.com/repository/pypi/packages/…

解决方案:

使用其他国内(清华)镜像源替换华为的pypi源,修改如下:

# build/prebuilts_download.sh
-    pypi_url='http://repo.huaweicloud.com/repository/pypi/simple'
+    pypi_url='https://pypi.tuna.tsinghua.edu.cn/simple'

4.3 一直卡在start npm install, please wait.

执行bash build/prebuilts_download.sh后一直卡在start npm install, please wait.

分析prebuilts_download.sh代码发现是npm源的问题,于是替换npm默认url

解决方案:

使用国内(淘宝)镜像源替换华为npm源,修改如下:

# build/prebuilts_download.py
-    parser.add_argument('--npm-registry', default='https://repo.huaweicloud.com/repository/npm/',
+    parser.add_argument('--npm-registry', default='https://registry.npm.taobao.org/',

4.4 ld.lld: error: undefined symbol: __aarch64_cas4_acq_rel…raise OHOSException(‘ninja phase failed’, ‘4000’)

详细报错如下:

[OHOS ERROR] ld.lld: error: undefined symbol: __aarch64_cas4_acq_rel
[OHOS ERROR] >>> referenced by hdf_vnode_adapter.c:294 (/home/xxx/OHOS/OpenHarmony_master/out/kernel/OBJ/linux-5.10/../../../../drivers/hdf_core/framework/core/adapter/vnode/src/hdf_vnode_adapter.c:294)
[OHOS ERROR] >>> vmlinux.o:(HdfVNodeAdapterIoctl)
[OHOS ERROR] >>> referenced by hdf_vnode_adapter.c:303 (/home/xxx/OHOS/OpenHarmony_master/out/kernel/OBJ/linux-5.10/../../../../drivers/hdf_core/framework/core/adapter/vnode/src/hdf_vnode_adapter.c:303)
[OHOS ERROR] >>> vmlinux.o:(HdfVNodeAdapterIoctl)
[OHOS ERROR] >>> referenced by hdf_vnode_adapter.c:428 (/home/xxx/OHOS/OpenHarmony_master/out/kernel/OBJ/linux-5.10/../../../../drivers/hdf_core/framework/core/adapter/vnode/src/hdf_vnode_adapter.c:428)
[OHOS ERROR] >>> vmlinux.o:(HdfDeviceSendEventToClient)
[OHOS ERROR] >>> referenced 1 more times
[OHOS ERROR] BTF .btf.vmlinux.bin.o
[OHOS ERROR] pahole: .tmp_vmlinux.btf: No such file or directory
[OHOS ERROR] LD .tmp_vmlinux.kallsyms1
[OHOS ERROR] ld.lld: error: .btf.vmlinux.bin.o: unknown file type
[OHOS ERROR] make[2]: *** [/home/xxx/OHOS/OpenHarmony_master/out/kernel/src_tmp/linux-5.10/Makefile:1236: vmlinux] Error 1
[OHOS ERROR] make[1]: *** [arch/arm64/Makefile:208: rk3568-toybrick-x0-linux.img] Error 2
[OHOS ERROR] make[1]: Leaving directory '/home/xxx/OHOS/OpenHarmony_master/out/kernel/OBJ/linux-5.10'
[OHOS ERROR] make: *** [Makefile:192: __sub-make] Error 2
[OHOS ERROR] Traceback (most recent call last):
[OHOS ERROR] File "/home/xxx/OHOS/OpenHarmony_master/build/hb/services/ninja.py", line 70, in _execute_ninja_cmd
[OHOS ERROR] SystemUtil.exec_command(
[OHOS ERROR] File "/home/xxx/OHOS/OpenHarmony_master/build/hb/util/system_util.py", line 64, in exec_command
[OHOS ERROR] raise OHOSException(
[OHOS ERROR] exceptions.ohos_exception.OHOSException: Please check build log in /home/xxx/OHOS/OpenHarmony_master/out/rk3568/build.log
[OHOS ERROR]
[OHOS ERROR] During handling of the above exception, another exception occurred:
[OHOS ERROR]
[OHOS ERROR] Traceback (most recent call last):
[OHOS ERROR] File "/home/xxx/OHOS/OpenHarmony_master/build/hb/containers/status.py", line 47, in wrapper
[OHOS ERROR] return func(args, **kwargs)
[OHOS ERROR] File "/home/xxx/OHOS/OpenHarmony_master/build/hb/modules/ohos_build_module.py", line 67, in run
[OHOS ERROR] raise exception
[OHOS ERROR] File "/home/xxx/OHOS/OpenHarmony_master/build/hb/modules/ohos_build_module.py", line 65, in run
[OHOS ERROR] super().run()
[OHOS ERROR] File "/home/xxx/OHOS/OpenHarmony_master/build/hb/modules/interface/build_module_interface.py", line 72, in run
[OHOS ERROR] raise exception
[OHOS ERROR] File "/home/xxx/OHOS/OpenHarmony_master/build/hb/modules/interface/build_module_interface.py", line 70, in run
[OHOS ERROR] self._target_compilation()
[OHOS ERROR] File "/home/xxx/OHOS/OpenHarmony_master/build/hb/modules/ohos_build_module.py", line 103, in _target_compilation
[OHOS ERROR] self.target_compiler.run()
[OHOS ERROR] File "/home/xxx/OHOS/OpenHarmony_master/build/hb/services/ninja.py", line 38, in run
[OHOS ERROR] self._execute_ninja_cmd()
[OHOS ERROR] File "/home/xxx/OHOS/OpenHarmony_master/build/hb/services/ninja.py", line 77, in _execute_ninja_cmd
[OHOS ERROR] raise OHOSException('ninja phase failed', '4000')
[OHOS ERROR] exceptions.ohos_exception.OHOSException: ninja phase failed
[OHOS ERROR]
[OHOS ERROR] Code: 4000
[OHOS ERROR]
[OHOS ERROR] Reason: ninja phase failed
[OHOS ERROR]
[OHOS ERROR] Solution: Please check the compile log at out/{compiling product}/build.log, If you could analyze build logs.
[OHOS ERROR] Or you can try the following steps to solve this problem:
[OHOS ERROR] 1. cd to OHOS root path
[OHOS ERROR] 2. run 'hb clean --all' or 'rm -rf out build/resources/args/.json'.
[OHOS ERROR] 3. repo sync
[OHOS ERROR] 4. repo forall -c 'git lfs pull'
[OHOS ERROR] 5. bash build/prebuilts_download.sh
[OHOS ERROR] 6. rebuild your product or component
[OHOS ERROR] 7. check if any environment variables required by the building process are not set in build/compile_env_allowlist.json
[OHOS ERROR]
[OHOS ERROR] If you still cannot solve this problem, you could post this problem on:
[OHOS ERROR] https://gitee.com/openharmony/build/issues
[OHOS ERROR]
=====build error=====

先从出现ERROR开始处分析一遍报错log,若无明显代码报错,可尝试:

sudo ./build.sh -p rk3568

sudo 命令在共用编译服务器慎用,以免影响其他人的编译环境。

若使用sudo编译通过,则说明与编译环境有关,可从以下几个方面处理:

  • 重新配置编译
  • 重装编译系统
  • 使用docker编辑编译,可参考博文:Docker 编译OpenHarmony 4.0 release

网友评论

 
 梦见老鼠咬手  最吉利的十种梦见蛇  梦见有人追跑躲藏害怕