0

I am using gn as my build system, and I want to some target deps another with " -whole-archive", but I found seem no way to do that?

What I need is something like:

clang++ -o libmy.so -Wl,--start-group libA.a libB.a -Wl,-whole-archive libC.a -Wl,-no-whole-archive -Wl,--end-group
  1. libA.a and libB.a in --start-group and --end-group
  2. libC.a in -whole-archive and -no-whole-archive

Thanks

Hui.Li
  • 399
  • 4
  • 18

1 Answers1

0

GN doesn't appear to support this use case. However, try building libC as a source_set instead of a static_library.

https://gn.googlesource.com/gn/+/master/docs/reference.md#func_source_set

A source set is a collection of sources that get compiled, but are not
linked to produce any kind of library. Instead, the resulting object files
are implicitly added to the linker line of all targets that depend on the
source set.

Putting every object file from libC directly on the link line has the same effect as using -Wl,--whole-archive.

Charles Nicholson
  • 888
  • 1
  • 8
  • 21