1
0
Просмотр исходного кода

simplify toolchain building

Buildroot uses the two-stage mechanism since a while.
This reduces the build time a lot. Instead of three stages,
we just use the two-stage build. The benefit is that
the C library do not need to be rebuild and one gcc compile
is obsolete. Tested with embedded-test.sh.

There is one unresolved problem, tile toolchain
building is broken.
Waldemar Brodkorb 9 лет назад
Родитель
Сommit
f06aece697

+ 3 - 3
mk/build.mk

@@ -173,12 +173,12 @@ world:
 	${BASH} ${ADK_TOPDIR}/scripts/scan-pkgs.sh
 ifeq ($(ADK_TARGET_TOOLCHAIN),y)
 ifeq ($(ADK_TOOLCHAIN_ONLY),y)
-	$(MAKE) -f mk/build.mk package/hostcompile toolchain/fixup package/compile
+	$(MAKE) -f mk/build.mk package/hostcompile toolchain/final package/compile
 else
-	$(MAKE) -f mk/build.mk package/hostcompile toolchain/fixup package/compile root_clean package/install
+	$(MAKE) -f mk/build.mk package/hostcompile toolchain/final package/compile root_clean package/install
 endif
 else
-	$(MAKE) -f mk/build.mk package/hostcompile toolchain/fixup target/config-prepare target/compile package/compile root_clean package/install target/install package_index
+	$(MAKE) -f mk/build.mk package/hostcompile toolchain/final target/config-prepare target/compile package/compile root_clean package/install target/install package_index
 endif
 
 package_index:

+ 2 - 2
mk/toolchain.mk

@@ -1,7 +1,7 @@
-prepare: ${WRKDIST}/.prepared $(WRKBUILD)/.headers
+prepare: ${WRKDIST}/.prepared
 configure: ${WRKBUILD}/.configured
 compile: $(WRKBUILD)/.compiled
 install: $(WRKBUILD)/.installed
-fixup: $(WRKBUILD)/.fixup
+final: $(WRKBUILD)/.final
 clean:
 	rm -rf $(WRKDIR)

+ 3 - 3
package/libgcc/Makefile

@@ -33,16 +33,16 @@ libgcc-install:
 	$(INSTALL_DIR) ${IDIR_LIBGCC}/$(ADK_TARGET_LIBC_PATH)
 ifeq ($(ADK_TARGET_ARCH_SH),y)
 ifeq ($(ADK_CPU_SH3),y)
-	${CP} ${STAGING_TARGET_DIR}/lib/!m3*/libgcc*.so* ${IDIR_LIBGCC}/$(ADK_TARGET_LIBC_PATH)
+	${CP} ${STAGING_TARGET_DIR}/usr/lib/!m3*/libgcc*.so* ${IDIR_LIBGCC}/$(ADK_TARGET_LIBC_PATH)
 endif
 ifeq ($(ADK_CPU_SH4),y)
-	${CP} ${STAGING_TARGET_DIR}/lib/!m4*/libgcc*.so* ${IDIR_LIBGCC}/$(ADK_TARGET_LIBC_PATH)
+	${CP} ${STAGING_TARGET_DIR}/usr/lib/!m4*/libgcc*.so* ${IDIR_LIBGCC}/$(ADK_TARGET_LIBC_PATH)
 endif
 else
 ifeq ($(ADK_TARGET_ARCH_AVR32),)
 ifeq ($(ADK_TARGET_BINFMT_FLAT),)
 ifeq ($(ADK_TARGET_USE_STATIC_LIBS),)
-	${CP} ${STAGING_TARGET_DIR}/lib/libgcc*.so* ${IDIR_LIBGCC}/$(ADK_TARGET_LIBC_PATH)
+	${CP} ${STAGING_TARGET_DIR}/usr/lib/libgcc*.so* ${IDIR_LIBGCC}/$(ADK_TARGET_LIBC_PATH)
 endif
 endif
 endif

+ 1 - 0
target/config/Config.in.binfmt

@@ -41,6 +41,7 @@ default ADK_TARGET_BINFMT_FLAT_ONE
 
 config ADK_TARGET_BINFMT_FLAT_ONE
 	bool "One memory region"
+	depends on ADK_TARGET_ARCH_BFIN
 	help
 	  All segments are linked into one memory region.
 

+ 4 - 0
target/config/Config.in.gcc

@@ -86,5 +86,9 @@ config ADK_TOOLCHAIN_GCC_4_2_4
 	bool "4.2.4"
 	depends on ADK_TARGET_ARCH_METAG
 	select ADK_DISABLE_HONOUR_CFLAGS
+	select ADK_TOOLCHAIN_GCC_OLD
 
 endchoice
+
+config ADK_TOOLCHAIN_GCC_OLD
+	bool

+ 13 - 18
toolchain/Makefile

@@ -4,14 +4,11 @@
 # Steps to build toolchains
 # 1) build and install binutils
 # 2) build and install mpfr, mpc, libelf and gmp
-# 3) build and install minimal gcc c compiler
+# 3) build and install initial gcc
 # 4) install kernel-headers
-# 5) install libc headers
-# 6) build and install initial static gcc
-# 7) build and install full libc
-# 8) build and install full shared gcc
-# 9) rebuild and install full libc (in case of musl/uclibc)
-# 10) build and install gdb debugger
+# 5) build and install full libc
+# 6) build and install full gcc
+# 7) build and install gdb debugger
 
 include $(ADK_TOPDIR)/rules.mk
 
@@ -46,20 +43,18 @@ endif
 
 DOWNLOAD:=kernel-headers-download $(patsubst %,%-download,$(TARGETS))
 TARGETS_INSTALL:=$(patsubst %,%-install,$(TARGETS))
-FIXUP:=$(patsubst %,%-fixup,$(CLIB))
+FINAL:=$(patsubst %,%-final,gcc)
 TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS))
 
 install: $(TARGETS_INSTALL)
 clean: $(TARGETS_CLEAN)
 download: $(DOWNLOAD)
-fixup: $(FIXUP)
+final: $(FINAL)
 
-gcc-prepare: binutils-install gmp-install mpfr-install mpc-install libelf-install
-$(CLIB)-prepare: gcc-prepare kernel-headers-prepare
-gcc-configure: $(CLIB)-prepare
-$(CLIB)-compile: gcc-configure
-gcc-compile: $(CLIB)-install
-$(CLIB)-fixup: gcc-install $(GDB) $(ELF2FLT)
+gcc-configure: binutils-install gmp-install mpfr-install mpc-install libelf-install
+$(CLIB)-install: gcc-configure kernel-headers-configure
+gcc-install: $(CLIB)-install
+gcc-final: gcc-install $(GDB) $(ELF2FLT)
 
 %-download:
 	$(TRACE) toolchain/$(patsubst %-download,%,$@)/download
@@ -105,9 +100,9 @@ $(CLIB)-fixup: gcc-install $(GDB) $(ELF2FLT)
 		    CC='$(HOST_CC)' CFLAGS='$(HOST_CFLAGS)' CXXFLAGS='$(HOST_STATIC_CXXFLAGS)' $(MAKE_TRACE); \
 	fi
 
-%-fixup: %-install
-	$(TRACE) toolchain/$(patsubst %-fixup,%,$@)/fixup
-	@$(MAKE) -C $(patsubst %-fixup,%,$@) fixup $(MAKE_TRACE)
+%-final: %-install
+	$(TRACE) toolchain/$(patsubst %-final,%,$@)/final
+	@$(MAKE) -C $(patsubst %-final,%,$@) final $(MAKE_TRACE)
 
 %-clean:
 	$(TRACE) toolchain/$(patsubst %-clean,%,$@)/clean

+ 2 - 2
toolchain/binutils/Makefile

@@ -69,8 +69,8 @@ $(WRKBUILD)/.installed: $(WRKBUILD)/.compiled
 	$(MAKE) -C $(WRKBUILD) install
 ifeq ($(ADK_TOOLCHAIN_BINUTILS_GIT),y)
 ifeq ($(ADK_TARGET_ARCH_H8300),y)
-	$(INSTALL_DIR) $(TOOLCHAIN_DIR)/usr/lib/ldscripts
-	$(CP) $(WRKBUILD)/ld/ldscripts/* $(TOOLCHAIN_DIR)/usr/lib/ldscripts/
+	$(INSTALL_DIR) $(STAGING_TARGET_DIR)/usr/lib/ldscripts
+	$(CP) $(WRKBUILD)/ld/ldscripts/* $(STAGING_TARGET_DIR)/usr/lib/ldscripts/
 endif
 endif
 	@touch $@

+ 45 - 59
toolchain/gcc/Makefile

@@ -56,7 +56,6 @@ GCC_CONFOPTS:=		--prefix=$(TOOLCHAIN_DIR)/usr \
 			--without-isl \
 			--disable-nls
 
-
 ifeq ($(ADK_TARGET_WITH_NPTL),y)
 GCC_FINAL_CONFOPTS:=	--enable-tls --enable-threads --enable-libatomic
 endif
@@ -188,16 +187,15 @@ endif
 
 include ${ADK_TOPDIR}/mk/buildhlp.mk
 
-GCC_BUILD_DIR_MINIMAL:=	$(WRKBUILD)-minimal
 GCC_BUILD_DIR_INITIAL:=	$(WRKBUILD)-initial
 GCC_BUILD_DIR_FINAL:=	$(WRKBUILD)-final
 
-$(GCC_BUILD_DIR_MINIMAL)/.configured:
+$(GCC_BUILD_DIR_INITIAL)/.configured:
 ifeq ($(ADK_TARGET_ARCH_XTENSA),y)
 	tar xf $(ADK_TOPDIR)/target/xtensa/overlay/xtensa_$(ADK_TARGET_XTENSA).tar \
 		--strip-components=1 -C $(WRKSRC) gcc
 endif
-	mkdir -p $(GCC_BUILD_DIR_MINIMAL)
+	mkdir -p $(GCC_BUILD_DIR_INITIAL)
 	# these symlinks are very important, do not remove
 	rm -rf $(TOOLCHAIN_DIR)/usr/$(GNU_TARGET_NAME)/sys-include
 	mkdir -p $(TOOLCHAIN_DIR)/usr/$(GNU_TARGET_NAME)
@@ -205,7 +203,7 @@ endif
 		ln -s ../$(STAGING_HOST2TARGET)/usr/include sys-include)
 	rm -rf ${TOOLCHAIN_DIR}/usr/$(GNU_TARGET_NAME)/lib
 	(cd $(TOOLCHAIN_DIR)/usr/$(GNU_TARGET_NAME); \
-		ln -s ../$(STAGING_HOST2TARGET)/lib lib)
+		ln -s ../$(STAGING_HOST2TARGET)/usr/lib lib)
 ifeq ($(ADK_TARGET_ARCH_SH),y)
 ifeq ($(ADK_CPU_SH3),y)
 	(cd ${STAGING_TARGET_DIR}/ && ln -sf . m3)
@@ -216,9 +214,13 @@ endif
 ifeq ($(ADK_CPU_SH4A),y)
 	(cd ${STAGING_TARGET_DIR}/ && ln -sf . m4a)
 endif
+endif
+ifeq ($(ADK_TARGET_ARCH_ARC),y)
+	$(SED) 's/crtbeginS.o libgmon.a crtg.o/crtbeginS.o crtg.o/' \
+                $(WRKBUILD)/libgcc/config.host
 endif
 	$(SED) '/k prot/agcc_cv_libc_provides_ssp=yes' $(WRKBUILD)/gcc/configure
-	cd $(GCC_BUILD_DIR_MINIMAL); \
+	cd $(GCC_BUILD_DIR_INITIAL); \
 		PATH='$(TARGET_PATH)' \
 		CC='$(HOST_CC)' \
 		CXX='$(HOST_CXX)' \
@@ -227,57 +229,47 @@ endif
 		$(WRKBUILD)/configure \
 			${GCC_CONFOPTS} \
 			--enable-languages=c \
-			--disable-libssp \
+			--with-newlib \
+			--enable-tls \
 			--disable-shared \
 			--disable-threads \
 			--disable-multilib \
 			--without-headers
 	touch $@
 
-$(GCC_BUILD_DIR_MINIMAL)/.compiled: $(GCC_BUILD_DIR_MINIMAL)/.configured
-	PATH='$(TARGET_PATH)' $(MAKE) ${GCC_MAKEOPTS} -C $(GCC_BUILD_DIR_MINIMAL) all-gcc
-	touch $@
-
-$(WRKBUILD)/.headers: $(GCC_BUILD_DIR_MINIMAL)/.compiled
-	PATH='$(TARGET_PATH)' $(MAKE) -C $(GCC_BUILD_DIR_MINIMAL) install-gcc
-	touch $@
-
-$(GCC_BUILD_DIR_INITIAL)/.configured:
-	mkdir -p $(GCC_BUILD_DIR_INITIAL)
-	cd $(GCC_BUILD_DIR_INITIAL); \
-		PATH='$(TARGET_PATH)' \
-		CC='$(HOST_CC)' \
-		CXX='$(HOST_CXX)' \
-		CFLAGS="-O0 -g0 -fomit-frame-pointer" \
-		CXXFLAGS="-O0 -g0 -fomit-frame-pointer" \
-		$(WRKBUILD)/configure \
-			${GCC_CONFOPTS} \
-			${GCC_FINAL_CONFOPTS} \
-			--enable-languages=c \
-			--disable-shared \
-			--disable-threads \
-			--with-sysroot=$(STAGING_TARGET_DIR)
-	touch $@
-
-ifeq ($(ADK_TOOLCHAIN_GCC_4_2_4),y)
 $(GCC_BUILD_DIR_INITIAL)/.compiled: $(GCC_BUILD_DIR_INITIAL)/.configured
-	PATH='$(TARGET_PATH)' $(MAKE) ${GCC_MAKEOPTS} -C $(GCC_BUILD_DIR_INITIAL) all-gcc
-	touch $@
-
-$(WRKBUILD)/.configured: $(GCC_BUILD_DIR_INITIAL)/.compiled
-	PATH='$(TARGET_PATH)' $(MAKE) -C $(GCC_BUILD_DIR_INITIAL) install-gcc
-	touch $@
+ifeq ($(ADK_TOOLCHAIN_GCC_OLD),y)
+	PATH='$(TARGET_PATH)' \
+		$(MAKE) ${GCC_MAKEOPTS} -C $(GCC_BUILD_DIR_INITIAL) all-gcc
 else
-$(GCC_BUILD_DIR_INITIAL)/.compiled: $(GCC_BUILD_DIR_INITIAL)/.configured
-	PATH='$(TARGET_PATH)' $(MAKE) ${GCC_MAKEOPTS} -C $(GCC_BUILD_DIR_INITIAL) all-gcc all-target-libgcc
+	PATH='$(TARGET_PATH)' \
+		$(MAKE) ${GCC_MAKEOPTS} -C $(GCC_BUILD_DIR_INITIAL) all-gcc all-target-libgcc
+endif
 	touch $@
 
 $(WRKBUILD)/.configured: $(GCC_BUILD_DIR_INITIAL)/.compiled
-	PATH='$(TARGET_PATH)' $(MAKE) -C $(GCC_BUILD_DIR_INITIAL) install-gcc install-target-libgcc
-	touch $@
+ifeq ($(ADK_TOOLCHAIN_GCC_OLD),y)
+	PATH='$(TARGET_PATH)' \
+		$(MAKE) -C $(GCC_BUILD_DIR_INITIAL) install-gcc
+else
+	PATH='$(TARGET_PATH)' \
+		$(MAKE) -C $(GCC_BUILD_DIR_INITIAL) install-gcc install-target-libgcc
+endif
+ifeq ($(ADK_TARGET_ARCH_M68K),y)
+	# create gcc wrapper for uClinux/m68k
+	echo "#!/bin/sh" > $(TOOLCHAIN_DIR)/usr/bin/adk-uclinux-gcc
+	echo "exec ${GNU_TARGET_NAME}-gcc \"\$$@\" -specs $(ADK_TOPDIR)/toolchain/gcc/m68k-uclinux-gcc.specs" >> $(TOOLCHAIN_DIR)/usr/bin/adk-uclinux-gcc
+	chmod a+x $(TOOLCHAIN_DIR)/usr/bin/adk-uclinux-gcc
 endif
+ifeq ($(ADK_TARGET_ARCH_ARM),y)
+	# create gcc wrapper for uClinux/arm
+	echo "#!/bin/sh" > $(TOOLCHAIN_DIR)/usr/bin/adk-uclinux-gcc
+	echo "exec ${GNU_TARGET_NAME}-gcc \"\$$@\" -specs $(ADK_TOPDIR)/toolchain/gcc/arm-uclinux-gcc.specs" >> $(TOOLCHAIN_DIR)/usr/bin/adk-uclinux-gcc
+	chmod a+x $(TOOLCHAIN_DIR)/usr/bin/adk-uclinux-gcc
+endif
+	touch $@
 
-$(GCC_BUILD_DIR_FINAL)/.configured:
+$(WRKBUILD)/.compiled:
 	mkdir -p $(GCC_BUILD_DIR_FINAL)
 	cd $(GCC_BUILD_DIR_FINAL); \
 		PATH='$(TARGET_PATH)' \
@@ -293,9 +285,6 @@ $(GCC_BUILD_DIR_FINAL)/.configured:
 			--with-build-sysroot='$${prefix}/${STAGING_HOST2TARGET}' \
 			--with-sysroot='$${prefix}/${STAGING_HOST2TARGET}'
 	PATH='$(TARGET_PATH)' $(MAKE) -C $(GCC_BUILD_DIR_FINAL) configure-host
-	touch $@
-
-$(WRKBUILD)/.compiled: $(GCC_BUILD_DIR_FINAL)/.configured
 	cd $(GCC_BUILD_DIR_FINAL); \
 		PATH='$(TARGET_PATH)' \
 		$(MAKE) ${GCC_MAKEOPTS} all
@@ -327,20 +316,17 @@ endif
 	cd $(STAGING_TARGET_DIR)/lib && \
 		ln -sf libstdc++.so.6.0.$(LIBSTDCXXVER) libstdc++.so && \
 		ln -sf libstdc++.so.6.0.$(LIBSTDCXXVER) libstdc++.so.6
+	touch $@
+
+$(WRKBUILD)/.final:
 	# cleanup unneeded docs
 	rm -rf $(TOOLCHAIN_DIR)/usr/share
-ifeq ($(ADK_TARGET_ARCH_M68K),y)
-	# create gcc wrapper for uClinux/m68k
-	echo "#!/bin/sh" > $(TOOLCHAIN_DIR)/usr/bin/adk-uclinux-gcc
-	echo "exec ${GNU_TARGET_NAME}-gcc \"\$$@\" -specs $(ADK_TOPDIR)/toolchain/gcc/m68k-uclinux-gcc.specs" >> $(TOOLCHAIN_DIR)/usr/bin/adk-uclinux-gcc
-	chmod a+x $(TOOLCHAIN_DIR)/usr/bin/adk-uclinux-gcc
-endif
-ifeq ($(ADK_TARGET_ARCH_ARM),y)
-	# create gcc wrapper for uClinux/arm
-	echo "#!/bin/sh" > $(TOOLCHAIN_DIR)/usr/bin/adk-uclinux-gcc
-	echo "exec ${GNU_TARGET_NAME}-gcc \"\$$@\" -specs $(ADK_TOPDIR)/toolchain/gcc/arm-uclinux-gcc.specs" >> $(TOOLCHAIN_DIR)/usr/bin/adk-uclinux-gcc
-	chmod a+x $(TOOLCHAIN_DIR)/usr/bin/adk-uclinux-gcc
-endif
+	# cleanup unneeded libtool files
+	-find $(STAGING_TARGET_DIR) $(STAGING_HOST_DIR) -name \*.la -exec rm {} \;
+	# strip target libs and host tools for toolchain builds
+	PATH="$(TARGET_PATH)" debug='0' prefix='${TARGET_CROSS}' ${BASH} ${SCRIPT_DIR}/rstrip.sh \
+		$(STAGING_TARGET_DIR) $(TOOLCHAIN_DIR)/usr/lib/gcc/$(GNU_TARGET_NAME)
+	debug='0' prefix=' ' ${BASH} ${SCRIPT_DIR}/rstrip.sh $(TOOLCHAIN_DIR)/usr/bin
 	touch $@
 
 include ${ADK_TOPDIR}/mk/toolchain.mk

+ 11 - 0
toolchain/gcc/patches/4.9.3/fix-m86k-libgcc.patch

@@ -0,0 +1,11 @@
+diff -Nur gcc-4.9.3.orig/libgcc/config/m68k/linux-atomic.c gcc-4.9.3/libgcc/config/m68k/linux-atomic.c
+--- gcc-4.9.3.orig/libgcc/config/m68k/linux-atomic.c	2014-01-02 23:25:22.000000000 +0100
++++ gcc-4.9.3/libgcc/config/m68k/linux-atomic.c	2015-11-29 14:42:10.566143595 +0100
+@@ -33,7 +33,6 @@
+    using the kernel helper defined below.  There is no support for
+    64-bit operations yet.  */
+ 
+-#include <asm/unistd.h>
+ #include <stdbool.h>
+ 
+ #ifndef __NR_atomic_cmpxchg_32

+ 11 - 0
toolchain/gcc/patches/4.9.3/fix-nios2.patch

@@ -0,0 +1,11 @@
+diff -Nur gcc-4.9.3.orig/libgcc/config/nios2/linux-atomic.c gcc-4.9.3/libgcc/config/nios2/linux-atomic.c
+--- gcc-4.9.3.orig/libgcc/config/nios2/linux-atomic.c	2014-01-02 23:25:22.000000000 +0100
++++ gcc-4.9.3/libgcc/config/nios2/linux-atomic.c	2015-12-01 22:50:00.029946306 +0100
+@@ -20,7 +20,6 @@
+ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+ <http://www.gnu.org/licenses/>.  */
+ 
+-#include <asm/unistd.h>
+ #define EFAULT  14
+ #define EBUSY   16
+ #define ENOSYS  38

+ 30 - 0
toolchain/gcc/patches/4.9.3/stdlib-h.ia64

@@ -0,0 +1,30 @@
+diff -Nur gcc-4.9.3.orig/libgcc/config/ia64/fde-glibc.c gcc-4.9.3/libgcc/config/ia64/fde-glibc.c
+--- gcc-4.9.3.orig/libgcc/config/ia64/fde-glibc.c	2014-01-02 23:25:22.000000000 +0100
++++ gcc-4.9.3/libgcc/config/ia64/fde-glibc.c	2015-12-01 07:06:43.963906167 +0100
+@@ -25,6 +25,8 @@
+ /* Locate the FDE entry for a given address, using glibc ld.so routines
+    to avoid register/deregister calls at DSO load/unload.  */
+ 
++#ifndef inhibit_libc
++
+ #ifndef _GNU_SOURCE
+ #define _GNU_SOURCE 1
+ #endif
+@@ -159,3 +161,4 @@
+ 
+   return data.ret;
+ }
++#endif
+diff -Nur gcc-4.9.3.orig/libgcc/unwind-generic.h gcc-4.9.3/libgcc/unwind-generic.h
+--- gcc-4.9.3.orig/libgcc/unwind-generic.h	2014-01-02 23:25:22.000000000 +0100
++++ gcc-4.9.3/libgcc/unwind-generic.h	2015-12-01 07:00:15.731287428 +0100
+@@ -221,7 +221,9 @@
+    compatible with the standard ABI for IA-64, we inline these.  */
+ 
+ #ifdef __ia64__
++#ifndef inhibit_libc
+ #include <stdlib.h>
++#endif
+ 
+ static inline _Unwind_Ptr
+ _Unwind_GetDataRelBase (struct _Unwind_Context *_C)

+ 3 - 31
toolchain/glibc/Makefile

@@ -20,30 +20,8 @@ ifeq (${ADK_MAKE_PARALLEL},y)
 GLIBC_MAKEOPTS+=	PARALLELMFLAGS="-j$(ADK_MAKE_JOBS)"
 endif
 
-
-GLIBC_BUILD_DIR_INITIAL:=	${WRKDIR}/$(PKG_NAME)-$(PKG_VERSION)-headers
 GLIBC_BUILD_DIR_FINAL:=		${WRKDIR}/$(PKG_NAME)-$(PKG_VERSION)-final
 
-$(WRKBUILD)/.headers_configure:
-	mkdir -p $(GLIBC_BUILD_DIR_INITIAL)
-	(cd $(GLIBC_BUILD_DIR_INITIAL); \
-		${GLIBC_ENV} \
-		$(WRKBUILD)/configure \
-			--prefix=$(STAGING_TARGET_DIR)/usr \
-			--with-sysroot=$(STAGING_TARGET_DIR) \
-			${GLIBC_CONFOPTS} \
-	);
-	touch $@
-
-$(WRKBUILD)/.headers: $(WRKBUILD)/.headers_configure
-	(cd $(GLIBC_BUILD_DIR_INITIAL); \
-		${GLIBC_ENV} \
-		$(MAKE) ${GLIBC_MAKEOPTS} install-headers \
-	);
-	touch $(STAGING_TARGET_DIR)/usr/include/gnu/stubs.h
-	touch $(STAGING_TARGET_DIR)/usr/include/gnu/stubs-{32,x32,64,soft,hard}.h
-	touch $@
-
 $(WRKBUILD)/.configured:
 	mkdir -p $(GLIBC_BUILD_DIR_FINAL)
 	(cd $(GLIBC_BUILD_DIR_FINAL); \
@@ -62,20 +40,14 @@ $(WRKBUILD)/.compiled:
 
 $(WRKBUILD)/.installed:
 	${GLIBC_ENV} $(MAKE) -C $(GLIBC_BUILD_DIR_FINAL) install_root=$(STAGING_TARGET_DIR) install
+	touch $(STAGING_TARGET_DIR)/usr/include/gnu/stubs.h
+	touch $(STAGING_TARGET_DIR)/usr/include/gnu/stubs-{32,x32,64,soft,hard}.h
 	mkdir -p ${STAGING_TARGET_DIR}/etc
 	${INSTALL_DATA} ${WRKBUILD}/posix/gai.conf ${STAGING_TARGET_DIR}/etc
 	${INSTALL_DATA} ${WRKBUILD}/nss/nsswitch.conf ${STAGING_TARGET_DIR}/etc
 	touch $@
 
-$(WRKBUILD)/.fixup:
-	-find $(STAGING_TARGET_DIR) $(STAGING_HOST_DIR) -name \*.la -exec rm {} \;
-	rm -rf $(STAGING_TARGET_DIR)/usr/share/locale $(STAGING_TARGET_DIR)/usr/share/i18n
-ifeq ($(ADK_TARGET_TOOLCHAIN),y)
-	# strip target libs and host tools for toolchain builds
-	PATH="$(TARGET_PATH)" debug='0' prefix='${TARGET_CROSS}' ${BASH} ${SCRIPT_DIR}/rstrip.sh \
-		$(STAGING_TARGET_DIR) $(TOOLCHAIN_DIR)/usr/lib/gcc/$(GNU_TARGET_NAME)
-	debug='0' prefix=' ' ${BASH} ${SCRIPT_DIR}/rstrip.sh $(TOOLCHAIN_DIR)/usr/bin
-endif
+$(WRKBUILD)/.final:
 	touch $@
 
 include ${ADK_TOPDIR}/mk/toolchain.mk

+ 1 - 2
toolchain/kernel-headers/Makefile

@@ -12,7 +12,6 @@ LINUX_DIR=${WRKBUILD}
 
 include $(ADK_TOPDIR)/mk/kernel-vars.mk
 
-
 $(TOOLCHAIN_BUILD_DIR)/w-$(PKG_NAME)-$(PKG_VERSION)-$(PKG_RELEASE)/linux-$(KERNEL_FILE_VER)/.patched:
 ifeq ($(ADK_TARGET_SYSTEM_PCENGINES_APU),y)
 ifeq ($(ADK_KERNEL_ROOT_NFS),y)
@@ -39,7 +38,7 @@ ifneq ($(ADK_DISABLE_TARGET_KERNEL_PATCHES),y)
 endif
 	touch $@
 
-$(WRKBUILD)/.headers: $(TOOLCHAIN_BUILD_DIR)/w-$(PKG_NAME)-$(PKG_VERSION)-$(PKG_RELEASE)/linux-$(KERNEL_FILE_VER)/.patched
+$(WRKBUILD)/.configured: $(TOOLCHAIN_BUILD_DIR)/w-$(PKG_NAME)-$(PKG_VERSION)-$(PKG_RELEASE)/linux-$(KERNEL_FILE_VER)/.patched
 	$(KERNEL_MAKE_ENV) $(MAKE) -C "${LINUX_DIR}" $(KERNEL_MAKE_OPTS) \
 		INSTALL_HDR_PATH=$(STAGING_TARGET_DIR)/usr \
 		headers_install

+ 2 - 30
toolchain/musl/Makefile

@@ -13,26 +13,16 @@ endif
 TARGET_CFLAGS:=		$(filter-out -fstack-protector-all,$(TARGET_CFLAGS))
 TARGET_LDFLAGS:=	$(filter-out -fstack-protector-all,$(TARGET_LDFLAGS))
 
-$(WRKBUILD)/.headers:
+$(WRKBUILD)/.configured:
 	(cd $(WRKBUILD); CC='$(TARGET_CC)' CROSS_COMPILE='$(TARGET_CROSS)' \
 		CFLAGS='$(TARGET_CFLAGS)' \
 		./configure --prefix=/usr \
 		--target=$(GNU_TARGET_NAME) \
 		--disable-gcc-wrapper \
 	)
-	$(MAKE) -C $(WRKBUILD) DESTDIR=$(STAGING_TARGET_DIR) install-headers
-	touch $(WRKBUILD)/.configured
 	touch $@
 
 $(WRKBUILD)/.compiled:
-	# reconfigure musl, otherwise linking with libgcc or libgcc_eh is disabled
-	$(MAKE) -C $(WRKBUILD) clean
-	(cd $(WRKBUILD); CC='$(TARGET_CC)' CROSS_COMPILE='$(TARGET_CROSS)' \
-		CFLAGS='$(TARGET_CFLAGS)' \
-		./configure --prefix=/usr \
-		--target=$(GNU_TARGET_NAME) \
-		--disable-gcc-wrapper \
-	)
 	$(MAKE) -C $(WRKBUILD) CFLAGS='$(TARGET_CFLAGS)' all
 	touch $@
 
@@ -40,25 +30,7 @@ $(WRKBUILD)/.installed: $(WRKBUILD)/.compiled
 	$(MAKE) -C $(WRKBUILD) CFLAGS='$(TARGET_CFLAGS)' DESTDIR=$(STAGING_TARGET_DIR) install
 	touch $@
 
-$(WRKBUILD)/.fixup:
-	# reconfigure musl, otherwise linking with libgcc or libgcc_eh is disabled
-	$(MAKE) -C $(WRKBUILD) clean
-	(cd $(WRKBUILD); CC='$(TARGET_CC)' CROSS_COMPILE='$(TARGET_CROSS)' \
-		CFLAGS='$(TARGET_CFLAGS)' \
-		./configure --prefix=/usr \
-		--target=$(GNU_TARGET_NAME) \
-		--disable-gcc-wrapper \
-	)
-	$(MAKE) -C $(WRKBUILD) CFLAGS='$(TARGET_CFLAGS)' all
-	$(MAKE) -C $(WRKBUILD) CFLAGS='$(TARGET_CFLAGS)' DESTDIR=$(STAGING_TARGET_DIR) install
-	# cleanup toolchain
-	-find $(STAGING_TARGET_DIR) $(STAGING_HOST_DIR) -name \*.la -exec rm {} \;
-ifeq ($(ADK_TARGET_TOOLCHAIN),y)
-	# strip target libs and host tools for toolchain builds
-	PATH="$(TARGET_PATH)" debug='0' prefix='${TARGET_CROSS}' ${BASH} ${SCRIPT_DIR}/rstrip.sh \
-		$(STAGING_TARGET_DIR) $(TOOLCHAIN_DIR)/usr/lib/gcc/$(GNU_TARGET_NAME)
-	debug='0' prefix=' ' ${BASH} ${SCRIPT_DIR}/rstrip.sh $(TOOLCHAIN_DIR)/usr/bin
-endif
+$(WRKBUILD)/.final:
 	touch $@
 
 include ${ADK_TOPDIR}/mk/toolchain.mk

+ 10 - 37
toolchain/uclibc-ng/Makefile

@@ -8,6 +8,7 @@ include ../rules.mk
 include Makefile.inc
 include ${ADK_TOPDIR}/mk/buildhlp.mk
 
+# disable LTO
 TARGET_CFLAGS:=$(filter-out -flto,$(TARGET_CFLAGS))
 # handled by uClibc-ng makefiles
 TARGET_CFLAGS:=$(filter-out -fstack-protector-all,$(TARGET_CFLAGS))
@@ -35,7 +36,7 @@ ifeq (${ADK_MAKE_PARALLEL},y)
 UCLIBC_MAKEOPTS+=	-j${ADK_MAKE_JOBS}
 endif
 
-$(WRKBUILD)/.headers:
+$(WRKBUILD)/.configured: $(WRKBUILD)/.prepared
 	$(SED) 's,^CROSS_COMPILE=.*,CROSS_COMPILE=$(TARGET_CROSS),g' $(WRKBUILD)/Rules.mak
 ifeq ($(ADK_TARGET_LIB_UCLIBC_NG_GIT),y)
 	PATH='$(HOST_PATH)' sed -e 's^KERNEL_HEADERS.*$$KERNEL_HEADERS=\"${STAGING_TARGET_DIR}/usr/include\"' \
@@ -277,7 +278,7 @@ ifeq ($(ADK_TARGET_ABI_O32),y)
 	$(SED) 's/.*\(CONFIG_MIPS_N64_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config
 endif
 endif
-	echo N|PATH='$(HOST_PATH)' $(MAKE) ${UCLIBC_MAKEOPTS} -C $(WRKBUILD) \
+	echo N|PATH='$(HOST_PATH)' $(MAKE) $(UCLIBC_MAKEOPTS) -C $(WRKBUILD) \
 		PREFIX=$(STAGING_TARGET_DIR) \
 		DEVEL_PREFIX=/usr/ \
 		RUNTIME_PREFIX=$(STAGING_TARGET_DIR) \
@@ -285,19 +286,10 @@ endif
 		UCLIBC_EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
 		UCLIBC_EXTRA_LDFLAGS="$(TARGET_LDFLAGS)" \
 		oldconfig
-	PATH='$(HOST_PATH)' $(MAKE) ${UCLIBC_MAKEOPTS} -C $(WRKBUILD) \
-		PREFIX=$(STAGING_TARGET_DIR) \
-		DEVEL_PREFIX=/usr/ \
-		RUNTIME_PREFIX=$(STAGING_TARGET_DIR) \
-		HOSTCC="$(HOST_CC)" \
-		UCLIBC_EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
-		UCLIBC_EXTRA_LDFLAGS="$(TARGET_LDFLAGS)" \
-		install_headers
-	touch $(WRKBUILD)/.configured
 	touch $@
 
-$(WRKBUILD)/.compiled:
-	PATH='$(HOST_PATH)' $(MAKE) ${UCLIBC_MAKEOPTS} -C $(WRKBUILD) \
+$(WRKBUILD)/.compiled: $(WRKBUILD)/.configured
+	PATH='$(HOST_PATH)' $(MAKE) $(UCLIBC_MAKEOPTS) -C $(WRKBUILD) \
 		PREFIX= \
 		DEVEL_PREFIX=/usr/ \
 		RUNTIME_PREFIX=/ \
@@ -308,7 +300,7 @@ $(WRKBUILD)/.compiled:
 		all
 	touch $@
 
-$(WRKBUILD)/.install_headers: $(WRKBUILD)/.compiled
+$(WRKBUILD)/.installed: $(WRKBUILD)/.compiled
 	PATH='$(HOST_PATH)' $(MAKE) -C $(WRKBUILD) \
 		PREFIX=$(STAGING_TARGET_DIR) \
 		DEVEL_PREFIX=/usr/ \
@@ -317,38 +309,19 @@ $(WRKBUILD)/.install_headers: $(WRKBUILD)/.compiled
 		UCLIBC_EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
 		UCLIBC_EXTRA_LDFLAGS="$(TARGET_LDFLAGS)" \
 		VERBOSE=1 \
-		install_dev
-	touch $@
-
-$(WRKBUILD)/.installed: $(WRKBUILD)/.install_headers
+		install_runtime install_dev
 	PATH='$(HOST_PATH)' $(MAKE) -C $(WRKBUILD) \
-		PREFIX=$(STAGING_TARGET_DIR) \
+		CC='$(TARGET_CC)' \
+		PREFIX= \
 		DEVEL_PREFIX=/usr/ \
-		DEVEL_PREFIX_LIB=/ \
 		RUNTIME_PREFIX=/ \
+		HOSTCC="$(HOST_CC)" \
 		UCLIBC_EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
 		UCLIBC_EXTRA_LDFLAGS="$(TARGET_LDFLAGS)" \
-		VERBOSE=1 \
-		install_runtime
-	touch $@
-
-$(WRKBUILD)/.fixup:
-	PATH='$(HOST_PATH)' $(MAKE) -C $(WRKBUILD) \
-		CC='$(TARGET_CC)' \
 		TEST_INSTALLED_UCLIBC=1 \
 		UCLIBC_ONLY=1 \
-		UCLIBC_EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
-		UCLIBC_EXTRA_LDFLAGS="$(TARGET_LDFLAGS)" \
 		VERBOSE=1 \
 		test_compile test_gen
-ifeq ($(ADK_TARGET_TOOLCHAIN),y)
-	# cleanup toolchain
-	-find $(STAGING_TARGET_DIR) $(STAGING_HOST_DIR) -name \*.la -exec rm {} \;
-	# strip target libs and host tools for toolchain builds
-	PATH="$(TARGET_PATH)" debug='0' prefix='${TARGET_CROSS}' ${BASH} ${SCRIPT_DIR}/rstrip.sh \
-		$(STAGING_TARGET_DIR) $(TOOLCHAIN_DIR)/usr/lib/gcc/$(GNU_TARGET_NAME)
-	debug='0' prefix=' ' ${BASH} ${SCRIPT_DIR}/rstrip.sh $(TOOLCHAIN_DIR)/usr/bin
-endif
 	touch $@
 
 include ${ADK_TOPDIR}/mk/toolchain.mk