Bug 3145

Summary: jffs2 image generation fails
Product: buildroot Reporter: Michael J. Hammel <mjhammel>
Component: Outdated packageAssignee: unassigned
Status: RESOLVED FIXED    
Severity: minor CC: buildroot
Priority: P5    
Version: 2010.05   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Host: Target:
Build:
Attachments: adds --enabled-shared to config options for host build
Update host build/install commands for mtd
Patch for mkfs.ubifs to reference libubi as object module instead of shared lib

Description Michael J. Hammel 2011-01-26 16:15:19 UTC
Created attachment 2881 [details]
adds --enabled-shared to config options for host build

Enabling "Target File Systems->jffs2 root file system" causes the build to fail when it tries to build host prerequisites.  The initial failure is from a lack of a shared library being built for host-lzo:

make[3]: Entering directory `/home/mjhammel/src/cei/system_build/bld/buildroot-2010.05/output/build/host-mtd-1.3.1/mkfs.ubifs'
gcc -I../include -I../ubi-utils/include -D_FILE_OFFSET_BITS=64 -O2 -g -Wall -Wextra -Wwrite-strings -Wno-sign-compare -c -o /home/mjhammel/src/cei/system_build/bld/buildroot-2010.05/output/build/host-mtd-1.3.1/mkfs.ubifs/mkfs.ubifs.o mkfs.ubifs.c -g -Wp,-MD,/home/mjhammel/src/cei/system_build/bld/buildroot-2010.05/output/build/host-mtd-1.3.1/mkfs.ubifs/.mkfs.ubifs.c.dep
gcc -O2 -g -Wall -Wextra -Wwrite-strings -Wno-sign-compare -g -o /home/mjhammel/src/cei/system_build/bld/buildroot-2010.05/output/build/host-mtd-1.3.1/mkfs.ubifs/mkfs.ubifs /home/mjhammel/src/cei/system_build/bld/buildroot-2010.05/output/build/host-mtd-1.3.1/mkfs.ubifs/mkfs.ubifs.o /home/mjhammel/src/cei/system_build/bld/buildroot-2010.05/output/build/host-mtd-1.3.1/mkfs.ubifs/crc16.o /home/mjhammel/src/cei/system_build/bld/buildroot-2010.05/output/build/host-mtd-1.3.1/mkfs.ubifs/crc32.o /home/mjhammel/src/cei/system_build/bld/buildroot-2010.05/output/build/host-mtd-1.3.1/mkfs.ubifs/lpt.o /home/mjhammel/src/cei/system_build/bld/buildroot-2010.05/output/build/host-mtd-1.3.1/mkfs.ubifs/compr.o /home/mjhammel/src/cei/system_build/bld/buildroot-2010.05/output/build/host-mtd-1.3.1/mkfs.ubifs/devtable.o /home/mjhammel/src/cei/system_build/bld/buildroot-2010.05/output/build/host-mtd-1.3.1/mkfs.ubifs/hashtable/hashtable.o /home/mjhammel/src/cei/system_build/bld/buildroot-2010.05/output/build/host-mtd-1.3.1/mkfs.ubifs/hashtable/hashtable_itr.o -lz -llzo2 -lm -luuid -L/home/mjhammel/src/cei/system_build/bld/buildroot-2010.05/output/build/host-mtd-1.3.1/mkfs.ubifs/../ubi-utils/ -lubi
/usr/bin/ld: cannot find -llzo2
collect2: ld returned 1 exit status
make[3]: *** [/home/mjhammel/src/cei/system_build/bld/buildroot-2010.05/output/build/host-mtd-1.3.1/mkfs.ubifs/mkfs.ubifs] Error 1
make[3]: Leaving directory `/home/mjhammel/src/cei/system_build/bld/buildroot-2010.05/output/build/host-mtd-1.3.1/mkfs.ubifs'
make[2]: *** [subdirs_mkfs.ubifs_install] Error 2

A fix for this is attached.  Once fixed, this exposes a bug in the mtd host build and install commands in the mtd.mk.  This is fixed by updating these commands.  I'll add the attachment for this fix after submitting this bug.

Once this is fixed it exposes a bug in the host mtd build where mtd/mkfs.ubifs fails trying to reference a shared object for libubi.  A workaround (which may or may not be a proper fix) is to change the reference in the mkfs.ubifs/Makefile to be a reference to the libubi.o object module instead.  This, at least, allows the build to complete, though it is unclear if mkfs.ubifs actually works since in this scenario I don't think it's used.  I'll add the attachment for this fix after submitting this bug.

I have not been able to test these with 2010.08 or 2010.11 because my 2010.05 configuration, which uses an external glibc Crosstool-NG based toolchain, fails.   I'll ask on the mailing list for help on that one - may just be something foolish I've done.
Comment 1 Michael J. Hammel 2011-01-26 16:16:41 UTC
Created attachment 2887 [details]
Update host build/install commands for mtd
Comment 2 Michael J. Hammel 2011-01-26 16:17:45 UTC
Created attachment 2893 [details]
Patch for mkfs.ubifs to reference libubi as object module instead of shared lib
Comment 3 Peter Korsgaard 2011-01-26 16:44:01 UTC
Getting liblzo to also build shared libs could be a nice extension, but a static lib should work fine as well. From what you quoted the problem seems more to be that gcc wasn't passed the correct -I and -L options for it to search output/host.

We've changed a few things since 2010.05 (and updated to a newer mtd-utils version), and I've just done a test build where I do see the correct -I / -L flags, so the issue seems to be fixed.

I'll add the --enable-shared for host/target builds of liblzo.
Comment 4 Michael J. Hammel 2011-01-26 17:13:32 UTC
I didn't know you could link a static lib with -L<path> -l<lib>.  I always that was for shared libraries only.  If not, I learned something new today. :-)

But if you can reference a static lib that way then the -L path was properly set because the static library was already in the same place the shared library ended up.  Which makes me think it wasn't related to the -L options.  

Anyway, it's an older release issue.  If I can get my 05 config to work with a newer release I'll reverify this is working with the updated mtd.  

Thanks for the quick reply!
Comment 5 Thomas Petazzoni 2011-09-18 16:01:18 UTC
Generating JFFS2 filesystems work just fine with Buildroot 2011.08. This bug has been fixed in multiple ways: the mtd package has been upgraded, host-lzo is now compiled as a shared library.