Browse Source

toolchain: add cross prelinking tool from yoctoproject and hook it into build system

Phil Sutter 4 years ago
parent
commit
b35d932816

+ 14 - 1
mk/image.mk

@@ -37,7 +37,7 @@ else
 $(error No login shell configured!)
 endif
 
-imageprepare: image-prepare-post extra-install
+imageprepare: image-prepare-post extra-install prelink
 
 # if an extra directory exist in ADK_TOPDIR, copy all content over the 
 # root directory, do the same if make extra=/dir/to/extra is used
@@ -79,6 +79,19 @@ ifneq ($(ADK_TARGET_ARCH_AARCH64)$(ADK_TARGET_ARCH_X86_64)$(ADK_TARGET_ARCH_PPC6
 	(cd ${TARGET_DIR}/usr ; ln -sf ${ADK_TARGET_LIBC_PATH} lib)
 endif
 
+ifeq (${ADK_PRELINK},)
+prelink:
+else
+${TARGET_DIR}/etc/prelink.conf:
+	echo '/' > $@
+
+prelink: ${TARGET_DIR}/etc/prelink.conf
+	$(TRACE) target/prelink
+	${TARGET_CROSS}prelink ${ADK_PRELINK_OPTS} \
+		--ld-library-path=${STAGING_TARGET_DIR}/usr/lib:${STAGING_TARGET_DIR}/lib \
+		--root=${TARGET_DIR} -a $(MAKE_TRACE)
+endif
+
 KERNEL_PKGDIR:=$(LINUX_BUILD_DIR)/kernel-pkg
 KERNEL_PKG:=$(PACKAGE_DIR)/kernel_$(KERNEL_VERSION)_$(ADK_TARGET_CPU_ARCH).$(PKG_SUFFIX)
 TARGET_KERNEL=		${ADK_TARGET_SYSTEM}-${ADK_TARGET_FS}-kernel

+ 12 - 0
target/config/Config.in.adk

@@ -110,4 +110,16 @@ config ADK_HOST_CYGWIN
 	bool "Cygwin"
 
 endchoice
+
+config ADK_PRELINK
+	prompt "Prelink binaries and libraries in Image"
+	boolean
+	help
+	  Do prelinking for faster loading of binaries.
+
+config ADK_PRELINK_OPTS
+	string "additional options to pass to prelink"
+	default "-mR"
+	depends on ADK_PRELINK
+
 endmenu

+ 3 - 0
toolchain/Makefile

@@ -44,6 +44,9 @@ ifeq ($(ADK_TARGET_ARCH_ARC),)
 TARGETS+=gdb
 GDB:=gdb-install
 endif
+ifeq (${ADK_PRELINK},y)
+TARGETS+=prelink-cross
+endif
 
 DOWNLOAD:=kernel-headers-download $(patsubst %,%-download,$(TARGETS))
 TARGETS_INSTALL:=$(patsubst %,%-install,$(TARGETS))

+ 1 - 0
toolchain/prelink-cross/Config.in

@@ -0,0 +1 @@
+

+ 34 - 0
toolchain/prelink-cross/Makefile

@@ -0,0 +1,34 @@
+# This file is part of the OpenADK project. OpenADK is copyrighted
+# material, please see the LICENCE file in the top-level directory.
+
+include $(ADK_TOPDIR)/rules.mk
+include ../rules.mk
+include Makefile.inc
+include ${ADK_TOPDIR}/mk/buildhlp.mk
+
+$(WRKBUILD)/.headers:
+$(WRKBUILD)/.configured:
+	(cd $(WRKBUILD)/trunk; \
+		./configure \
+		--prefix=$(STAGING_HOST_DIR) \
+		--build=$(GNU_HOST_NAME) \
+		--host=$(GNU_HOST_NAME) \
+		--target=$(REAL_GNU_TARGET_NAME) \
+		--disable-dependency-tracking \
+		--disable-libtool-lock \
+		--with-gnu-ld \
+	);
+	touch $@
+
+$(WRKBUILD)/.compiled:
+	$(MAKE) -C $(WRKBUILD)/trunk CFLAGS="-fPIC ${CFLAGS_FOR_BUILD}"
+	touch $@
+
+$(WRKBUILD)/.installed:
+	install -c ${WRKBUILD}/trunk/src/prelink \
+		${TARGET_CROSS}prelink
+	install -c ${WRKBUILD}/trunk/src/prelink-rtld \
+		${TARGET_CROSS}prelink-rtld
+	touch $@
+
+include ${ADK_TOPDIR}/mk/toolchain.mk

+ 8 - 0
toolchain/prelink-cross/Makefile.inc

@@ -0,0 +1,8 @@
+# This file is part of the OpenADK project. OpenADK is copyrighted
+# material, please see the LICENCE file in the top-level directory.
+
+# this is branch cross_prelink_r185 in git
+PKG_NAME:=	prelink-cross
+PKG_VERSION:=	909470ee441237563d6236c505cb2d02ddc48704
+PKG_RELEASE:=	1
+PKG_SITES:=	git://git.yoctoproject.org/prelink-cross