Преглед изворни кода

strip toolchain components without copying debug data, clean toolchain after every target so no 300Gb are required to bulk build the toolchains

Waldemar Brodkorb пре 11 година
родитељ
комит
16fb226839
7 измењених фајлова са 34 додато и 13 уклоњено
  1. 3 0
      Makefile
  2. 12 2
      mk/build.mk
  3. 11 3
      scripts/rstrip.sh
  4. 2 2
      toolchain/eglibc/Makefile
  5. 2 2
      toolchain/glibc/Makefile
  6. 2 2
      toolchain/musl/Makefile
  7. 2 2
      toolchain/uClibc/Makefile

+ 3 - 0
Makefile

@@ -104,6 +104,9 @@ cleantarget targetclean: .prereq_done
 	-@${GMAKE_INV} cleantarget
 	@-rm -f make.log
 
+cleantoolchain toolchainclean: .prereq_done
+	-@${GMAKE_INV} cleantoolchain
+
 distclean cleandist:
 	-@${GMAKE_INV} distclean
 	@-rm -f make.log .prereq_done

+ 12 - 2
mk/build.mk

@@ -141,7 +141,7 @@ ${TOPDIR}/package/Depends.mk: ${TOPDIR}/.config $(wildcard ${TOPDIR}/package/*/M
 	$(STAGING_HOST_DIR)/usr/bin/depmaker > ${TOPDIR}/package/Depends.mk
 
 .NOTPARALLEL:
-.PHONY: all world clean cleantarget cleandir distclean image_clean
+.PHONY: all world clean cleantarget cleandir cleantoolchain distclean image_clean
 
 world:
 	mkdir -p $(DISTDIR) $(BUILD_DIR) $(TARGET_DIR) $(FW_DIR) \
@@ -275,6 +275,15 @@ cleandir:
 	rm -rf $(STAGING_TARGET_DIR_PFX) $(STAGING_PKG_DIR_PFX)
 	rm -f .menu .tmpconfig.h .rebuild* ${TOPDIR}/package/Depends.mk ${TOPDIR}/prereq.mk
 
+cleantoolchain:
+	@$(TRACE) cleantoolchain
+	@$(MAKE) -C $(CONFIG) clean $(MAKE_TRACE) 
+	rm -rf $(BUILD_DIR_PFX) $(TARGET_DIR_PFX) \
+	    ${TOPDIR}/package/pkglist.d ${TOPDIR}/package/pkgconfigs.d
+	rm -rf $(TOOLCHAIN_BUILD_DIR_PFX) $(STAGING_HOST_DIR_PFX) $(TOOLS_BUILD_DIR)
+	rm -rf $(STAGING_TARGET_DIR_PFX) $(STAGING_PKG_DIR_PFX)
+	rm -f .menu .tmpconfig.h .rebuild* ${TOPDIR}/package/Depends.mk ${TOPDIR}/prereq.mk
+
 cleantarget:
 	@$(TRACE) cleantarget
 	@$(MAKE) -C $(CONFIG) clean $(MAKE_TRACE)
@@ -535,7 +544,8 @@ bulktoolchain:
 			$(GMAKE) prereq && \
 				$(GMAKE) ARCH=$$tarch SYSTEM=toolchain-$$arch LIBC=$$libc defconfig; \
 				$(GMAKE) VERBOSE=1 all; if [ $$? -ne 0 ]; then touch .exit;fi; \
-				tar -cvJf ${TOPDIR}/firmware/toolchain_$${arch}_$${libc}.tar.xz host_$${arch}_*_$${libc} target_$${arch}_*_$${libc}; \
+				tar -cvJf ${TOPDIR}/firmware/toolchain_$${arch}_$${libc}.tar.xz host_* target_$${arch}_$${libc}_*; \
+				$(GMAKE) cleantoolchain; \
 			rm .config; \
 		    ) 2>&1 | tee $(TOPDIR)/firmware/toolchain_$${arch}_$${libc}/build.log; \
 		    if [ -f .exit ];then break;fi \

+ 11 - 3
scripts/rstrip.sh

@@ -5,6 +5,10 @@
 
 SELF=${0##*/}
 
+if [[ -z $debug ]];then
+	debug=1
+fi
+
 if [[ -z $prefix ]]; then
 	echo >&2 "$SELF: strip command not defined ('prefix' variable not set)"
 	exit 1
@@ -60,9 +64,13 @@ find $TARGETS -type f -a -exec file {} \; | \
 	echo "$SELF: $V:$S"
 	echo "-> $T $F"
 	eval "chmod u+w $F"
-	eval "mkdir -p $D/usr/lib/debug/$Q"
-	eval "$O --only-keep-debug $F $D/usr/lib/debug/$P.debug"
+	if [[ $debug -eq 1 ]];then
+		eval "mkdir -p $D/usr/lib/debug/$Q"
+		eval "$O --only-keep-debug $F $D/usr/lib/debug/$P.debug"
+	fi
 	eval "$T $F"
-	eval "cd $D/usr/lib/debug/$Q && $O --add-gnu-debuglink=$R.debug $F"
+	if [[ $debug -eq 1 ]];then
+		eval "cd $D/usr/lib/debug/$Q && $O --add-gnu-debuglink=$R.debug $F"
+	fi
 done
 exit 0

+ 2 - 2
toolchain/eglibc/Makefile

@@ -92,8 +92,8 @@ $(WRKBUILD)/.fixup:
 	-find $(STAGING_TARGET_DIR) -type -f -name \*_pic\* -delete
 	rm -rf $(STAGING_TARGET_DIR)/usr/share/locale $(STAGING_TARGET_DIR)/usr/share/i18n
 	rm -rf $(STAGING_TARGET_DIR)/usr/lib/gconv
-	PATH="$(TARGET_PATH)" prefix='${TARGET_CROSS}' ${BASH} ${SCRIPT_DIR}/rstrip.sh $(STAGING_TARGET_DIR)
-	prefix=' ' ${BASH} ${SCRIPT_DIR}/rstrip.sh $(STAGING_HOST_DIR)
+	PATH="$(TARGET_PATH)" debug='' prefix='${TARGET_CROSS}' ${BASH} ${SCRIPT_DIR}/rstrip.sh $(STAGING_TARGET_DIR)
+	debug='' prefix=' ' ${BASH} ${SCRIPT_DIR}/rstrip.sh $(STAGING_HOST_DIR)
 	touch $@
 
 include ${TOPDIR}/mk/toolchain.mk

+ 2 - 2
toolchain/glibc/Makefile

@@ -73,8 +73,8 @@ $(WRKBUILD)/.fixup:
 	-find $(STAGING_TARGET_DIR) -type f -name \*_pic\* -delete
 	rm -rf $(STAGING_TARGET_DIR)/usr/share/locale $(STAGING_TARGET_DIR)/usr/share/i18n
 	rm -rf $(STAGING_TARGET_DIR)/usr/lib/gconv
-	PATH="$(TARGET_PATH)" prefix='${TARGET_CROSS}' ${BASH} ${SCRIPT_DIR}/rstrip.sh $(STAGING_TARGET_DIR)
-	prefix=' ' ${BASH} ${SCRIPT_DIR}/rstrip.sh $(STAGING_HOST_DIR)
+	PATH="$(TARGET_PATH)" debug='' prefix='${TARGET_CROSS}' ${BASH} ${SCRIPT_DIR}/rstrip.sh $(STAGING_TARGET_DIR)
+	debug='' prefix=' ' ${BASH} ${SCRIPT_DIR}/rstrip.sh $(STAGING_HOST_DIR)/bin $(STAGING_HOST_DIR)/$(GNU_TARGET_NAME)/
 	touch $@
 
 include ${TOPDIR}/mk/toolchain.mk

+ 2 - 2
toolchain/musl/Makefile

@@ -59,8 +59,8 @@ $(WRKBUILD)/.fixup:
 	$(MAKE) -C $(WRKBUILD) DESTDIR=$(STAGING_TARGET_DIR) install
 	# cleanup toolchain
 	-find $(STAGING_TARGET_DIR) $(STAGING_HOST_DIR) -name \*.la -delete
-	PATH="$(TARGET_PATH)" prefix='${TARGET_CROSS}' ${BASH} ${SCRIPT_DIR}/rstrip.sh $(STAGING_TARGET_DIR)
-	prefix=' ' ${BASH} ${SCRIPT_DIR}/rstrip.sh $(STAGING_HOST_DIR)
+	PATH="$(TARGET_PATH)" debug='' prefix='${TARGET_CROSS}' ${BASH} ${SCRIPT_DIR}/rstrip.sh $(STAGING_TARGET_DIR)
+	debug='' prefix=' ' ${BASH} ${SCRIPT_DIR}/rstrip.sh $(STAGING_HOST_DIR)
 	touch $@
 
 include ${TOPDIR}/mk/toolchain.mk

+ 2 - 2
toolchain/uClibc/Makefile

@@ -120,8 +120,8 @@ endif
 	ln -s libc.so.0 $(STAGING_TARGET_DIR)/lib/libc.so
 	# cleanup toolchain
 	-find $(STAGING_TARGET_DIR) $(STAGING_HOST_DIR) -name \*.la -delete
-	PATH="$(TARGET_PATH)" prefix='${TARGET_CROSS}' ${BASH} ${SCRIPT_DIR}/rstrip.sh $(STAGING_TARGET_DIR)
-	prefix=' ' ${BASH} ${SCRIPT_DIR}/rstrip.sh $(STAGING_HOST_DIR)
+	PATH="$(TARGET_PATH)" debug='' prefix='${TARGET_CROSS}' ${BASH} ${SCRIPT_DIR}/rstrip.sh $(STAGING_TARGET_DIR)
+	debug='' prefix=' ' ${BASH} ${SCRIPT_DIR}/rstrip.sh $(STAGING_HOST_DIR)
 	touch $@
 
 include ${TOPDIR}/mk/toolchain.mk