From 4eeb2a9514a8341623347fcf2bb3e9c459a90219 Mon Sep 17 00:00:00 2001 From: Vinh Tran Date: Mon, 14 Aug 2023 13:29:30 -0400 Subject: [PATCH] Remove dylibs prop from rust module types For device build, rust defaults to dylib linkage for rustlibs deps. `dylibs` prop was provided for flexibility. By removing it, we're enforcing users to either use the default linkage (dylibs for device and rlibs for host) or rlibs prop explicitly. This means no dylibs for host modules. This makes sense because host modules always uses rlib linkage against libstd. The flexibility with dylibs prop opened room for linkage collisions because the dependencies don't link against libstd the same way. Test: go test Change-Id: I2fc221daa8a9bb42bdcf6d9823c723a4ddabe7b5 --- apex/apex_test.go | 2 +- rust/bindgen.go | 2 +- rust/compiler.go | 7 ++----- rust/protobuf.go | 2 +- rust/rust_test.go | 10 ---------- 5 files changed, 5 insertions(+), 18 deletions(-) diff --git a/apex/apex_test.go b/apex/apex_test.go index bd19cb5ef..8368db154 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -390,7 +390,7 @@ func TestBasicApex(t *testing.T) { name: "foo.rust", srcs: ["foo.rs"], rlibs: ["libfoo.rlib.rust"], - dylibs: ["libfoo.dylib.rust"], + rustlibs: ["libfoo.dylib.rust"], apex_available: ["myapex"], } diff --git a/rust/bindgen.go b/rust/bindgen.go index c2bf6af4c..407f2754f 100644 --- a/rust/bindgen.go +++ b/rust/bindgen.go @@ -294,7 +294,7 @@ func (b *bindgenDecorator) SourceProviderProps() []interface{} { // rust_bindgen generates Rust FFI bindings to C libraries using bindgen given a wrapper header as the primary input. // Bindgen has a number of flags to control the generated source, and additional flags can be passed to clang to ensure // the header and generated source is appropriately handled. It is recommended to add it as a dependency in the -// rlibs, dylibs or rustlibs property. It may also be added in the srcs property for external crates, using the ":" +// rlibs or rustlibs property. It may also be added in the srcs property for external crates, using the ":" // prefix. func RustBindgenFactory() android.Module { module, _ := NewRustBindgen(android.HostAndDeviceSupported) diff --git a/rust/compiler.go b/rust/compiler.go index 06ae12f79..84c1fce9b 100644 --- a/rust/compiler.go +++ b/rust/compiler.go @@ -91,10 +91,8 @@ type BaseCompilerProperties struct { // list of rust rlib crate dependencies Rlibs []string `android:"arch_variant"` - // list of rust dylib crate dependencies - Dylibs []string `android:"arch_variant"` - - // list of rust automatic crate dependencies + // list of rust automatic crate dependencies. + // Rustlibs linkage is rlib for host targets and dylib for device targets. Rustlibs []string `android:"arch_variant"` // list of rust proc_macro crate dependencies @@ -359,7 +357,6 @@ func (compiler *baseCompiler) strippedOutputFilePath() android.OptionalPath { func (compiler *baseCompiler) compilerDeps(ctx DepsContext, deps Deps) Deps { deps.Rlibs = append(deps.Rlibs, compiler.Properties.Rlibs...) - deps.Dylibs = append(deps.Dylibs, compiler.Properties.Dylibs...) deps.Rustlibs = append(deps.Rustlibs, compiler.Properties.Rustlibs...) deps.ProcMacros = append(deps.ProcMacros, compiler.Properties.Proc_macros...) deps.StaticLibs = append(deps.StaticLibs, compiler.Properties.Static_libs...) diff --git a/rust/protobuf.go b/rust/protobuf.go index 0cf6e8c97..a14ebeaab 100644 --- a/rust/protobuf.go +++ b/rust/protobuf.go @@ -243,7 +243,7 @@ func (proto *protobufDecorator) SourceProviderDeps(ctx DepsContext, deps Deps) D // rust_protobuf generates protobuf rust code from the provided proto file. This uses the protoc-gen-rust plugin for // protoc. Additional flags to the protoc command can be passed via the proto_flags property. This module type will -// create library variants that can be used as a crate dependency by adding it to the rlibs, dylibs, and rustlibs +// create library variants that can be used as a crate dependency by adding it to the rlibs and rustlibs // properties of other modules. func RustProtobufFactory() android.Module { module, _ := NewRustProtobuf(android.HostAndDeviceSupported) diff --git a/rust/rust_test.go b/rust/rust_test.go index 3f4e29676..704bfe785 100644 --- a/rust/rust_test.go +++ b/rust/rust_test.go @@ -232,11 +232,6 @@ func TestDepsTracking(t *testing.T) { srcs: ["foo.rs"], crate_name: "shared", } - rust_library_host_dylib { - name: "libdylib", - srcs: ["foo.rs"], - crate_name: "dylib", - } rust_library_host_rlib { name: "librlib", srcs: ["foo.rs"], @@ -252,7 +247,6 @@ func TestDepsTracking(t *testing.T) { } rust_binary_host { name: "fizz-buzz", - dylibs: ["libdylib"], rlibs: ["librlib"], proc_macros: ["libpm"], static_libs: ["libstatic"], @@ -265,10 +259,6 @@ func TestDepsTracking(t *testing.T) { rustLink := ctx.ModuleForTests("fizz-buzz", "linux_glibc_x86_64").Rule("rustLink") // Since dependencies are added to AndroidMk* properties, we can check these to see if they've been picked up. - if !android.InList("libdylib", module.Properties.AndroidMkDylibs) { - t.Errorf("Dylib dependency not detected (dependency missing from AndroidMkDylibs)") - } - if !android.InList("librlib.rlib-std", module.Properties.AndroidMkRlibs) { t.Errorf("Rlib dependency not detected (dependency missing from AndroidMkRlibs)") }