diff --git a/rust/binary.go b/rust/binary.go index db91ccb9a..5d9b0a67b 100644 --- a/rust/binary.go +++ b/rust/binary.go @@ -95,11 +95,11 @@ func (binary *binaryDecorator) compilerDeps(ctx DepsContext, deps Deps) Deps { if ctx.toolchain().Bionic() { deps = bionicDeps(ctx, deps, Bool(binary.Properties.Static_executable)) if Bool(binary.Properties.Static_executable) { - deps.CrtBegin = "crtbegin_static" + deps.CrtBegin = []string{"crtbegin_static"} } else { - deps.CrtBegin = "crtbegin_dynamic" + deps.CrtBegin = []string{"libc_musl_crtbegin_dynamic"} } - deps.CrtEnd = "crtend_android" + deps.CrtEnd = []string{"libc_musl_crtend"} } return deps diff --git a/rust/builder.go b/rust/builder.go index e66a6f071..00035b9b7 100644 --- a/rust/builder.go +++ b/rust/builder.go @@ -247,9 +247,8 @@ func transformSrctoCrate(ctx ModuleContext, main android.Path, deps PathDeps, fl implicits = append(implicits, deps.srcProviderFiles...) implicits = append(implicits, deps.AfdoProfiles...) - if deps.CrtBegin.Valid() { - implicits = append(implicits, deps.CrtBegin.Path(), deps.CrtEnd.Path()) - } + implicits = append(implicits, deps.CrtBegin...) + implicits = append(implicits, deps.CrtEnd...) if len(deps.SrcDeps) > 0 { moduleGenDir := ctx.RustModule().compiler.CargoOutDir() @@ -319,8 +318,8 @@ func transformSrctoCrate(ctx ModuleContext, main android.Path, deps PathDeps, fl "rustcFlags": strings.Join(rustcFlags, " "), "linkFlags": strings.Join(linkFlags, " "), "libFlags": strings.Join(libFlags, " "), - "crtBegin": deps.CrtBegin.String(), - "crtEnd": deps.CrtEnd.String(), + "crtBegin": strings.Join(deps.CrtBegin.Strings(), " "), + "crtEnd": strings.Join(deps.CrtEnd.Strings(), " "), "envVars": strings.Join(envVars, " "), }, }) diff --git a/rust/library.go b/rust/library.go index bb2e83fdb..9d79c53f2 100644 --- a/rust/library.go +++ b/rust/library.go @@ -428,8 +428,8 @@ func (library *libraryDecorator) compilerDeps(ctx DepsContext, deps Deps) Deps { if ctx.toolchain().Bionic() && (library.dylib() || library.shared()) { deps = bionicDeps(ctx, deps, false) - deps.CrtBegin = "crtbegin_so" - deps.CrtEnd = "crtend_so" + deps.CrtBegin = []string{"crtbegin_so"} + deps.CrtEnd = []string{"crtend_so"} } return deps diff --git a/rust/rust.go b/rust/rust.go index 0f7b76823..8f875bde7 100644 --- a/rust/rust.go +++ b/rust/rust.go @@ -394,7 +394,7 @@ type Deps struct { DataLibs []string DataBins []string - CrtBegin, CrtEnd string + CrtBegin, CrtEnd []string } type PathDeps struct { @@ -421,8 +421,8 @@ type PathDeps struct { depGeneratedHeaders android.Paths depSystemIncludePaths android.Paths - CrtBegin android.OptionalPath - CrtEnd android.OptionalPath + CrtBegin android.Paths + CrtEnd android.Paths // Paths to generated source files SrcDeps android.Paths @@ -1224,9 +1224,9 @@ func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps { depPaths.depSystemIncludePaths = append(depPaths.depSystemIncludePaths, exportedInfo.SystemIncludeDirs...) depPaths.depGeneratedHeaders = append(depPaths.depGeneratedHeaders, exportedInfo.GeneratedHeaders...) case depTag == cc.CrtBeginDepTag: - depPaths.CrtBegin = linkObject + depPaths.CrtBegin = append(depPaths.CrtBegin, linkObject.Path()) case depTag == cc.CrtEndDepTag: - depPaths.CrtEnd = linkObject + depPaths.CrtEnd = append(depPaths.CrtEnd, linkObject.Path()) } // Make sure these dependencies are propagated @@ -1432,13 +1432,13 @@ func (mod *Module) DepsMutator(actx android.BottomUpMutatorContext) { actx.AddVariationDependencies(nil, cc.HeaderDepTag(), deps.HeaderLibs...) crtVariations := cc.GetCrtVariations(ctx, mod) - if deps.CrtBegin != "" { + for _, crt := range deps.CrtBegin { actx.AddVariationDependencies(crtVariations, cc.CrtBeginDepTag, - cc.RewriteSnapshotLib(deps.CrtBegin, cc.GetSnapshot(mod, &snapshotInfo, actx).Objects)) + cc.RewriteSnapshotLib(crt, cc.GetSnapshot(mod, &snapshotInfo, actx).Objects)) } - if deps.CrtEnd != "" { + for _, crt := range deps.CrtEnd { actx.AddVariationDependencies(crtVariations, cc.CrtEndDepTag, - cc.RewriteSnapshotLib(deps.CrtEnd, cc.GetSnapshot(mod, &snapshotInfo, actx).Objects)) + cc.RewriteSnapshotLib(crt, cc.GetSnapshot(mod, &snapshotInfo, actx).Objects)) } if mod.sourceProvider != nil {