bugGPSD - Bugs: bug #47349, Building with ncurses on FreeBSD...

 
 

bug #47349: Building with ncurses on FreeBSD may crash scons

Submitter:  Fred Wright <fhgwright>
Submitted:  Sat 05 Mar 2016 11:12:12 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  yazug
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 08 Mar 2016 12:03:44 AM UTC, comment #1: 

The workaround suggested at the end of the original post has now been merged, so this bug can be marked fixed.

Fred Wright <fhgwright>
Group Member
Sat 05 Mar 2016 11:12:12 PM UTC, original submission:  

I saw this a while back, but finally tracked down the cause.

Although FreeBSD includes ncurses and tinfo in the base install, in which case pkg-config presumably doesn't report anything (and there's fallback code to handle that),  if ncurses and/or tinfo is installed as a package, pkg-config does provide results, which cause scons to choke.

Sample:

$ pkg-config --libs ncurses
-L/usr/local/lib -rpath /usr/local/lib  -lncurses -ltinfo 

The problem with this is the "-rpath", exacerbating a number of bugs:

1) The "-rpath" itself seems completely superfluous in this case, given that it specifies the same path as the link-time path.  This is presumably a problem with the packaging of ncurses and tinfo (and several other packages not relevant here).  BTW, this is present even when "--static" is supplied to pkg-config, which is pretty severely broken.

2) Scons's ParseFlags() doesn't recognize "-rpath" as a specially handled option (though it does recognize "-Wl,rpath="), so it jut passes it on.  It then assumes that the next item (not considered an option since it lacks a leading dash) must be a file as it passes it through.

3) When it tries to create a "file" node for "/usr/local/lib", it already has a "directory" node by that name (presumably created by the preceding -L option), and throws an exception due to the type mismatch.

4) Nothing within ParseFlags() (or its caller) catches the exception, so it passes up through SConstruct to the top-level scons, which treats it as a fatal error.  Note that it doesn't matter whether the relevant target is actually being built, since it crashes during the setup.

5) Just to make it harder to debug, "--debug=pdb" still exits on uncaught exceptions, rather than handing them off to pdb (and making post-mortem work properly).

Any workaround that requires massaging the flags would first need to rework the pkg-config logic so that pkg-config is run directly in SConstruct, rather than deferring it via the '!pkg-config ...' construct, where its results are hidden within the innards of ParseFlags().  This is probably a good idea in general, since it's better for debugging to be able to view the actual flags from SConstruct breakpoints, but it's a non-trivial change.

However, it looks like there's a cheap fix by exploiting the fact that neither the "--libs-only-L" nor" --libs-only-l" pkg-config optuons include the superfluous "-rpath /usr/local/lib".  To wit:

$ pkg-config --libs-only-L ncurses
-L/usr/local/lib 
$ pkg-config --libs-only-l ncurses
-lncurses -ltinfo 
$ pkg-config --cflags --libs-only-L --libs-only-l ncurses
-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -I/usr/local/include -I/usr/local/include/ncurses -L/usr/local/lib -lncurses -ltinfo 

So a simple tweak of the pkg-config options should be adequate.

Fred Wright <fhgwright>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by yazug (Updated the item)
  • -email is unavailable- added by fhgwright (Submitted the item)
  • -email is unavailable- added by fhgwright
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-03-08 yazug StatusNone Fixed
        Assigned toNone yazug
        Open/ClosedOpen Closed
    2016-03-05 fhgwright Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code