From fe605e14ee71dae43d384968fffd3aea7ac53bba Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Sun, 23 Jan 2022 20:46:16 -0800 Subject: Support multiple crtbegin and crtend dependencies Musl libc with an embedded linker uses multiple crtbegin dependencies, convert rust's CrtBegin and CrtEnd to lists. Bug: 190084016 Test: m USE_HOST_MUSL=true host-native Change-Id: Ie843801e87b1f38ace84502d9e4f938a92ec1fa2 --- rust/rust.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'rust/rust.go') diff --git a/rust/rust.go b/rust/rust.go index cba92c33f..ee573fa43 100644 --- a/rust/rust.go +++ b/rust/rust.go @@ -393,7 +393,7 @@ type Deps struct { DataLibs []string DataBins []string - CrtBegin, CrtEnd string + CrtBegin, CrtEnd []string } type PathDeps struct { @@ -419,8 +419,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 @@ -1214,9 +1214,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 @@ -1422,13 +1422,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 { -- cgit v1.2.3-59-g8ed1b From 018cbebd7149afb14a60e84e4fd9c53ff63cd676 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Mon, 24 Jan 2022 17:22:45 -0800 Subject: Support genrules as CrtBegin and CrtEnd in rust Musl will use a genrule output as a linker script in CrtBegin, support genrules as Crt* dependencies. This is equivalent to Ie384089d26459797d0b4b5fef84846507fc508ad in cc. Bug: 216192129 Test: m USE_HOST_MUSL=true host-native Change-Id: Ibc08fdcff7a6bca2a1ec05b781ce929080e211bd --- rust/rust.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'rust/rust.go') diff --git a/rust/rust.go b/rust/rust.go index ee573fa43..0a941bf2d 100644 --- a/rust/rust.go +++ b/rust/rust.go @@ -1224,6 +1224,13 @@ func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps { lib.exportLinkDirs(linkPath) lib.exportLinkObjects(linkObject.String()) } + } else { + switch { + case depTag == cc.CrtBeginDepTag: + depPaths.CrtBegin = append(depPaths.CrtBegin, android.OutputFileForModule(ctx, dep, "")) + case depTag == cc.CrtEndDepTag: + depPaths.CrtEnd = append(depPaths.CrtEnd, android.OutputFileForModule(ctx, dep, "")) + } } if srcDep, ok := dep.(android.SourceFileProducer); ok { -- cgit v1.2.3-59-g8ed1b