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
This commit is contained in:
parent
41f7a4a788
commit
fe605e14ee
4 changed files with 18 additions and 19 deletions
|
@ -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
|
||||
|
|
|
@ -246,9 +246,8 @@ func transformSrctoCrate(ctx ModuleContext, main android.Path, deps PathDeps, fl
|
|||
implicits = append(implicits, deps.SharedLibDeps...)
|
||||
implicits = append(implicits, deps.srcProviderFiles...)
|
||||
|
||||
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()
|
||||
|
@ -318,8 +317,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, " "),
|
||||
},
|
||||
})
|
||||
|
|
|
@ -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
|
||||
|
|
18
rust/rust.go
18
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 {
|
||||
|
|
Loading…
Reference in a new issue