问题1:
[OHOS ERROR] (.text.Reset_Handler+0x2e): undefined reference to `__libc_init_array'
__libc_init_array在startup_stm32f407xx.s中,看字面意思像是对C库的初始化。
我现在用的是musl的C库。也可以在startup_stm32f407xx.s中注释掉相关语句。
/* Call the clock system intitialization function.*/
bl SystemInit
/* Call static constructors */
/* bl __libc_init_array */
/* Call the application's entry point.*/
bl main
bx lr
.size Reset_Handler, .-Reset_Handler
hb build之后问题没有出现。
问题2
[OHOS ERROR] stm32f4xx_hal_rcc.c:(.text.HAL_RCC_GetSysClockFreq+0x34): undefined reference to `__aeabi_uldivmod'
[OHOS ERROR] collect2: error: ld returned 1 exit status
__aeabi_uldivmod,网上查资料说跟除法有关。本次我开的是软除法,没有开硬件除法。英文用用的musl不支持cortex-m4的除法。因为一下错误:
Error: selected FPU does not support instruction -- `vabs.f64 d0,d0'
cortex-m4只支持vabs.f32指令
放弃musl库,使用gcc标准C库
问题:XTS移植
[OHOS INFO] The variable "enable_ohos_test_xts_acts_use_thirdparty_lwip" was set as a build argument
[OHOS INFO] but never appeared in a declare_args() block in any buildfile.
[OHOS INFO]
[OHOS INFO] To view all possible args, run "gn args --list <out_dir>"
[OHOS INFO]
[OHOS INFO] The build continued as if that argument was unspecified.
enable_ohos_test_xts_acts_use_thirdparty_lwip被设置成了编译参数,但是在编译文件中没有出现enable_ohos_test_xts_acts_use_thirdparty_lwip。
根据提示运行:
gn args -list out/tunnel_box/tunnel/
...
build_xts
Current value (from the default) = false
From //build/config/BUILDCONFIG.gn:255
...
is_debug
Current value (from the default) = false
From //build/config/BUILDCONFIG.gn:251
Debug build. Enabling official builds automatically sets is_debug to false.
发现两个有趣的参数build_xts和is_debug都是false。
根据XTS官网文档的说法“debug版本编译时会同步编译acts测试套件”。所以is_debug应该是ture。
build_xts根据面意思应该也是true。
根据提示位置,找到is_debug和build_xts赋值为true。
declare_args() {
# Debug build. Enabling official builds automatically sets is_debug to false.
is_debug = true
}
declare_args() {
build_xts = true
}
重启hb build之后,提示
[OHOS INFO] c targets overlap rate statistics
[OHOS INFO] subsystem files NO. percentage builds NO. percentage overlap rate
[OHOS INFO] kernel 39 19.7% 39 19.7% 1.00
[OHOS INFO] securec 39 19.7% 39 19.7% 1.00
[OHOS INFO] test 2 1.0% 2 1.0% 1.00
[OHOS INFO] third_party 127 64.1% 127 64.1% 1.00
[OHOS INFO] xts 2 1.0% 2 1.0% 1.00
[OHOS INFO]
[OHOS INFO] c overall build overlap rate: 1.00
确实有效果,多了一个xts的subsystem。且在out/tunnel_box/tunnel/libs/目录下libhctest.a文件。与官方说法一致。