Question: I have a library that only interacts in static scope with an application. This requires me to link the library with the `--whole-archive` option to avoid the linker from "optimizing" out the library (this is done because the linker never actually sees my library being used).

The issue is that I haven't found a way to add this linker option for a specific library in scons. 

```
env.Append(LIBS=['mylib']) #I don't have the linker option
env.Append(LINKFLAGS=['-Wl,--whole-archive','-lmylib']) #I don't add myself to the scons dependency tree, I also get added to the link line before the LIBPATH variable.

```

How do I support linker flags elegantly in scons?

Answer: 
Scons *still* doesn't support link flags such as `-Wl,--whole-archive`. Using the solution provided by Kenneth E. Bellock is has been working well for many years. The downside is that this is error prone. You have to be careful to manage your manual dependency list.

There is an alternate workaround. Add the following to your SConstruct file:

```
whole_archive = env.Command('-Wl,--whole-archive', [], '')
no_whole_archive = env.Command('-Wl,--no-whole-archive', [], '')

```

Now you can wrap the necessary libraries with whole-archive/no-whole-archive in any combination. Example:

```
so_libs = env.SharedLibrary('myso', whole_archive+['libfoo1.a']+no_whole_archive+['libbar.a']+whole_archive+['libfoo2.a']+no_whole_archive)

```
You can add LIBS and LINKFLAGS to your linker statement.

```
env.SharedLibrary('target',sources,LIBS=['mylib'],LINKFLAGS=env['LINKFLAGS']+['-Wl,--whole-archive','-lmylib'])

```

For example.