0

我使用 gn 作为我的构建系统,我想用“-whole-archive”来定位另一个目标,但我发现似乎没有办法做到这一点?

我需要的是这样的:

clang++ -o libmy.so -Wl,--start-group libA.a libB.a -Wl,-whole-archive libC.a -Wl,-no-whole-archive -Wl,--end-group
  1. --start-group 和 --end-group 中的 libA.a 和 libB.a
  2. libC.a 在 -whole-archive 和 -no-whole-archive

谢谢

4

1 回答 1

0

GN 似乎不支持此用例。但是,尝试构建libC为 asource_set而不是 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.

将每个目标文件libC直接放在链接行上与使用-Wl,--whole-archive.

于 2022-02-06T15:32:56.373 回答