pass cc shared libs as order-only to rustc
The library file for a cc_shared_library dependency is added to the linkFlags of the rustc compilation action, but no explicit dependency was made on it from a Ninja perspective if a TOC was also present. This change adds the explicit dependency on the library file whether or not a TOC is present. Test: m crosvm Bug: 275416061 Change-Id: I625b62762d9ba7b4fd2b8362285528e47f728dd4
This commit is contained in:
@@ -218,6 +218,7 @@ func transformSrctoCrate(ctx ModuleContext, main android.Path, deps PathDeps, fl
|
|||||||
|
|
||||||
var inputs android.Paths
|
var inputs android.Paths
|
||||||
var implicits android.Paths
|
var implicits android.Paths
|
||||||
|
var orderOnly android.Paths
|
||||||
var output buildOutput
|
var output buildOutput
|
||||||
var rustcFlags, linkFlags []string
|
var rustcFlags, linkFlags []string
|
||||||
var implicitOutputs android.WritablePaths
|
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.CrtBegin...)
|
||||||
implicits = append(implicits, deps.CrtEnd...)
|
implicits = append(implicits, deps.CrtEnd...)
|
||||||
|
|
||||||
|
orderOnly = append(orderOnly, deps.SharedLibs...)
|
||||||
|
|
||||||
if len(deps.SrcDeps) > 0 {
|
if len(deps.SrcDeps) > 0 {
|
||||||
moduleGenDir := ctx.RustModule().compiler.CargoOutDir()
|
moduleGenDir := ctx.RustModule().compiler.CargoOutDir()
|
||||||
var outputs android.WritablePaths
|
var outputs android.WritablePaths
|
||||||
@@ -331,6 +334,7 @@ func transformSrctoCrate(ctx ModuleContext, main android.Path, deps PathDeps, fl
|
|||||||
ImplicitOutputs: nil,
|
ImplicitOutputs: nil,
|
||||||
Inputs: inputs,
|
Inputs: inputs,
|
||||||
Implicits: implicits,
|
Implicits: implicits,
|
||||||
|
OrderOnly: orderOnly,
|
||||||
Args: map[string]string{
|
Args: map[string]string{
|
||||||
"rustcFlags": strings.Join(rustcFlags, " "),
|
"rustcFlags": strings.Join(rustcFlags, " "),
|
||||||
"libFlags": strings.Join(libFlags, " "),
|
"libFlags": strings.Join(libFlags, " "),
|
||||||
@@ -349,6 +353,7 @@ func transformSrctoCrate(ctx ModuleContext, main android.Path, deps PathDeps, fl
|
|||||||
ImplicitOutputs: implicitOutputs,
|
ImplicitOutputs: implicitOutputs,
|
||||||
Inputs: inputs,
|
Inputs: inputs,
|
||||||
Implicits: implicits,
|
Implicits: implicits,
|
||||||
|
OrderOnly: orderOnly,
|
||||||
Args: map[string]string{
|
Args: map[string]string{
|
||||||
"rustcFlags": strings.Join(rustcFlags, " "),
|
"rustcFlags": strings.Join(rustcFlags, " "),
|
||||||
"linkFlags": strings.Join(linkFlags, " "),
|
"linkFlags": strings.Join(linkFlags, " "),
|
||||||
@@ -367,6 +372,7 @@ func transformSrctoCrate(ctx ModuleContext, main android.Path, deps PathDeps, fl
|
|||||||
Output: kytheFile,
|
Output: kytheFile,
|
||||||
Inputs: inputs,
|
Inputs: inputs,
|
||||||
Implicits: implicits,
|
Implicits: implicits,
|
||||||
|
OrderOnly: orderOnly,
|
||||||
Args: map[string]string{
|
Args: map[string]string{
|
||||||
"rustcFlags": strings.Join(rustcFlags, " "),
|
"rustcFlags": strings.Join(rustcFlags, " "),
|
||||||
"linkFlags": strings.Join(linkFlags, " "),
|
"linkFlags": strings.Join(linkFlags, " "),
|
||||||
|
@@ -1413,7 +1413,7 @@ func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
|
|||||||
|
|
||||||
depPaths.RLibs = append(depPaths.RLibs, rlibDepFiles...)
|
depPaths.RLibs = append(depPaths.RLibs, rlibDepFiles...)
|
||||||
depPaths.DyLibs = append(depPaths.DyLibs, dylibDepFiles...)
|
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.SharedLibDeps = append(depPaths.SharedLibDeps, sharedLibDepFiles...)
|
||||||
depPaths.StaticLibs = append(depPaths.StaticLibs, staticLibDepFiles...)
|
depPaths.StaticLibs = append(depPaths.StaticLibs, staticLibDepFiles...)
|
||||||
depPaths.ProcMacros = append(depPaths.ProcMacros, procMacroDepFiles...)
|
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.
|
// Test to make sure dependencies are being picked up correctly.
|
||||||
func TestDepsTracking(t *testing.T) {
|
func TestDepsTracking(t *testing.T) {
|
||||||
ctx := testRust(t, `
|
ctx := testRust(t, `
|
||||||
|
cc_library {
|
||||||
|
host_supported: true,
|
||||||
|
name: "cc_stubs_dep",
|
||||||
|
}
|
||||||
rust_ffi_host_static {
|
rust_ffi_host_static {
|
||||||
name: "libstatic",
|
name: "libstatic",
|
||||||
srcs: ["foo.rs"],
|
srcs: ["foo.rs"],
|
||||||
@@ -235,6 +239,7 @@ func TestDepsTracking(t *testing.T) {
|
|||||||
crate_name: "rlib",
|
crate_name: "rlib",
|
||||||
static_libs: ["libstatic"],
|
static_libs: ["libstatic"],
|
||||||
whole_static_libs: ["libwholestatic"],
|
whole_static_libs: ["libwholestatic"],
|
||||||
|
shared_libs: ["cc_stubs_dep"],
|
||||||
}
|
}
|
||||||
rust_proc_macro {
|
rust_proc_macro {
|
||||||
name: "libpm",
|
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"])
|
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) {
|
func TestSourceProviderDeps(t *testing.T) {
|
||||||
@@ -331,7 +347,7 @@ func TestSourceProviderDeps(t *testing.T) {
|
|||||||
source_stem: "bindings",
|
source_stem: "bindings",
|
||||||
host_supported: true,
|
host_supported: true,
|
||||||
wrapper_src: "src/any.h",
|
wrapper_src: "src/any.h",
|
||||||
}
|
}
|
||||||
`)
|
`)
|
||||||
|
|
||||||
libfoo := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_rlib_dylib-std").Rule("rustc")
|
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) {
|
if !android.InList("libbindings.rlib-std", libprocmacroMod.Properties.AndroidMkRlibs) {
|
||||||
t.Errorf("bindgen dependency not detected as a rlib dependency (dependency missing from AndroidMkRlibs)")
|
t.Errorf("bindgen dependency not detected as a rlib dependency (dependency missing from AndroidMkRlibs)")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSourceProviderTargetMismatch(t *testing.T) {
|
func TestSourceProviderTargetMismatch(t *testing.T) {
|
||||||
|
Reference in New Issue
Block a user