diff options
author | 2024-12-17 06:08:02 -0800 | |
---|---|---|
committer | 2024-12-17 06:08:02 -0800 | |
commit | aea639d61264b9b22027d8c274180883d1143ea7 (patch) | |
tree | a52113bf022d30df9b7607d2f15eb686ad8ab435 /rust/rust_test.go | |
parent | 9e1f9b9d73dae437aadd9b204136b2fcc8fc4a98 (diff) | |
parent | 806efd3885d6eecfa1b1bd1697431c0ab073a76a (diff) |
Merge "rust: Alias rust_ffi_rlib to rust_library_rlib" into main
Diffstat (limited to 'rust/rust_test.go')
-rw-r--r-- | rust/rust_test.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/rust/rust_test.go b/rust/rust_test.go index 767508d5f..7e64c0a9e 100644 --- a/rust/rust_test.go +++ b/rust/rust_test.go @@ -547,3 +547,31 @@ func assertString(t *testing.T, got, expected string) { t.Errorf("expected %q got %q", expected, got) } } + +func TestStdLinkMismatch(t *testing.T) { + // Test that we catch cases where the std linkage mismatches. This leads to + // a confusing rustc error where a crate is declared missing despite being + // passed in as a rustlib dependency / via the --extern flag. Thus, we want + // to make sure we detect it in Soong. + + // libfoo depends on libbar as an rlib, but does not link libstd as an rlib. + // libbar only links libstd as an rlib (prefer_rlib). + testRustError(t, "wrong StdLinkage", ` + rust_library { + name: "libfoo", + crate_name: "foo", + srcs: [ + "foo.rs", + ], + rlibs: ["libbar"], + } + rust_library { + name: "libbar", + crate_name: "bar", + srcs: [ + "bar.rs", + ], + prefer_rlib: true, + } + `) +} |