2024年6月29日 星期六

[OpenWRT] Missing lto (liblto_plugin.so)

1. 少了lto
plugin needed to handle lto object
這其實是一個error,但卻沒顯示error,還把.a建出來,他的意思是組libubusd_library.a時找不到liblto_plugin.so
[ 62%] Linking C static library libubusd_library.a
toolchain-aarch64_xxx/bin/aarch64-openwrt-linux-ar: CMakeFiles/ubusd_library.dir/ubusd.c.o: plugin needed to handle lto object
toolchain-aarch64_xxx/bin/aarch64-openwrt-linux-ar: CMakeFiles/ubusd_library.dir/ubusd_proto.c.o: plugin needed to handle lto object
toolchain-aarch64_xxx/bin/aarch64-openwrt-linux-ar: CMakeFiles/ubusd_library.dir/ubusd_id.c.o: plugin needed to handle lto object


2. 組libubusd_library.a的命令在ubus-2019-12-27-041c9d1c/CMakeFiles/ubusd_library.dir/link.txt
(可用nm libubusd_library.a確認內容)

正確的用: aarch64-openwrt-linux-gcc-ar
錯誤的用: aarch64-openwrt-linux-ar (少了gcc)

因為在rule.mk有bug
正確的rule.mk

```makefile
ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
TARGET_AR:=$(TARGET_CROSS)gcc-ar
TARGET_RANLIB:=$(TARGET_CROSS)gcc-ranlib
TARGET_NM:=$(TARGET_CROSS)gcc-nm
else
TARGET_AR:=$(TARGET_CROSS)gcc-ar
TARGET_RANLIB:=$(TARGET_CROSS)gcc-ranlib
TARGET_NM:=$(TARGET_CROSS)gcc-nm
endif
```

錯誤的rule.mk

```makefile
ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
TARGET_AR:=$(TARGET_CROSS)gcc-ar
TARGET_RANLIB:=$(TARGET_CROSS)gcc-ranlib
TARGET_NM:=$(TARGET_CROSS)gcc-nm
else
TARGET_AR:=$(TARGET_CROSS)ar
TARGET_RANLIB:=$(TARGET_CROSS)ranlib
TARGET_NM:=$(TARGET_CROSS)nm
endif
```


沒有留言:

張貼留言