OpenWrt Forum Archive

Topic: zlib-static on host system

The content of this topic has been archived on 25 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Recently, when trying to build latest trunk (r33137) I got the message I need to install static libs for zlib on host system.
Well, I did (I am on gentoo x64) and everything seems fine. I just wondered why suddenly the change, up to now, my system lived without static zlib quite well (and was building openwrt for several years too.)

Because we begun to link host utils statically.

If you take a look at one of the upgraded files (i.e., tools/m4/Makefile), you will see a -static switch gets added to the HOST_LDFLAGS as shown below. The question is if it's necessary to build the tools with a zlib static, instead of link, library? I wonder why.

[mazilo@Mi:/opt/openwrt-svn-trunk 295%] ~ svn diff -r PREV tools/m4/Makefile 
Index: tools/m4/Makefile
===================================================================
--- tools/m4/Makefile   (revision 33094)
+++ tools/m4/Makefile   (working copy)
@@ -1,5 +1,5 @@
 # 
-# Copyright (C) 2008 OpenWrt.org
+# Copyright (C) 2008-2012 OpenWrt.org
 #
 # This is free software, licensed under the GNU General Public License v2.
 # See /LICENSE for more information.
@@ -16,6 +16,8 @@
 
 include $(INCLUDE_DIR)/host-build.mk
 
+HOST_LDFLAGS += -static
+
 define Host/Clean
        -$(MAKE) -C $(HOST_BUILD_DIR) uninstall
        $(call Host/Clean/Default)
[mazilo@Mi:/opt/openwrt-svn-trunk 296%] ~

We link statically mainly to make the ImageBuilder portable.
Right now it fails on any distro which is older then the one used on the buildbot due to different library and glibc versions.

For example on Debian 6.0 the current snapshot ImageBuilder used to fail because the host sed referred to not existing glibc symbols, likewise for all the image generation and mtd utils (some of them need zlib).

The discussion might have continued from here.