mirror of
https://github.com/aphrody-labs/gn.git
synced 2026-10-14 13:19:22 +00:00
When a C++ `static_library` has `complete_static_lib = true` and depends
on a `rust_library`, the Rust library's symbols need to be available to
downstream consumers of the static library.
This change propagates `rust_library` dependencies through
`complete_static_lib` targets to downstream linking targets (like
executables), similar to how `shared_library` dependencies are handled.
This ensures the `.rlib` files are passed directly to the final linker
via the Ninja `rlibs` variable (using `{{rlibs}}` substitution).
Reproduction error before this change (with mixed C++/Rust example):
```
FAILED: c_main
g++ -o c_main -Wl,--start-group @c_main.rsp -Wl,--end-group
/usr/bin/ld: obj/c_main.c_main.o: in function `main':
c_main.cc:(.text+0x5): undefined reference to `call_from_c'
collect2: error: ld returned 1 exit status
```
Verification success after this change:
```
[1/2] AR libc_lib.a
[2/2] LINK c_main
$ examples/rust_example/out/c_main
Value from c_lib (via Rust): 42
SUCCESS!
```
Bug: 42440276
Change-Id: I7ea3d6df444a25faf2847f59de5303884e0933a1
Reviewed-on: https://gn-review.googlesource.com/c/gn/+/22100
Reviewed-by: Petr Hosek <phosek@google.com>
Commit-Queue: Evan Shrubsole <eshr@google.com>