Bug 2767 - Build for lsof broken in buildroot-2010.08
Summary: Build for lsof broken in buildroot-2010.08
Status: RESOLVED FIXED
Alias: None
Product: buildroot
Classification: Unclassified
Component: Other (show other bugs)
Version: unspecified
Hardware: Other Linux
: P5 major
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-04 09:29 UTC by Andy Gibbs
Modified: 2010-11-04 16:17 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments
Error log (19.69 KB, application/octet-stream)
2010-11-04 09:29 UTC, Andy Gibbs
Details
Proposed patch (2.36 KB, patch)
2010-11-04 09:30 UTC, Andy Gibbs
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andy Gibbs 2010-11-04 09:29:35 UTC
Created attachment 2635 [details]
Error log

The build process for the lsof package has been broken in buildroot-2010.08.  In buildroot-2010.05 it was not broken.

The attached build log file shows the error as it occurs.  Note how the compiler options passed to make via CFGF, don't actually get passed to gcc, as should be the case.

The problem has been tracked down to a change made in buildroot: specifically that it now includes CFLAGS="..." in TARGET_CONFIGURE_OPTS, whereas before this was not the case.

However, the Configure script for lsof also generates its own CFLAGS declaration inside the Makefile, which is now overridden by that given by buildroot.  Fortunately, lsof has a partial solution to this problem which is the LSOF_CFLAGS_OVERRIDE=1 configuration option.  CFLAGS from buildroot is still then passed through Configure and incorporated into the CFLAGS declaration inside the Makefile, but then the Makefile declaration of CFLAGS can then be marked 'override' so that when calling make, it continues to build correctly.

Unfortunately, the solution provided by lsof is only partial.  The configuration option only applies to liblsof, not the application itself.

Attached also is a patch file that fixes both this, plus adds the configuration option into the package's lsof.mk file.
Comment 1 Andy Gibbs 2010-11-04 09:30:45 UTC
Created attachment 2641 [details]
Proposed patch
Comment 2 Thomas Petazzoni 2010-11-04 15:36:33 UTC
I've tried to build lsof today, but it fails because the FTP server rejects anonymous logins:


--2010-11-04 16:28:39--  ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof//lsof_4.81.tar.bz2
           => `/home/thomas/local/buildroot-dl/lsof_4.81.tar.bz2'
Resolving lsof.itap.purdue.edu... 128.210.7.20
Connecting to lsof.itap.purdue.edu|128.210.7.20|:21... connected.
Logging in as anonymous ... 
Error in server greeting.
Retrying.

Does it work for you ? If not, we should switch to using the tarball made available by Debian, as we do for some other packages.

Moreover, I'm not terribly happy with the approach. If Buildroot passes some CFLAGS, it's done with reason, so those CFLAGS should be taken into account, not overriden by the package build logic. So rather than having the CFLAGS passed on the command line ignored, I'd prefer to see them *added* to the internal package CFLAGS.
Comment 3 Andy Gibbs 2010-11-04 16:06:29 UTC
Thomas,

I do get it downloading, but it I believe it picks it up from the sources.buildroot.org mirror instead of the ftp site, so maybe best to change to the debian distribution site.

Regarding the use of CFLAGS, inside the Makefile is defined:

CFLAGS= ${CDEFS} ${INCL} ${DEP} ${DEBUG}

which expands to

CFLAGS= ${CDEF} ${CFGF} ${DINC} ${CFGD} ${CFGDN} ${DEBUG}

Now when make is invoked, buildroot's CFLAGS are passed via DEBUG:

$(MAKE) $(TARGET_CONFIGURE_OPTS) DEBUG="$(TARGET_CFLAGS) $(BR2_LSOF_CFLAGS)" -C $(LSOF_DIR)/lsof_$(LSOF_VERSION)_src

However, if TARGET_CONFIGURE_OPTS also holds CFLAGS, then the CFLAGS declared inside the Makefile is overridden and all the additional flags that are required (e.g. from CFGF) are lost.

This is why I have patched it to put the "override" keyword ahead of the Makefile's CFLAGS declaration.  Buildroot's CFLAGS are still sent forward, via DEBUG, so that's not a problem.

Does this explain the situation better?

Cheers
Andy
Comment 4 Andy Gibbs 2010-11-04 16:10:06 UTC
(In reply to comment #3)
> Now when make is invoked, buildroot's CFLAGS are passed via DEBUG:
> [ snip ]

Sorry, I should probably just point out that this is the original behaviour for building the package, not something that I've changed in my patch.  Perhaps this problem is the reason why the original package worked this way?
Comment 5 Peter Korsgaard 2010-11-04 16:17:07 UTC
Committed, thanks