)]}'
{
  "commit": "dcd874cd2e10d576c39160a63c1176a77ea07e3b",
  "tree": "7e54691cad149c34f372453134832f33fe1b8c6e",
  "parents": [
    "bd99dbf98cbdefe18a4128189665c5761263bcfb"
  ],
  "author": {
    "name": "danakj",
    "email": "danakj@chromium.org",
    "time": "Thu Mar 24 16:18:07 2022 -0400"
  },
  "committer": {
    "name": "Commit Bot",
    "email": "commit-bot@chromium.org",
    "time": "Fri Mar 25 19:37:51 2022 +0000"
  },
  "message": "Make library inheritance for consistent for Rust libraries\n\nPreviously C libraries, and CDYLIB libraries would be inherited for\nlinking through an rlib. But DYLIB libraries would not be. Proc macros\nwould be inherited through a group, but not through a Rust library. And\nproc macros would be inherited for linking as a direct dependency but\nnot as a transitive one.\n\nThere was inconsistency of what Rust targets should be inherited (ie\ncollected) for linking by a C linking target.\n\nWe improve this by removing or consolidating conditionals, which helps\nto make the system more consistent.\n\na) Don\u0027t inherit transitive libraries through a Rust Dylib or Rlib\n   differently than other final or non-final targets respectively.\n   For linking purposes they are the same.\n\nb) Since inherited_libraries_ and rust_linkable_inherited_libs_ are now\n   the same thing, we can remove the latter.\n\nc) Consistently avoid adding proc macros, or their dependencies, to\n   inherited_libraries_, as they are never linked into a final target.\n   They are only passed to the Rust compiler with --extern.\n\nThe NinjaCBinaryTargetWriterTest.LinkingWithRustLibraryDepsOnDylib test\ndemonstrates the bug fix, which allows Rust Dylib targets to be\ninherited into the linker through an rlib.\n\nThe NinjaCBinaryTargetWriterTest.LinkingWithRustLibraryDepsOnCdylib\ntest passed before this change, but provides a regression test.\n\nThe NinjaRustBinaryTargetWriterTest.DylibDeps test was inadvertently\ndemonstrating the bug as well, but for public deps through a Dylib. A\nbinary depended a dylib (\"direct\") which then transitively publicly-\ndepended on another dylib (\"mylib\"). Since the binary has access to\nmylib and could make calls to it, the transitive shared library needs\nto be included in the inherited libraries of the binary as well. That\nway if the binary was linked by a C linker, it would know all the\nrequired Rust libraries. This is now done. We augment the test to also\nshow that a private dependency from the middle dylib (\"direct\") onto\nanother dylib (\"private_dylib\") will not add the private-transitive\nshared library into the linker for the binary.\n\nThe NinjaRustBinaryTargetWriterTest.RlibDepsAcrossGroups test\nchanges to not inherit implicit dependencies on proc macro libraries,\nas they would not need to be linked with the Rust library by a C linker.\nThis more accurately represents to a C linker what the Rust linker would\nimplicitly do. While the proc-macro is given to rustc in a --extern flag\nthe Rust compiler would not add it to the linking line.\n\nThe NinjaRustBinaryTargetWriterTest.GroupDeps test has a binary that\ndepends on a group which publicly-depends on an rlib. Rlibs were not\nnormally inherited (by checking !RustValues::IsRustLibrary()) however\nsince it was through a group, it was being inherited for linking\nincorrectly.\n\nAn example of a BUILD.gn which failed to link (missing symbols from the\ndylib) before this change, but builds after:\n\nshared_library(\"rust_so\") {\n  crate_type \u003d \"dylib\"\n  crate_root \u003d \"rust_so.rs\"\n  sources \u003d [ \"rust_so.rs\" ]\n}\n\nrust_library(\"rust_stdlib\") {\n  crate_type \u003d \"staticlib\"\n  crate_root \u003d \"rust_lib.rs\"\n}\n\nrust_library(\"rust_lib\") {\n  crate_root \u003d \"rust_lib.rs\"\n  sources \u003d [ \"rust_lib.rs\" ]\n  deps \u003d [\":rust_so\"]\n}\n\nexecutable(\"exe\") {\n  sources \u003d [ \"exe.c\" ]\n  deps \u003d [\n    \":rust_lib\",\n  ]\n}\n\nThis also fixes a bug in the RUST_LIBRARY branch that is no longer a\nspecial case, and thus removes the bug. We were inheriting all\ntransitive dependencies from _ourselves_ when depending on an rlib,\nwhich would incorrectly pull in transitive dependencies from previously\ntraversed dependencies. In particular if one of those was a shared\nlibrary, we\u0027d pull in things that were private deps in the shared\nlibrary and linked into it, and which should not be visible/inherited\ninto the current target.\n\nWe add a test which brackets an rlib dependency with shared library\ndependencies and verifies the static libs inside the shared libraries\ndo not get inherited (which they do before this CL).\n\nBug: 276\nChange-Id: Ie50ea2ae21fc6da7dcdbb7259726f67f74c61beb\nReviewed-on: https://gn-review.googlesource.com/c/gn/+/13180\nReviewed-by: Tyler Mandry \u003ctmandry@google.com\u003e\nReviewed-by: David Turner \u003cdigit@google.com\u003e\nReviewed-by: Brett Wilson \u003cbrettw@chromium.org\u003e\nCommit-Queue: Brett Wilson \u003cbrettw@chromium.org\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "213505e535e5b730082e5a0816e183835bc7129c",
      "old_mode": 33188,
      "old_path": "src/gn/ninja_c_binary_target_writer.cc",
      "new_id": "5f3afcb9f2ebd622a85d2adb9c834b33d4a88c70",
      "new_mode": 33188,
      "new_path": "src/gn/ninja_c_binary_target_writer.cc"
    },
    {
      "type": "modify",
      "old_id": "630ba28455a21a0e8d6b41e53fd616619d111cae",
      "old_mode": 33188,
      "old_path": "src/gn/ninja_c_binary_target_writer_unittest.cc",
      "new_id": "2aafe92ae99209412efd7b46f3e685e186a07a2a",
      "new_mode": 33188,
      "new_path": "src/gn/ninja_c_binary_target_writer_unittest.cc"
    },
    {
      "type": "modify",
      "old_id": "cc77bfcfa92b96df980db5e127588c062fc5d15e",
      "old_mode": 33188,
      "old_path": "src/gn/ninja_rust_binary_target_writer_unittest.cc",
      "new_id": "308e742afa0d17eeaab1890c60d9b6fda573fe96",
      "new_mode": 33188,
      "new_path": "src/gn/ninja_rust_binary_target_writer_unittest.cc"
    },
    {
      "type": "modify",
      "old_id": "53c6510ff0aeb48598ad2b6e90a1e884d7ea1d38",
      "old_mode": 33188,
      "old_path": "src/gn/target.cc",
      "new_id": "55649d49a286de3cbc296472316804314cfb3b10",
      "new_mode": 33188,
      "new_path": "src/gn/target.cc"
    },
    {
      "type": "modify",
      "old_id": "31d4e3aa3202ed2ca9c882487d2e52f642af5f58",
      "old_mode": 33188,
      "old_path": "src/gn/target.h",
      "new_id": "de076a84dbfb10ffee51c588018d76816afa2ff1",
      "new_mode": 33188,
      "new_path": "src/gn/target.h"
    }
  ]
}
