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.
|