Commit 9ab4e56e authored by Eric Andersen's avatar Eric Andersen
Browse files

Add support for mklibs (strips unused syms from shared libs such as uClibc)

based on a patch from akvadrako, and using a version of mklibs.py that was
massively hacked up by andersee and mjn3 for uClibc support.
parent 54044da9
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ source "toolchain/gcc/Config.in"
source "toolchain/ccache/Config.in"
source "toolchain/gdb/Config.in"
source "toolchain/elf2flt/Config.in"
source "toolchain/mklibs/Config.in"

comment "Common Toolchain Options"

+6 −0
Original line number Diff line number Diff line
config BR2_MKLIBS
	bool "Run mklibs on the built root filesystem"
	default n
	help
	  Recompiles all the shared libraries to only include the
	  symbols actually needed to run the binaries on the target
+49 −0
Original line number Diff line number Diff line
######################################################################
#
# mklibs
#
######################################################################
MKLIBS_PROGRAM:=$(STAGING_DIR)/bin/mklibs.py

$(MKLIBS_PROGRAM): toolchain/mklibs/mklibs.py
	cp -a toolchain/mklibs/mklibs.py $@

mklibs-clean:
	rm -f $(MKLIBS_PROGRAM)

mklibs-dirclean:
	true

#############################################################
#
# Run mklibs
#
#############################################################
MKLIBS_PYTHON:=$(shell which python)
ifeq ($(MKLIBS_PYTHON),)
    MKLIBS_PYTHON=/usr/bin/python
endif

$(STAGING_DIR)/mklibs-stamp: $(MKLIBS_PROGRAM) $(MKLIBS_PYTHON) $(STAGING_DIR)/lib/*
	find $(TARGET_DIR) -type f -perm +100 -exec \
	    file -r -N -F '' {} + | \
	    awk ' /executable.*dynamically/ { print $$1 }' > $(STAGING_DIR)/mklibs-progs
	cd $(TARGET_DIR); PATH=$(PATH):$(STAGING_DIR)/bin $(MKLIBS_PYTHON) $(MKLIBS_PROGRAM) \
	    --target $(REAL_GNU_TARGET_NAME) --root $(STAGING_DIR) -d ./ \
	    `cat $(STAGING_DIR)/mklibs-progs`
	touch $@

# this empty target allows a mklibs dependeny to be included in the
# target targets, but it will be only invoked if BR2_MKLIBS is conf'ed
.PHONY: mklibs
mklibs:

#############################################################
#
# Toplevel Makefile options
#
#############################################################

ifeq ($(strip $(BR2_MKLIBS)),y)
mklibs: $(STAGING_DIR)/mklibs-stamp
endif
+597 −0

File added.

Preview size limit exceeded, changes collapsed.