Index: tools/gn/ninja_binary_target_writer.cc |
diff --git a/tools/gn/ninja_binary_target_writer.cc b/tools/gn/ninja_binary_target_writer.cc |
index cb486880fd521a4910d78bf29fde934038508644..30658f21ed155973a44be8c8bced91044a185c2e 100644 |
--- a/tools/gn/ninja_binary_target_writer.cc |
+++ b/tools/gn/ninja_binary_target_writer.cc |
@@ -938,7 +938,14 @@ void NinjaBinaryTargetWriter::ClassifyDependency( |
// don't link at all. |
bool can_link_libs = target_->IsFinal(); |
- if (dep->output_type() == Target::SOURCE_SET) { |
+ if (dep->output_type() == Target::SOURCE_SET || |
+ // If a complete static library depends on an incomplete static library, |
+ // manually link in the object files of the dependent library as if it |
+ // were a source set. This avoids problems with braindead tools such as |
+ // ar which don't properly link dependent static libraries. |
+ (target_->complete_static_lib() && |
+ dep->output_type() == Target::STATIC_LIBRARY && |
+ !dep->complete_static_lib())) { |
// Source sets have their object files linked into final targets |
// (shared libraries, executables, loadable modules, and complete static |
// libraries). Intermediate static libraries and other source sets |
@@ -954,6 +961,8 @@ void NinjaBinaryTargetWriter::ClassifyDependency( |
// can be complete. Otherwise, these will be skipped since this target |
// will depend only on the source set's object files. |
non_linkable_deps->push_back(dep); |
+ } else if (target_->complete_static_lib() && dep->IsFinal()) { |
+ non_linkable_deps->push_back(dep); |
} else if (can_link_libs && dep->IsLinkable()) { |
linkable_deps->push_back(dep); |
} else { |