openharmony编译时,出现OHOSException,ninja phase failed,具体错误经常变化
解决编译报错,但是报错位置,报错地方模糊的问题
- 环境:Ubuntu20.04,WSL,24GB内存,编译openharmony4.0Release版本,出现如下类似报错
ld.lld: warning: stack frame size (8336) exceeds limit (2048) in function 'get_exec_file_signature_info'
MODPOST vmlinux.symvers
WARNING: modpost: vmlinux.o(___ksymtab_gpl+rockchip_clk_register_armclk+0x0): Section mismatch in reference from the variable __ksymtab_rockchip_clk_register_armclk to the function .init.text:rockchip_clk_register_armclk()
The symbol rockchip_clk_register_armclk is exported and annotated __init
Fix this by removing the __init annotation of rockchip_clk_register_armclk or drop the export.
MODINFO modules.builtin.modinfo
GEN modules.builtin
LD .tmp_vmlinux.kallsyms1
KSYMS .tmp_vmlinux.kallsyms1.S
AS .tmp_vmlinux.kallsyms1.S
LD .tmp_vmlinux.kallsyms2
KSYMS .tmp_vmlinux.kallsyms2.S
AS .tmp_vmlinux.kallsyms2.S
LD vmlinux
SORTTAB vmlinux
SYSMAP System.map
OBJCOPY arch/arm64/boot/Image
LZ4 arch/arm64/boot/Image.lz4
E/write_index_tbl(1475): try to write index table...
E/write_index_tbl(1483): write_index_tbl 3
E/write_index_tbl(1498): try to write index entry(./arch/arm64/boot/dts/rockchip/rk3568-toybrick-x0-linux.dtb)...
E/write_index_tbl(1515): mod fdt path:./arch/arm64/boot/dts/rockchip/rk3568-toybrick-x0-linux.dtb -> rk-kernel.dtb...
E/write_index_tbl(1498): try to write index entry(logo.bmp)...
E/write_index_tbl(1498): try to write index entry(logo_kernel.bmp)...
Image: resource.img (with rk3568-toybrick-x0-linux.dtb logo.bmp logo_kernel.bmp) is ready
make[1]: Leaving directory '/home/om/ohos_40/out/kernel/OBJ/linux-5.10'
/home/om/ohos_40/out/rk3568
blocks = 4096 block_size 16384
/home/om/ohos_40/out/rk3568
kernel compile finish, save build info.
ninja: build stopped: subcommand failed.
[91m[OHOS ERROR][0m Traceback (most recent call last):
[91m[OHOS ERROR][0m File "/home/om/ohos_40/build/hb/services/ninja.py", line 49, in _execute_ninja_cmd
[91m[OHOS ERROR][0m SystemUtil.exec_command(
[91m[OHOS ERROR][0m File "/home/om/ohos_40/build/hb/util/system_util.py", line 63, in exec_command
[91m[OHOS ERROR][0m raise OHOSException(
[91m[OHOS ERROR][0m exceptions.ohos_exception.OHOSException: Please check build log in /home/om/ohos_40/out/rk3568/build.log
[91m[OHOS ERROR][0m
[91m[OHOS ERROR][0m During handling of the above exception, another exception occurred:
[91m[OHOS ERROR][0m
[91m[OHOS ERROR][0m Traceback (most recent call last):
[91m[OHOS ERROR][0m File "/home/om/ohos_40/build/hb/containers/status.py", line 47, in wrapper
[91m[OHOS ERROR][0m return func(*args, **kwargs)
[91m[OHOS ERROR][0m File "/home/om/ohos_40/build/hb/modules/ohos_build_module.py", line 67, in run
[91m[OHOS ERROR][0m raise exception
[91m[OHOS ERROR][0m File "/home/om/ohos_40/build/hb/modules/ohos_build_module.py", line 65, in run
[91m[OHOS ERROR][0m super().run()
[91m[OHOS ERROR][0m File "/home/om/ohos_40/build/hb/modules/interface/build_module_interface.py", line 72, in run
[91m[OHOS ERROR][0m raise exception
[91m[OHOS ERROR][0m File "/home/om/ohos_40/build/hb/modules/interface/build_module_interface.py", line 70, in run
[91m[OHOS ERROR][0m self._target_compilation()
[91m[OHOS ERROR][0m File "/home/om/ohos_40/build/hb/modules/ohos_build_module.py", line 103, in _target_compilation
[91m[OHOS ERROR][0m self.target_compiler.run()
[91m[OHOS ERROR][0m File "/home/om/ohos_40/build/hb/services/ninja.py", line 38, in run
[91m[OHOS ERROR][0m self._execute_ninja_cmd()
[91m[OHOS ERROR][0m File "/home/om/ohos_40/build/hb/services/ninja.py", line 52, in _execute_ninja_cmd
[91m[OHOS ERROR][0m raise OHOSException('ninja phase failed', '4000')
[91m[OHOS ERROR][0m exceptions.ohos_exception.OHOSException: ninja phase failed
[91m[OHOS ERROR][0m
[91m[OHOS ERROR][0m Code: 4000
[91m[OHOS ERROR][0m
[91m[OHOS ERROR][0m Reason: ninja phase failed
[91m[OHOS ERROR][0m
[91m[OHOS ERROR][0m Solution: Please check the compile log at out/{compiling product}/build.log, If you could analyze build logs.
[91m[OHOS ERROR][0m Or you can try the following steps to solve this problem:
[91m[OHOS ERROR][0m 1. cd to OHOS root path
[91m[OHOS ERROR][0m 2. run 'hb clean --all' or 'rm -rf out build/resources/args/*.json'.
[91m[OHOS ERROR][0m 3. repo sync
[91m[OHOS ERROR][0m 4. repo forall -c 'git lfs pull'
[91m[OHOS ERROR][0m 5. bash build/prebuilts_download.sh
[91m[OHOS ERROR][0m 6. rebuild your product or component
[91m[OHOS ERROR][0m
[91m[OHOS ERROR][0m If you still cannot solve this problem, you could post this problem on:
[91m[OHOS ERROR][0m https://gitee.com/openharmony/build/issues
[91m[OHOS ERROR][0m
增加虚拟内存
- 主要是编译时内存不够的问题,增加虚拟内存,取消BTF_debug配置
- 增加wsl的虚拟内存,在 C:\Users\用户名 下,增加 .wslconfig 文件,配置如下
[wsl2]
memory=20GB
swap=32GB
localhostForwarding=true
取消BTF配置
- 取消BTF配置,BTF在编译时会占用大量内存。
- 配置文件中的CONFIG_DEBUG_INFO_BTF字段可以用来选择是否开启调试信息
- 具体配置路径 \wsl.localhost\Ubuntu-20.04\home\{linux用户名}\{openharmony仓库名称}\kernel\linux\config\linux-5.10\rk3568\arch\arm64_defconfig文件
# 将如下配置更改为:(没有就增加)
CONFIG_DEBUG_INFO_BTF=m
CONFIG_SYSTEM_TRUSTED_KEYS=""
CONFIG_TEST_BLACKHOLD=m
参考: https://blog.csdn.net/qq_35616222/article/details/120358499