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..dff5b15f97c60024f8c256b9605fe69aaa2005b0 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 |
@@ -947,13 +954,14 @@ void NinjaBinaryTargetWriter::ClassifyDependency( |
// multiple definition errors. |
if (can_link_libs) |
AddSourceSetObjectFiles(dep, extra_object_files); |
- |
brettw
2016/04/21 20:47:00
I liked this blank line here as it was before.
|
// Add the source set itself as a non-linkable dependency on the current |
// target. This will make sure that anything the source set's stamp file |
// depends on (like data deps) are also built before the current target |
// 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 { |