Support cc_object modules in mixed builds

Test: With a handwritten conversion of crtbegin_so1, USE_BAZEL_ANALYSIS=1 m crtbegin_so1
Change-Id: I7c777d7f46b37aa1827cc04205e2014f9293bf35
This commit is contained in:
Chris Parsons
2021-02-22 16:13:50 -05:00
parent c572b5bf62
commit 8d6e433c1e
5 changed files with 329 additions and 53 deletions

View File

@@ -46,6 +46,26 @@ type objectLinker struct {
Properties ObjectLinkerProperties
}
type objectBazelHandler struct {
bazelHandler
module *Module
}
func (handler *objectBazelHandler) generateBazelBuildActions(ctx android.ModuleContext, label string) bool {
bazelCtx := ctx.Config().BazelContext
objPaths, ok := bazelCtx.GetCcObjectFiles(label, ctx.Arch().ArchType)
if ok {
if len(objPaths) != 1 {
ctx.ModuleErrorf("expected exactly one object file for '%s', but got %s", label, objPaths)
return false
}
handler.module.outputFile = android.OptionalPathForPath(android.PathForBazelOut(ctx, objPaths[0]))
}
return ok
}
type ObjectLinkerProperties struct {
// list of modules that should only provide headers for this module.
Header_libs []string `android:"arch_variant,variant_prepend"`
@@ -80,6 +100,7 @@ func ObjectFactory() android.Module {
baseLinker: NewBaseLinker(module.sanitize),
}
module.compiler = NewBaseCompiler()
module.bazelHandler = &objectBazelHandler{module: module}
// Clang's address-significance tables are incompatible with ld -r.
module.compiler.appendCflags([]string{"-fno-addrsig"})