diff mbox

[OpenWrt-Devel,1/1,buildroot] Fix for liblzma breaks redhat-like systems

Message ID 20150810153021.796FC23A1534@danielcent.thecshore.com
State Changes Requested
Headers show

Commit Message

Daniel Dickinson Aug. 9, 2015, 3:50 a.m. UTC
On RedHat/Fedora and derivatives we must use the system liblzma
from xz-devel because the liblzma in tools/xz breaks these
systems due to system tools (which use liblzma) having
missing symbols when staging_dir/host/lib has liblzma
(because buildroot puts staging_dir/host/lib first in
library load path and therefore all binaries not just
buildroot's binaries use liblzma from staging_dir/host/lib, at
least while building OpenWrt).

Closes: 20134
Signed-off-by: Daniel Dickinson <openwrt@daniel.thecshore.com>
---
 include/host.mk          |  7 ++++++-
 include/prereq-build.mk  |  7 +++++++
 tools/Makefile           | 11 ++++++++---
 tools/squashfs4/Makefile |  2 +-
 4 files changed, 22 insertions(+), 5 deletions(-)

Comments

Hauke Mehrtens Aug. 15, 2015, 2:37 p.m. UTC | #1
On 08/09/2015 05:50 AM, Daniel Dickinson wrote:
> On RedHat/Fedora and derivatives we must use the system liblzma
> from xz-devel because the liblzma in tools/xz breaks these
> systems due to system tools (which use liblzma) having
> missing symbols when staging_dir/host/lib has liblzma
> (because buildroot puts staging_dir/host/lib first in
> library load path and therefore all binaries not just
> buildroot's binaries use liblzma from staging_dir/host/lib, at
> least while building OpenWrt).
> 
> Closes: 20134
> Signed-off-by: Daniel Dickinson <openwrt@daniel.thecshore.com>
> ---
>  include/host.mk          |  7 ++++++-
>  include/prereq-build.mk  |  7 +++++++
>  tools/Makefile           | 11 ++++++++---
>  tools/squashfs4/Makefile |  2 +-
>  4 files changed, 22 insertions(+), 5 deletions(-)
> 
Please check if your patch is still needed with r46603
https://dev.openwrt.org/changeset/46603

Hauke
John Crispin Aug. 16, 2015, 3:44 p.m. UTC | #2
On 15/08/2015 16:37, Hauke Mehrtens wrote:
> On 08/09/2015 05:50 AM, Daniel Dickinson wrote:
>> On RedHat/Fedora and derivatives we must use the system liblzma
>> from xz-devel because the liblzma in tools/xz breaks these
>> systems due to system tools (which use liblzma) having
>> missing symbols when staging_dir/host/lib has liblzma
>> (because buildroot puts staging_dir/host/lib first in
>> library load path and therefore all binaries not just
>> buildroot's binaries use liblzma from staging_dir/host/lib, at
>> least while building OpenWrt).
>>
>> Closes: 20134
>> Signed-off-by: Daniel Dickinson <openwrt@daniel.thecshore.com>
>> ---
>>  include/host.mk          |  7 ++++++-
>>  include/prereq-build.mk  |  7 +++++++
>>  tools/Makefile           | 11 ++++++++---
>>  tools/squashfs4/Makefile |  2 +-
>>  4 files changed, 22 insertions(+), 5 deletions(-)
>>
> Please check if your patch is still needed with r46603
> https://dev.openwrt.org/changeset/46603
> 


Daniel,

did you test the rev hauke named ?

	John
Daniel Dickinson Aug. 17, 2015, 2:44 a.m. UTC | #3
I'll be doing a build shortly.  I haven't had much time this weekend, so 
hopefully I'll have an answer before the busy week starts.

Regards,

Daniel

On 2015-08-16 11:44 AM, John Crispin wrote:
>
>
> On 15/08/2015 16:37, Hauke Mehrtens wrote:
>> On 08/09/2015 05:50 AM, Daniel Dickinson wrote:
>>> On RedHat/Fedora and derivatives we must use the system liblzma
>>> from xz-devel because the liblzma in tools/xz breaks these
>>> systems due to system tools (which use liblzma) having
>>> missing symbols when staging_dir/host/lib has liblzma
>>> (because buildroot puts staging_dir/host/lib first in
>>> library load path and therefore all binaries not just
>>> buildroot's binaries use liblzma from staging_dir/host/lib, at
>>> least while building OpenWrt).
>>>
>>> Closes: 20134
>>> Signed-off-by: Daniel Dickinson <openwrt@daniel.thecshore.com>
>>> ---
>>>   include/host.mk          |  7 ++++++-
>>>   include/prereq-build.mk  |  7 +++++++
>>>   tools/Makefile           | 11 ++++++++---
>>>   tools/squashfs4/Makefile |  2 +-
>>>   4 files changed, 22 insertions(+), 5 deletions(-)
>>>
>> Please check if your patch is still needed with r46603
>> https://dev.openwrt.org/changeset/46603
>>
>
>
> Daniel,
>
> did you test the rev hauke named ?
>
> 	John
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
>
Daniel Dickinson Aug. 19, 2015, 11:31 p.m. UTC | #4
This resolves the build issue on CentOS.

On 2015-08-15 10:37 AM, Hauke Mehrtens wrote:
> On 08/09/2015 05:50 AM, Daniel Dickinson wrote:
>> On RedHat/Fedora and derivatives we must use the system liblzma
>> from xz-devel because the liblzma in tools/xz breaks these
>> systems due to system tools (which use liblzma) having
>> missing symbols when staging_dir/host/lib has liblzma
>> (because buildroot puts staging_dir/host/lib first in
>> library load path and therefore all binaries not just
>> buildroot's binaries use liblzma from staging_dir/host/lib, at
>> least while building OpenWrt).
>>
>> Closes: 20134
>> Signed-off-by: Daniel Dickinson <openwrt@daniel.thecshore.com>
>> ---
>>   include/host.mk          |  7 ++++++-
>>   include/prereq-build.mk  |  7 +++++++
>>   tools/Makefile           | 11 ++++++++---
>>   tools/squashfs4/Makefile |  2 +-
>>   4 files changed, 22 insertions(+), 5 deletions(-)
>>
> Please check if your patch is still needed with r46603
> https://dev.openwrt.org/changeset/46603
>
> Hauke
>
diff mbox

Patch

diff --git a/include/host.mk b/include/host.mk
index ec3ae27..fc55b63 100644
--- a/include/host.mk
+++ b/include/host.mk
@@ -45,7 +45,12 @@  $(TMP_DIR)/.host.mk: $(TOPDIR)/include/host.mk
 			echo "FIND_L=find -L \$$(1)" >> $@; \
 		else \
 			echo "FIND_L=find \$$(1) -follow" >> $@; \
-		fi \
+		fi ; \
+		[ -r /etc/os-release ] && \
+			eval "$$(cat /etc/os-release)" && \
+				echo "$$ID_LIKE" | grep -qE '(rhel|fedora)' && \
+					[ "$$VERSION_ID" -ge 7 ] && \
+						echo "USE_HOST_LZMA:=1" >> $@ \
 	) >/dev/null 2>/dev/null
 
 endif
diff --git a/include/prereq-build.mk b/include/prereq-build.mk
index 211201a..312eabf 100644
--- a/include/prereq-build.mk
+++ b/include/prereq-build.mk
@@ -70,6 +70,13 @@  $(eval $(call TestHostCommand,libssl, \
 	echo 'int main(int argc, char **argv) { SSL_library_init(); return 0; }' | \
 		gcc -include openssl/ssl.h -x c -o $(TMP_DIR)/a.out - -lcrypto -lssl))
 
+ifeq ($(USE_HOST_LZMA),1)
+$(eval $(call TestHostCommand,liblzma, \
+	Please install xz development package.  (Missing liblzma.so or lzma.h), \
+	echo 'int main(int argc, char **argv) { lzma_stream strm = LZMA_STREAM_INIT; lzma_ret ret = lzma_easy_encoder(&strm, 1, LZMA_CHECK_CRC64); if (ret == LZMA_OK) { lzma_end(&strm); return 0; } else { return -1; } }' | \
+		gcc -include lzma.h -x c -o $(TMP_DIR)/a.out - -llzma))
+endif
+
 
 $(eval $(call SetupHostCommand,tar,Please install GNU 'tar', \
 	gtar --version 2>&1 | grep GNU, \
diff --git a/tools/Makefile b/tools/Makefile
index 60041dd..a4bc127 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -27,7 +27,10 @@  tools-$(BUILD_TOOLCHAIN) += gmp mpfr mpc libelf expat
 tools-y += m4 libtool autoconf automake flex bison pkg-config sed mklibs
 tools-y += sstrip make-ext4fs e2fsprogs mtd-utils mkimage
 tools-y += firmware-utils patch-image patch quilt yaffs2 flock padjffs2
-tools-y += mm-macros missing-macros xz cmake scons bc findutils gengetopt patchelf
+tools-y += mm-macros missing-macros cmake scons bc findutils gengetopt patchelf
+ifneq ($(USE_HOST_LZMA),1)
+tools-y += xz
+endif
 tools-$(CONFIG_TARGET_orion_generic) += wrt350nv2-builder upslug2
 tools-$(CONFIG_powerpc) += upx
 tools-$(CONFIG_TARGET_x86) += qemu
@@ -45,16 +48,18 @@  $(curdir)/flex/compile := $(curdir)/libtool/install
 $(curdir)/pkg-config/compile := $(curdir)/sed/install
 $(curdir)/libtool/compile := $(curdir)/sed/install $(curdir)/m4/install $(curdir)/autoconf/install $(curdir)/automake/install $(curdir)/missing-macros/install
 $(curdir)/squashfs/compile := $(curdir)/lzma-old/install
+ifneq ($(USE_HOST_LZMA),1)
 $(curdir)/squashfs4/compile := $(curdir)/xz/install
+endif
 $(curdir)/quilt/compile := $(curdir)/sed/install $(curdir)/autoconf/install $(curdir)/findutils/install
 $(curdir)/autoconf/compile := $(curdir)/m4/install
-$(curdir)/automake/compile := $(curdir)/m4/install $(curdir)/autoconf/install $(curdir)/pkg-config/install $(curdir)/xz/install
+$(curdir)/automake/compile := $(curdir)/m4/install $(curdir)/autoconf/install $(curdir)/pkg-config/install $(if $(filter 1,$(USE_HOST_LZMA)),,$(curdir)/xz/install)
 $(curdir)/gmp/compile := $(curdir)/libtool/install
 $(curdir)/mpc/compile := $(curdir)/mpfr/install $(curdir)/gmp/install
 $(curdir)/mpfr/compile := $(curdir)/gmp/install
 $(curdir)/ppl/compile := $(curdir)/gmp/install
 $(curdir)/cloog/compile := $(curdir)/ppl/install
-$(curdir)/mtd-utils/compile := $(curdir)/e2fsprogs/install $(curdir)/xz/install
+$(curdir)/mtd-utils/compile := $(curdir)/e2fsprogs/install $(if $(filter 1,$(USE_HOST_LZMA)),,$(curdir)/xz/install)
 $(curdir)/mkimage/compile := $(curdir)/sed/install
 $(curdir)/mklibs/compile := $(curdir)/libtool/install
 $(curdir)/qemu/compile := $(curdir)/e2fsprogs/install
diff --git a/tools/squashfs4/Makefile b/tools/squashfs4/Makefile
index 50b70fb..2c0ee0d 100644
--- a/tools/squashfs4/Makefile
+++ b/tools/squashfs4/Makefile
@@ -24,7 +24,7 @@  define Host/Compile
 		XZ_SUPPORT=1 \
 		LZMA_XZ_SUPPORT=1 \
 		XATTR_SUPPORT= \
-		LZMA_LIB="$(STAGING_DIR_HOST)/lib/liblzma.a" \
+		$(if $(filter 1,$(USE_HOST_LZMA)),,LZMA_LIB="$(STAGING_DIR_HOST)/lib/liblzma.a") \
 		EXTRA_CFLAGS="-I$(STAGING_DIR_HOST)/include" \
 		mksquashfs unsquashfs
 endef