buildroot 下增加新的编译程序

buildroot 下增加新的编译程序

开发环境

rv1109 官方sdk -自带buildroot
pc:ubuntu20.04

目标

使用buildroot 编译主机上(ubuntu)运行的prelink 软件

操作过程

增加prelink-cross

  1. 在/buildroot/package 目录下建立 prelink-cross 文件夹
    文件夹中创建Config.in ,prelink.mk ,prelink.conf 文件
    内容分别为

Config.in

config BR2_PACKAGE_PRELINK_CROSS
	bool "prelink-cross"
	depends on BR2_PACKAGE_BINUTILS
	
	help
	  Prelinking is the process of pre-computing the load addresses and link
	  tables generated by the dynamic linker as compared to doing this at
	  runtime. Doing this ahead of time results in performance improvements
	  when the application is launched.
	  By providing an emulated runtime dynamic linker, the cross-prelink
	  project extends the prelink software's ability to prelink a sysroot
	  environment. Additionally, the cross-prelink software enables the
	  ability to work in sysroot style environments.

prelink.mk

# prelink-cross
#
# A prelinker which can run on the host and emulate ld.so of
# the target, to support prelinking of cross-compiled binaries.
#
PRELINK_CROSS_VERSION=20151030_cross
PRELINK_CROSS_SITE=https://git.yoctoproject.org/prelink-cross
PRELINK_CROSS_SITE_METHOD = git
PRELINK_CROSS_SOURCE=prelink-cross-${PRELINK_CROSS_VERSION}.tar.gz

HOST_PRELINK_CROSS_AUTORECONF = YES
#PRELINK_CROSS_AUTORECONF = YES

HOST_PRELINK_CROSS_DEPENDENCIES = host-elfutils host-binutils 
##PRELINK_CROSS_DEPENDENCIES = libelf binutils   # 使用的是外部工具链,不用增加elf , binutils

PRELINK_CROSS_INSTALL_HOST=YES
#PRELINK_CROSS_INSTALL_TARGET=YES

define PRELINK_CROSS_INSTALL_CONF
	$(INSTALL) -m 0755 -D package/prelink-cross/prelink.conf ${TARGET_DIR}/etc/prelink.conf
endef
ifeq ($(BR2_TOOLCHAIN_USES_UCLIBC),y)
PRELINK_CMD="${HOST_DIR}/usr/sbin/prelink --verbose --config-file /etc/prelink.conf --cache-file /etc/prelink.cache --root=${TARGET_DIR} --ld-library-path=/lib:/usr/lib:/usr/local/lib:/chrome/lib:/chrome:/usr/local/lib/webkitGl3:/app/client --dynamic-linker=/lib/ld-uClibc.so.0 --all"
else
PRELINK_CMD="${HOST_DIR}/usr/sbin/prelink --verbose --config-file /etc/prelink.conf --cache-file /etc/prelink.cache --root=${TARGET_DIR} --ld-library-path=/lib:/usr/lib:/usr/local/lib:/chrome/lib:/chrome:/usr/local/lib/webkitGl3:/app/client --all"
endif

HOST_PRELINK_CROSS_POST_INSTALL_HOOKS += PRELINK_CROSS_INSTALL_CONF
#PRELINK_CROSS_POST_INSTALL_HOOKS += PRELINK_CROSS_INSTALL_CONF

# The point of prelink-cross is to run it on the host. We deliberately do not
# provide a way to compile it for the target, only the host.
$(eval $(host-autotools-package))
#$(eval $(autotools-package))

prelink 只编译 pc上使用的版本,不编译在arm运行的,所以$(eval $(autotools-package)) 相关的内容不打开

prelink.conf

-l /lib
-l /usr/lib
-l /usr/local/lib
-l /bin
-l /sbin
-l /usr/bin
-l /usr/sbin
-l /usr/local/bin
-l /chrome/lib
-l /usr/local/lib/webkitGl3
-l /usr/local/bin/webkitGl3
-l /app/client

注意事项

HOST_PRELINK_CROSS_DEPENDENCIES = host-elfutils host-binutils
elf 与binnutils (gcc 编译器相关的)

  1. 在package 目录下的Config.in 增加(放在menu “Development tools” 下)
	source "package/prelink-cross/Config.in"
  1. 在SDK的主目录
./build.sh -h rootfs
source envsetup.sh rockchip_rv1126_rv1109_facial_gate
make

执行 source envsetup.sh rockchip_rv1126_rv1109_facial_gate
进入buildroot 目录下 开如编译prelink,执行

make host-prelink-cross-rebuild

会自动编译依赖的库,如libelf liberty
编译期间可能会有报错,我这里编译bzip2时编译,报错的大意是下载的bzip源码解压格式错误,一看发现下载下来的文件为空,再检查发现下载路径错误 ,下方为修改后的BZIP2_SITE

bzip2/bzip2.mk:8:BZIP2_SITE = https://sourceware.org/pub/bzip2

另外发现报缺少 liberty

.....al_gate/host/lib -liberty -lselinux -lelf
/usr/bin/ld: cannot find -liberty
collect2: error: ld returned 1 exit status

libiberty 库对应的源码为binutils
到对应的目录找,看是否生成libiberty

buildroot/output/rockchip_rv1126_rv1109_facial_gate/build/host-binutils-2.32/libiberty

发现已经生成了libiberty.a,但是编译install 时没有安装到

buildroot/output/rockchip_rv1126_rv1109_facial_gate/host/lib

这个路径 下,修改 package/binutils/binutils.mk

HOST_BINUTILS_CONF_OPTS = \
	--disable-multilib \
	--disable-werror \
	--target=$(GNU_TARGET_NAME) \
	--enable-install-libiberty \
	--disable-shared \
	--enable-static \
	--with-sysroot=$(STAGING_DIR) \
	--enable-poison-system-directories \
	$(BINUTILS_DISABLE_GDB_CONF_OPTS) \
	$(BINUTILS_EXTRA_CONFIG_OPTIONS)

增加–enable-install-libiberty
重新编译

make host-binutils-rebuild

发现还是没有把libiberty.a install 到对应路径 ,编译prelink时还是提示找不到对应的libiberty 库。

手动copy libiberty.a 到buildroot/output/rockchip_rv1126_rv1109_facial_gate/host/lib 重新编译 prelink 成功

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值