This version is based against trunk as of now and fixes the SDK tarball name.

The following patch both fixes using an openwrt external toolchain
(that is in menuconfig using the option to build a toolchain, and feeding
that back into another openwrt build as an external toolchain, which if you're 
not
constantly following every commit in trunk (or to a certain extent even if you 
are,
because even then toolchain doesn't change that often), saves a great deal of 
build time
since the toolchain is one of the portions of the build that takes longest and 
is not
parallelized (or at least not much)) to build a working ImageBuilder and SDK 
(the resulting
ImageBuilder and SDK (or at least the SDK) require that the Toolchain directory 
be referenced
in their .configs).

This patch should be fairly non-controversial or painful for anyone, but I am 
posting for review
of submitting because I have been on a long hiatus, and my previous recent 
commit (for a personal patch,
unlike this patch, which comes from a client) as a I came back was rather a 
disaster (though at least
the concept was appreciated (the -fat image for dir825 which allows to use the 
full flash of the dir825
instead of only about 6MB that the stock images use and the default caldata 
position allows).

I am hoping this gets no complaints and I can just commit the patch, but if 
there are issues, please let me
know and I will try to address them.  I probably can't spend a lot of time on 
it, since my client isn't likely to pay for
extensive amounts of time massaging patches to get them accepted upstream when 
they work for them, so please keep
that in mind when asking for changes.  I am hoping the that various patches I 
will be sending don't require a lot
of managing to be useful/manageable in openwrt proper, since I'd like to see 
openwrt benefit from the time I've
spent away, but as I've said I don't have a lot of paid time to get them 
integrated.

In include patch both inline and as attachment so that hopefully everyone can 
get a non-mangled using their
preferred method of dealing with patches.

Signed-off-by: DanielDickinson <[email protected]>
---
 package/toolchain/Makefile         |   10 +++++++---
 rules.mk                           |    3 +++
 target/imagebuilder/Config.in      |    2 +-
 target/imagebuilder/files/Makefile |    7 ++++++-
 target/sdk/Config.in               |    2 +-
 target/sdk/Makefile                |    8 +++++++-
 toolchain/Config.in                |    9 ++++++++-
 toolchain/Makefile                 |    2 ++
 toolchain/wrapper/Makefile         |    4 ++++
 9 files changed, 39 insertions(+), 8 deletions(-)


diff --git a/package/toolchain/Makefile b/package/toolchain/Makefile
index c194a34..00923f9 100644
--- a/package/toolchain/Makefile
+++ b/package/toolchain/Makefile
@@ -138,7 +138,8 @@ define Package/libc/config
                string
                prompt "libc shared library files (use wildcards)"
                depends EXTERNAL_TOOLCHAIN && PACKAGE_libc
-               default "./lib/ld{-*.so,-linux*.so.*} 
./lib/lib{anl,c,cidn,crypt,dl,m,nsl,nss_dns,nss_files,resolv,util}{-*.so,.so.*}"
+               default "./lib/ld{-*.so,-linux*.so.*} 
./lib/lib{anl,c,cidn,crypt,dl,m,nsl,nss_dns,nss_files,resolv,util}{-*.so,.so.*,.so}"
 if !EXTERNAL_UCLIBC
+               default "./lib/ld{-*.so,-*.so.*,-linux*.so.*} 
./lib/lib{anl,c,cidn,crypt,dl,m,nsl,nss_dns,nss_files,resolv,util,uClibc}{-*.so,.so.*,.so}"
 if EXTERNAL_UCLIBC

        endmenu
 endef
@@ -164,7 +165,7 @@ define Package/libpthread/config
                string
                prompt "libpthread shared library files (use wildcards)"
                depends EXTERNAL_TOOLCHAIN && PACKAGE_libpthread
-               default "./lib/libpthread{-*.so,.so.*}"
+               default "./lib/libpthread{-*.so,.so.*,.so}"

        endmenu
 endef
@@ -196,7 +197,7 @@ define Package/librt/config
                string
                prompt "librt shared library files (use wildcards)"
                depends EXTERNAL_TOOLCHAIN && PACKAGE_librt
-               default "./lib/librt{-*.so,.so.*}"
+               default "./lib/librt{-*.so,.so.*,.so}"

        endmenu
 endef
@@ -468,6 +469,7 @@ ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
                $(TOOLCHAIN_DIR)/lib/librt.so.* \
                $(TOOLCHAIN_DIR)/lib/librt-$(LIBC_SO_VERSION).so \
                $(1)/lib/
+       $(if $(CONFIG_EXTERNAL_UCLIBC),$(CP) 
$(CONFIG_TOOLCHAIN_ROOT)/lib/librt-*.so $(TOOLCHAIN_DIR)/lib))
   endef

   define Package/ldd/install
@@ -532,6 +534,7 @@ else
                $(INSTALL_DIR) $(1)/$$$$dir ; \
                $(CP) $(call qstrip,$(CONFIG_LIBPTHREAD_ROOT_DIR))/$$$$file 
$(1)/$$$$dir/ ; \
        done ; \
+       $(INSTALL_DIR) $(1)/lib
        exit 0
   endef

@@ -541,6 +544,7 @@ else
                $(INSTALL_DIR) $(1)/$$$$dir ; \
                $(CP) $(call qstrip,$(CONFIG_LIBRT_ROOT_DIR))/$$$$file 
$(1)/$$$$dir/ ; \
        done ; \
+       $(INSTALL_DIR) $(1)/lib
        exit 0
   endef

diff --git a/rules.mk b/rules.mk
index 34c86ca..cce7b26 100644
--- a/rules.mk
+++ b/rules.mk
@@ -116,6 +116,9 @@ ifneq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
 LIBGCC_S_PATH=$(realpath $(wildcard $(call 
qstrip,$(CONFIG_LIBGCC_ROOT_DIR))/$(call qstrip,$(CONFIG_LIBGCC_FILE_SPEC))))
 LIBGCC_S=$(if $(LIBGCC_S_PATH),-L$(dir $(LIBGCC_S_PATH)) -lgcc_s)
 LIBGCC_A=$(realpath $(wildcard $(dir $(LIBGCC_S_PATH))/gcc/*/*/libgcc.a))
+ifneq ($(CONFIG_EXTERNAL_UCLIBC),)
+TARGET_LDFLAGS+= -ldl
+endif
 else
 LIBGCC_A=$(wildcard $(TOOLCHAIN_DIR)/lib/gcc/*/*/libgcc.a)
 LIBGCC_S=$(if $(wildcard 
$(TOOLCHAIN_DIR)/lib/libgcc_s.so),-L$(TOOLCHAIN_DIR)/lib -lgcc_s,$(LIBGCC_A))
diff --git a/target/imagebuilder/Config.in b/target/imagebuilder/Config.in
index 23a418b..9cf500c 100644
--- a/target/imagebuilder/Config.in
+++ b/target/imagebuilder/Config.in
@@ -2,7 +2,7 @@ config IB
        bool "Build the OpenWrt Image Builder"
        depends !TARGET_ROOTFS_INITRAMFS
        depends !PROFILE_KCONFIG
-       depends !EXTERNAL_TOOLCHAIN
+       depends !EXTERNAL_TOOLCHAIN || EXTERNAL_UCLIBC
        help
          This is essentially a stripped-down version of the buildroot
          with precompiled packages, kernel image and image building tools.
diff --git a/target/imagebuilder/files/Makefile 
b/target/imagebuilder/files/Makefile
index b0d0698..85e9f5a 100644
--- a/target/imagebuilder/files/Makefile
+++ b/target/imagebuilder/files/Makefile
@@ -53,6 +53,7 @@ help: FORCE

 # override variables from rules.mk
 PACKAGE_DIR:=$(TOPDIR)/packages
+OPKG_TMP:=$(TOPDIR)/$(shell mktemp -d)
 OPKG:= \
   IPKG_TMP="$(TOPDIR)/tmp/ipkgtmp" \
   IPKG_INSTROOT="$(TARGET_DIR)" \
@@ -67,7 +68,8 @@ OPKG:= \
        --offline-root $(TARGET_DIR) \
        --add-dest root:/ \
        --add-arch all:100 \
-       --add-arch $(ARCH_PACKAGES):200
+       --add-arch $(ARCH_PACKAGES):200 \
+       -t $(OPKG_TMP)

 define Profile
   $(eval $(call Profile/Default))
@@ -105,6 +107,7 @@ _call_image:
                $(MAKE) package_index; \
        else \
                mkdir -p $(TARGET_DIR)/tmp; \
+               mkdir -p $(OPKG_TMP); \
                $(OPKG) update; \
        fi
        $(MAKE) package_install
@@ -121,11 +124,13 @@ package_index: FORCE
        (cd $(PACKAGE_DIR); $(SCRIPT_DIR)/ipkg-make-index.sh . > Packages && \
                gzip -9c Packages > Packages.gz \
        ) >/dev/null 2>/dev/null
+       mkdir -p $(OPKG_TMP); \
        $(OPKG) update

 package_install: FORCE
        @echo
        @echo Installing packages...
+       mkdir -p $(OPKG_TMP)    
        $(OPKG) install $(PACKAGE_DIR)/libc_*.ipk
        $(OPKG) install $(PACKAGE_DIR)/kernel_*.ipk
        $(OPKG) install $(BUILD_PACKAGES)
diff --git a/target/sdk/Config.in b/target/sdk/Config.in
index c8106d2..6b937f7 100644
--- a/target/sdk/Config.in
+++ b/target/sdk/Config.in
@@ -1,6 +1,6 @@
 config SDK
        bool "Build the OpenWrt SDK"
-       depends !EXTERNAL_TOOLCHAIN
+       depends !EXTERNAL_TOOLCHAIN || EXTERNAL_UCLIBC
        help
          This is essentially a stripped-down version of the buildroot
          with a precompiled toolchain. It can be used to develop and
diff --git a/target/sdk/Makefile b/target/sdk/Makefile
index 51bf47b..74c8a80 100644
--- a/target/sdk/Makefile
+++ b/target/sdk/Makefile
@@ -14,7 +14,11 @@ override MAKEFLAGS=
 PKG_OS:=$(word 2,$(subst -, ,$(shell $(HOSTCC) -dumpmachine)))
 PKG_CPU:=$(word 1,$(subst -, ,$(shell $(HOSTCC) -dumpmachine)))

+ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
 
SDK_NAME:=OpenWrt-SDK-$(BOARD)-for-$(PKG_OS)-$(PKG_CPU)-gcc-$(GCCV)_$(LIBC)-$(LIBCV)
+else
+SDK_NAME:=OpenWrt-SDK-$(BOARD)-for-$(PKG_OS)-$(PKG_CPU)-gcc-$(GNU_TARGET_NAME)
+endif
 SDK_BUILD_DIR:=$(BUILD_DIR)/$(SDK_NAME)
 EXCLUDE_DIRS:=*/ccache \
        */stamp \
@@ -33,7 +37,9 @@ $(BIN_DIR)/$(SDK_NAME).tar.bz2: clean
                $(foreach exclude,$(EXCLUDE_DIRS),--exclude="$(exclude)") \
                --exclude="staging_dir/$(ARCH)" \
                staging_dir/host 
staging_dir/target-$(ARCH)$(ARCH_SUFFIX)_$(LIBC)-$(LIBCV)$(if 
$(CONFIG_arm),_eabi) \
-               
staging_dir/toolchain-$(ARCH)$(ARCH_SUFFIX)_gcc-$(GCCV)_$(LIBC)-$(LIBCV)$(if 
$(CONFIG_arm),_eabi) | \
+               staging_dir/host staging_dir/target-$(GNU_TARGET_NAME) \
+               
staging_dir/toolchain-$(ARCH)$(ARCH_SUFFIX)_gcc-$(GCCV)_$(LIBC)-$(LIBCV)$(if 
$(CONFIG_arm),_eabi) \
+               staging_dir/toolchain-$(GNU_TARGET_NAME) | \
                $(TAR) -xf - -C $(SDK_BUILD_DIR)
        mkdir -p $(SDK_BUILD_DIR)/target/linux
        $(CP) $(GENERIC_PLATFORM_DIR) $(PLATFORM_DIR) 
$(SDK_BUILD_DIR)/target/linux/
diff --git a/toolchain/Config.in b/toolchain/Config.in
index 1c09983..d1cbb32 100644
--- a/toolchain/Config.in
+++ b/toolchain/Config.in
@@ -14,6 +14,13 @@ menuconfig EXTERNAL_TOOLCHAIN
                help
                  If enabled, OpenWrt will compile using the native toolchain 
for your host instead of compiling one

+       config EXTERNAL_UCLIBC
+               bool
+               prompt "External toolchain uses uClibc" if DEVEL
+               depends EXTERNAL_TOOLCHAIN && !NATIVE_TOOLCHAIN
+               help
+                  If enabled, OpenWrt will treat the external toolchain as a 
uClibc toolchain
+
        config TARGET_NAME
                string
                prompt "Target name"  if DEVEL
@@ -171,7 +178,7 @@ config INSIGHT

 config USE_UCLIBC
        bool
-       default y if !TOOLCHAINOPTS && !EXTERNAL_TOOLCHAIN && !NATIVE_TOOLCHAIN
+       default y if !TOOLCHAINOPTS && !EXTERNAL_TOOLCHAIN && !NATIVE_TOOLCHAIN 
|| EXTERNAL_UCLIBC

 config USE_EXTERNAL_LIBC
        bool
diff --git a/toolchain/Makefile b/toolchain/Makefile
index bdfb29e..2ec1572 100644
--- a/toolchain/Makefile
+++ b/toolchain/Makefile
@@ -29,9 +29,11 @@ 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))
+ifndef CONFIG_EXTERNAL_TOOLCHAIN
 ifdef CONFIG_USE_UCLIBC
   $(curdir)/builddirs += $(LIBC)/utils
 endif
+endif
 $(curdir)/builddirs-compile:=$($(curdir)/builddirs-prepare)
 $(curdir)/builddirs-install:=$($(curdir)/builddirs-compile)

diff --git a/toolchain/wrapper/Makefile b/toolchain/wrapper/Makefile
index 417ed8c..9ae18a3 100644
--- a/toolchain/wrapper/Makefile
+++ b/toolchain/wrapper/Makefile
@@ -53,6 +53,10 @@ endef

 define Host/Install
        $(call toolchain_util,--wrap "$(TOOLCHAIN_DIR)/bin")
+       $(CP) $(CONFIG_TOOLCHAIN_ROOT)/lib/libpthread.so* $(TOOLCHAIN_DIR)/lib
+       $(CP) $(CONFIG_TOOLCHAIN_ROOT)/lib/librt.so* $(TOOLCHAIN_DIR)/lib
+       $(CP) $(CONFIG_TOOLCHAIN_ROOT)/lib/libpthread-*.so $(TOOLCHAIN_DIR)/lib
+       $(CP) $(CONFIG_TOOLCHAIN_ROOT)/lib/librt-*.so $(TOOLCHAIN_DIR)/lib
 endef

 define Host/Clean





-- 
Daniel Dickinson PowerCloud Systems, Palo Alto, CA Senior Firmware Engineer (In 
Canada: Senior Firmware Analyst)
_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to