Fix linking deps propagation Rust libraries are not final from the perspective of anything depending on them, but we do need to collect all the link lines of their transitive dependencies in each, and so this removes RUST_LIBRARY from the Target::IsFinal() function, but also adds in an if branch to collect dependent linking information in NinjaBinaryTargetWriter::ClassifyDependency(). Bug: crbug/gn/88 Change-Id: I41dddb5fddbddb41a24b6bb3cd3a72fd0fb07159 Reviewed-on: https://gn-review.googlesource.com/c/gn/+/5260 Reviewed-by: Brett Wilson <brettw@google.com> Commit-Queue: Julie Hockett <juliehockett@google.com>
diff --git a/tools/gn/ninja_binary_target_writer.cc b/tools/gn/ninja_binary_target_writer.cc index 1c0cdd2..3cf7c48 100644 --- a/tools/gn/ninja_binary_target_writer.cc +++ b/tools/gn/ninja_binary_target_writer.cc
@@ -159,6 +159,11 @@ // 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_->output_type() == Target::RUST_LIBRARY && + dep->IsLinkable()) { + // Rust libraries aren't final, but need to have the link lines of all + // transitive deps specified. + 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()) {
diff --git a/tools/gn/target.cc b/tools/gn/target.cc index 7c9cd6d..27dce25 100644 --- a/tools/gn/target.cc +++ b/tools/gn/target.cc
@@ -412,8 +412,7 @@ output_type_ == LOADABLE_MODULE || output_type_ == ACTION || output_type_ == ACTION_FOREACH || output_type_ == COPY_FILES || output_type_ == CREATE_BUNDLE || - (output_type_ == STATIC_LIBRARY && complete_static_lib_) || - output_type_ == RUST_LIBRARY; + (output_type_ == STATIC_LIBRARY && complete_static_lib_); } DepsIteratorRange Target::GetDeps(DepsIterationType type) const { @@ -545,7 +544,7 @@ // library. inherited_libraries_.AppendPublicSharedLibraries(dep->inherited_libraries(), is_public); - } else if (!dep->IsFinal() || dep->output_type() == RUST_LIBRARY) { + } else if (!dep->IsFinal()) { // The current target isn't linked, so propogate linked deps and // libraries up the dependency tree. inherited_libraries_.AppendInherited(dep->inherited_libraries(), is_public); @@ -566,8 +565,7 @@ } // Library settings are always inherited across static library boundaries. - if (!dep->IsFinal() || dep->output_type() == STATIC_LIBRARY || - dep->output_type() == RUST_LIBRARY) { + if (!dep->IsFinal() || dep->output_type() == STATIC_LIBRARY) { all_lib_dirs_.append(dep->all_lib_dirs()); all_libs_.append(dep->all_libs()); }