Merge "pass cc shared libs as order-only to rustc" am: 0bdbc1c387
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2511855 Change-Id: I51d4360fdcccab26e2214263af1b18f92b6817c7 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -218,6 +218,7 @@ func transformSrctoCrate(ctx ModuleContext, main android.Path, deps PathDeps, fl
|
||||
|
||||
var inputs android.Paths
|
||||
var implicits android.Paths
|
||||
var orderOnly android.Paths
|
||||
var output buildOutput
|
||||
var rustcFlags, linkFlags []string
|
||||
var implicitOutputs android.WritablePaths
|
||||
@@ -285,6 +286,8 @@ func transformSrctoCrate(ctx ModuleContext, main android.Path, deps PathDeps, fl
|
||||
implicits = append(implicits, deps.CrtBegin...)
|
||||
implicits = append(implicits, deps.CrtEnd...)
|
||||
|
||||
orderOnly = append(orderOnly, deps.SharedLibs...)
|
||||
|
||||
if len(deps.SrcDeps) > 0 {
|
||||
moduleGenDir := ctx.RustModule().compiler.CargoOutDir()
|
||||
var outputs android.WritablePaths
|
||||
@@ -331,6 +334,7 @@ func transformSrctoCrate(ctx ModuleContext, main android.Path, deps PathDeps, fl
|
||||
ImplicitOutputs: nil,
|
||||
Inputs: inputs,
|
||||
Implicits: implicits,
|
||||
OrderOnly: orderOnly,
|
||||
Args: map[string]string{
|
||||
"rustcFlags": strings.Join(rustcFlags, " "),
|
||||
"libFlags": strings.Join(libFlags, " "),
|
||||
@@ -349,6 +353,7 @@ func transformSrctoCrate(ctx ModuleContext, main android.Path, deps PathDeps, fl
|
||||
ImplicitOutputs: implicitOutputs,
|
||||
Inputs: inputs,
|
||||
Implicits: implicits,
|
||||
OrderOnly: orderOnly,
|
||||
Args: map[string]string{
|
||||
"rustcFlags": strings.Join(rustcFlags, " "),
|
||||
"linkFlags": strings.Join(linkFlags, " "),
|
||||
@@ -367,6 +372,7 @@ func transformSrctoCrate(ctx ModuleContext, main android.Path, deps PathDeps, fl
|
||||
Output: kytheFile,
|
||||
Inputs: inputs,
|
||||
Implicits: implicits,
|
||||
OrderOnly: orderOnly,
|
||||
Args: map[string]string{
|
||||
"rustcFlags": strings.Join(rustcFlags, " "),
|
||||
"linkFlags": strings.Join(linkFlags, " "),
|
||||
|
@@ -1413,7 +1413,7 @@ func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
|
||||
|
||||
depPaths.RLibs = append(depPaths.RLibs, rlibDepFiles...)
|
||||
depPaths.DyLibs = append(depPaths.DyLibs, dylibDepFiles...)
|
||||
depPaths.SharedLibs = append(depPaths.SharedLibs, sharedLibDepFiles...)
|
||||
depPaths.SharedLibs = append(depPaths.SharedLibs, sharedLibFiles...)
|
||||
depPaths.SharedLibDeps = append(depPaths.SharedLibDeps, sharedLibDepFiles...)
|
||||
depPaths.StaticLibs = append(depPaths.StaticLibs, staticLibDepFiles...)
|
||||
depPaths.ProcMacros = append(depPaths.ProcMacros, procMacroDepFiles...)
|
||||
|
@@ -209,6 +209,10 @@ func TestLinkPathFromFilePath(t *testing.T) {
|
||||
// Test to make sure dependencies are being picked up correctly.
|
||||
func TestDepsTracking(t *testing.T) {
|
||||
ctx := testRust(t, `
|
||||
cc_library {
|
||||
host_supported: true,
|
||||
name: "cc_stubs_dep",
|
||||
}
|
||||
rust_ffi_host_static {
|
||||
name: "libstatic",
|
||||
srcs: ["foo.rs"],
|
||||
@@ -235,6 +239,7 @@ func TestDepsTracking(t *testing.T) {
|
||||
crate_name: "rlib",
|
||||
static_libs: ["libstatic"],
|
||||
whole_static_libs: ["libwholestatic"],
|
||||
shared_libs: ["cc_stubs_dep"],
|
||||
}
|
||||
rust_proc_macro {
|
||||
name: "libpm",
|
||||
@@ -279,6 +284,17 @@ func TestDepsTracking(t *testing.T) {
|
||||
t.Errorf("-lstatic flag not being passed to rustc for static library %#v", rustc.Args["rustcFlags"])
|
||||
}
|
||||
|
||||
if !strings.Contains(rustc.Args["linkFlags"], "cc_stubs_dep.so") {
|
||||
t.Errorf("shared cc_library not being passed to rustc linkFlags %#v", rustc.Args["linkFlags"])
|
||||
}
|
||||
|
||||
if !android.SuffixInList(rustc.OrderOnly.Strings(), "cc_stubs_dep.so") {
|
||||
t.Errorf("shared cc dep not being passed as order-only to rustc %#v", rustc.OrderOnly.Strings())
|
||||
}
|
||||
|
||||
if !android.SuffixInList(rustc.Implicits.Strings(), "cc_stubs_dep.so.toc") {
|
||||
t.Errorf("shared cc dep TOC not being passed as implicit to rustc %#v", rustc.Implicits.Strings())
|
||||
}
|
||||
}
|
||||
|
||||
func TestSourceProviderDeps(t *testing.T) {
|
||||
@@ -331,7 +347,7 @@ func TestSourceProviderDeps(t *testing.T) {
|
||||
source_stem: "bindings",
|
||||
host_supported: true,
|
||||
wrapper_src: "src/any.h",
|
||||
}
|
||||
}
|
||||
`)
|
||||
|
||||
libfoo := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_rlib_dylib-std").Rule("rustc")
|
||||
@@ -371,7 +387,6 @@ func TestSourceProviderDeps(t *testing.T) {
|
||||
if !android.InList("libbindings.rlib-std", libprocmacroMod.Properties.AndroidMkRlibs) {
|
||||
t.Errorf("bindgen dependency not detected as a rlib dependency (dependency missing from AndroidMkRlibs)")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestSourceProviderTargetMismatch(t *testing.T) {
|
||||
|
Reference in New Issue
Block a user