[Scons-users] libraries which need associated flags

Gary Granger granger at ucar.edu
Tue Sep 12 11:02:40 EDT 2017


I don't think scons can detect library dependencies in the LINKFLAGS
variable, so we try to avoid that approach.  We have a similar problem
with libraries that need static linking, and one solution I tried was
replacing the _LIBFLAGS function with a custom wrapper function, so the
-Wl,-Bstatic and -Wl,-Bdynamic flags could be inserted on either side of
the library flag.  I don't know if that's portable, but it's worked so far.

I put the functionality into a tool which you can see here:

https://github.com/ncareol/eol_scons/blob/master/eol_scons/tools/staticlink.py

See the _insert_static_flags() function.  I did not end up using that
approach, as mentioned in the comments, but it is still there in case
you want to see how it could work.  The current approach in that tool is
to replace the library option with the full path to the static library
file, so maybe you need to do that too, as well as inserting the
whole-archive options.

If anyone has another suggestion, I'd like to hear it also.  Wrapping
_LIBFLAGS feels like violating the public API, but it is effective.

gary

On 09/12/2017 08:38 AM, Mats Wichmann wrote:
> If a library needs some flags to go with it, and those flags have to
> stay together with the library, it can't go into LIBS which is "smart"
> so we end up with stuff like this:
>
> env.AppendUnique(LINKFLAGS=[
>     '-Wl,--whole-archive',
>     env.get('BUILD_DIR') + 'libmpmcommon.a',
>     '-Wl,-no-whole-archive',
> ])
>
> Is that the best way to handle this?  (please ignore the local oddity of
> this project of fiddling with BUILD_DIR instead of setting LIBPATH).
> This seems to not be tracking dependencies correctly... scons doesn't
> seem to know the target depends on the library, although I may be
> reading that wrong.
>
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org
> https://pairlist4.pair.net/mailman/listinfo/scons-users



More information about the Scons-users mailing list