toolchain: skip gcc/minimal for musl
authorFelix Fietkau <nbd@nbd.name>
Thu, 7 Jul 2016 12:12:30 +0000 (14:12 +0200)
committerFelix Fietkau <nbd@nbd.name>
Thu, 7 Jul 2016 13:13:40 +0000 (15:13 +0200)
No extra libc header build step is done, so no extra toolchain is needed
for preparing it.
This saves a significant amount of build time and disk space

Signed-off-by: Felix Fietkau <nbd@nbd.name>
toolchain/Makefile
toolchain/gcc/common.mk
toolchain/gcc/initial/Makefile
toolchain/gcc/minimal/Makefile
toolchain/glibc/headers/Makefile
toolchain/musl/headers/Makefile [deleted file]
toolchain/uClibc/headers/Makefile

index cd5399e..7d2fddd 100644 (file)
 # 8) toolchain/libc/utils/install
 #    build & install libc utilities
 #
+# For musl, steps 2 and 4 are skipped, and step 3 is done after 5
 
 curdir:=toolchain
 
 # subdirectories to descend into
-$(curdir)/builddirs := $(if $(CONFIG_GDB),gdb) $(if $(CONFIG_INSIGHT),insight) $(if $(CONFIG_EXTERNAL_TOOLCHAIN),wrapper,kernel-headers binutils gcc/minimal gcc/initial gcc/final $(LIBC)/headers $(LIBC) fortify-headers)
+$(curdir)/builddirs := $(if $(CONFIG_GDB),gdb) $(if $(CONFIG_INSIGHT),insight) $(if $(CONFIG_EXTERNAL_TOOLCHAIN),wrapper,kernel-headers binutils gcc/initial gcc/final $(LIBC) fortify-headers)
 ifdef CONFIG_USE_UCLIBC
   $(curdir)/builddirs += $(LIBC)/utils
 endif
-$(curdir)/builddirs-compile:=$($(curdir)/builddirs-prepare)
-$(curdir)/builddirs-install:=$($(curdir)/builddirs-compile)
 
 # builddir dependencies
 ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
-  $(curdir)/gcc/minimal/compile:=$(curdir)/binutils/install
-  $(curdir)/kernel-headers/install:=$(curdir)/gcc/minimal/install
-  $(curdir)/gcc/initial/prepare:=$(curdir)/gcc/minimal/prepare
-  $(curdir)/gcc/final/prepare:=$(curdir)/gcc/initial/prepare
+  ifdef CONFIG_USE_MUSL
+    $(curdir)/kernel-headers/compile:=$(curdir)/gcc/initial/install
+    $(curdir)/$(LIBC)/compile:=$(curdir)/kernel-headers/install
+  else
+    $(curdir)/builddirs += $(LIBC)/headers gcc/minimal
+    $(curdir)/gcc/minimal/compile:=$(curdir)/binutils/install
+    $(curdir)/kernel-headers/compile:=$(curdir)/gcc/minimal/install
+    $(curdir)/gcc/initial/prepare:=$(curdir)/gcc/minimal/prepare
+    $(curdir)/$(LIBC)/prepare:=$(curdir)/$(LIBC)/headers/prepare
+    $(curdir)/$(LIBC)/headers/compile:=$(curdir)/kernel-headers/install
+    $(curdir)/gcc/initial/compile:=$(curdir)/$(LIBC)/headers/install
+  endif
 
-  $(curdir)/$(LIBC)/headers/compile:=$(curdir)/kernel-headers/install
-  $(curdir)/gcc/initial/compile:=$(curdir)/$(LIBC)/headers/install
+  $(curdir)/gcc/initial/compile+=$(curdir)/binutils/install
+  $(curdir)/gcc/final/prepare:=$(curdir)/gcc/initial/prepare
   $(curdir)/$(LIBC)/compile:=$(curdir)/gcc/initial/install
   $(curdir)/gcc/final/compile:=$(curdir)/$(LIBC)/install
   $(curdir)/$(LIBC)/utils/compile:=$(curdir)/gcc/final/install
-  $(curdir)/$(LIBC)/prepare:=$(curdir)/$(LIBC)/headers/prepare
   $(curdir)/$(LIBC)/utils/prepare:=$(curdir)/$(LIBC)/headers/prepare
 endif
 
+$(curdir)/builddirs-compile:=$($(curdir)/builddirs-prepare)
+$(curdir)/builddirs-install:=$($(curdir)/builddirs-compile)
+
 ifndef DUMP_TARGET_DB
 ifneq ($(ARCH),)
   $(TOOLCHAIN_DIR)/info.mk: .config
index eab143c..9bc8491 100644 (file)
@@ -170,10 +170,30 @@ GCC_MAKE:= \
                CFLAGS_FOR_TARGET="$(TARGET_CFLAGS)" \
                CXXFLAGS_FOR_TARGET="$(TARGET_CFLAGS)"
 
-define Host/Prepare
-       mkdir -p $(GCC_BUILD_DIR)
+define Host/SetToolchainInfo
+       $(SED) 's,TARGET_CROSS=.*,TARGET_CROSS=$(REAL_GNU_TARGET_NAME)-,' $(TOOLCHAIN_DIR)/info.mk
+       $(SED) 's,GCC_VERSION=.*,GCC_VERSION=$(GCC_VERSION),' $(TOOLCHAIN_DIR)/info.mk
 endef
 
+ifneq ($(GCC_PREPARE),)
+  define Host/Prepare
+       $(call Host/SetToolchainInfo)
+       $(call Host/Prepare/Default)
+       ln -snf $(GCC_DIR) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
+       $(CP) $(SCRIPT_DIR)/config.{guess,sub} $(HOST_SOURCE_DIR)/
+       $(SED) 's,^MULTILIB_OSDIRNAMES,# MULTILIB_OSDIRNAMES,' $(HOST_SOURCE_DIR)/gcc/config/*/t-*
+       $(SED) 'd' $(HOST_SOURCE_DIR)/gcc/DEV-PHASE
+       $(SED) 's, DATESTAMP,,' $(HOST_SOURCE_DIR)/gcc/version.c
+       #(cd $(HOST_SOURCE_DIR)/libstdc++-v3; autoconf;);
+       $(SED) 's,gcc_no_link=yes,gcc_no_link=no,' $(HOST_SOURCE_DIR)/libstdc++-v3/configure
+       mkdir -p $(GCC_BUILD_DIR)
+  endef
+else
+  define Host/Prepare
+       mkdir -p $(GCC_BUILD_DIR)
+  endef
+endif
+
 define Host/Configure
        (cd $(GCC_BUILD_DIR) && rm -f config.cache; \
                $(GCC_CONFIGURE) \
@@ -181,7 +201,7 @@ define Host/Configure
 endef
 
 define Host/Clean
-       rm -rf \
+       rm -rf $(if $(GCC_PREPARE),$(HOST_SOURCE_DIR)) \
                $(STAGING_DIR_HOST)/stamp/.gcc_* \
                $(STAGING_DIR_HOST)/stamp/.binutils_* \
                $(GCC_BUILD_DIR) \
index f0c65b5..1ed5484 100644 (file)
@@ -1,4 +1,5 @@
 GCC_VARIANT:=initial
+GCC_PREPARE=$(CONFIG_USE_MUSL)
 
 include ../common.mk
 
@@ -10,7 +11,6 @@ GCC_CONFIGURE += \
        --disable-threads \
 
 define Host/Compile
-       $(CP) $(BUILD_DIR_TOOLCHAIN)/linux-dev/* $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/
        +$(GCC_MAKE) $(HOST_JOBS) -C $(GCC_BUILD_DIR) \
                all-build-libiberty \
                all-gcc \
index 0344e1a..31d6f67 100644 (file)
@@ -1,4 +1,5 @@
 GCC_VARIANT:=minimal
+GCC_PREPARE=$(if $(CONFIG_USE_MUSL),,1)
 
 include ../common.mk
 
@@ -11,24 +12,6 @@ GCC_CONFIGURE += \
        --disable-shared \
        --disable-threads
 
-define Host/SetToolchainInfo
-       $(SED) 's,TARGET_CROSS=.*,TARGET_CROSS=$(REAL_GNU_TARGET_NAME)-,' $(TOOLCHAIN_DIR)/info.mk
-       $(SED) 's,GCC_VERSION=.*,GCC_VERSION=$(GCC_VERSION),' $(TOOLCHAIN_DIR)/info.mk
-endef
-
-define Host/Prepare
-       $(call Host/SetToolchainInfo)
-       $(call Host/Prepare/Default)
-       ln -snf $(GCC_DIR) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
-       $(CP) $(SCRIPT_DIR)/config.{guess,sub} $(HOST_BUILD_DIR)/
-       $(SED) 's,^MULTILIB_OSDIRNAMES,# MULTILIB_OSDIRNAMES,' $(HOST_BUILD_DIR)/gcc/config/*/t-*
-       $(SED) 'd' $(HOST_BUILD_DIR)/gcc/DEV-PHASE
-       $(SED) 's, DATESTAMP,,' $(HOST_BUILD_DIR)/gcc/version.c
-       #(cd $(HOST_BUILD_DIR)/libstdc++-v3; autoconf;);
-       $(SED) 's,gcc_no_link=yes,gcc_no_link=no,' $(HOST_BUILD_DIR)/libstdc++-v3/configure
-       mkdir -p $(GCC_BUILD_DIR)
-endef
-
 define Host/Compile
        +$(GCC_MAKE) $(HOST_JOBS) -C $(GCC_BUILD_DIR) all-gcc all-target-libgcc
 endef
index f9f411b..f1d8a8b 100644 (file)
@@ -15,6 +15,7 @@ define Host/Install
                install_root="$(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev" \
                install-bootstrap-headers=yes \
                install-headers
+       $(CP) $(BUILD_DIR_TOOLCHAIN)/linux-dev/* $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/
        $(MAKE) -C $(CUR_BUILD_DIR) \
                csu/subdir_lib
        ( cd $(CUR_BUILD_DIR); \
diff --git a/toolchain/musl/headers/Makefile b/toolchain/musl/headers/Makefile
deleted file mode 100644 (file)
index 21e6b3b..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-PATH_PREFIX:=..
-
-include ../common.mk
-
-HOST_STAMP_BUILT:=$(HOST_BUILD_DIR)/.headers_built
-HOST_STAMP_INSTALLED:=$(TOOLCHAIN_DIR)/stamp/.uclibc_headers_installed
-
-define Host/Compile
-
-endef
-
-define Host/Install
-endef
-
-$(eval $(call HostBuild))
-
index 67a2d95..abd3620 100644 (file)
@@ -20,6 +20,7 @@ define Host/Install
                ARCH="$(CONFIG_ARCH)" \
                pregen \
                install_headers
+       $(CP) $(BUILD_DIR_TOOLCHAIN)/linux-dev/* $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/
 endef
 
 $(eval $(call HostBuild))