Optimizations to abi checking.
We now add export_static_lib_headers, export_generated_headers to the filters while dumping the abi of a library using header-abi-dumper (through -I<dir> additions to the invocation of header-abi-dumper and header-abi-linker) Also add support for zipped reference source based abi dumps. Test: mm -j64 in hardware/interfaces/nfc/default/1.0 produces android.hardware.nfc@1.0.so.lsdump with abi filtered out using generated headers. Test: Copied the linked abi dumps produced by mm -j64 in bionic/libc to prebuilts/abi-dumps/ndk and gzipped them. Ran mm -j64 again in bionic/libc and verified header-abi-diff getting invoked. Bug: 32750600 Change-Id: I26210af908c87a6143e39fa25f50307acb68a387
This commit is contained in:
parent
442b7e6dc9
commit
715cac3971
|
@ -584,10 +584,10 @@ func PathForVndkRefAbiDump(ctx ModuleContext, version, fileName string, vndkOrNd
|
||||||
var vndkOrNdkDir string
|
var vndkOrNdkDir string
|
||||||
var ext string
|
var ext string
|
||||||
if isSourceDump {
|
if isSourceDump {
|
||||||
ext = ".lsdump"
|
ext = ".lsdump.gz"
|
||||||
sourceOrBinaryDir = "source-based"
|
sourceOrBinaryDir = "source-based"
|
||||||
} else {
|
} else {
|
||||||
ext = ".bdump"
|
ext = ".bdump.gz"
|
||||||
sourceOrBinaryDir = "binary-based"
|
sourceOrBinaryDir = "binary-based"
|
||||||
}
|
}
|
||||||
if vndkOrNdk {
|
if vndkOrNdk {
|
||||||
|
|
|
@ -149,6 +149,7 @@ func (library *libraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.An
|
||||||
fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES += ", library.sAbiOutputFile.String())
|
fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES += ", library.sAbiOutputFile.String())
|
||||||
if library.sAbiDiff.Valid() && !library.static() {
|
if library.sAbiDiff.Valid() && !library.static() {
|
||||||
fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES += ", library.sAbiDiff.String())
|
fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES += ", library.sAbiDiff.String())
|
||||||
|
fmt.Fprintln(w, "HEADER_ABI_DIFFS += ", library.sAbiDiff.String())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -158,9 +158,10 @@ var (
|
||||||
|
|
||||||
_ = pctx.SourcePathVariable("sAbiDumper", "prebuilts/build-tools/${config.HostPrebuiltTag}/bin/header-abi-dumper")
|
_ = pctx.SourcePathVariable("sAbiDumper", "prebuilts/build-tools/${config.HostPrebuiltTag}/bin/header-abi-dumper")
|
||||||
|
|
||||||
|
// -w has been added since header-abi-dumper does not need to produce any sort of diagnostic information.
|
||||||
sAbiDump = pctx.AndroidStaticRule("sAbiDump",
|
sAbiDump = pctx.AndroidStaticRule("sAbiDump",
|
||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
Command: "rm -f $out && $sAbiDumper -o ${out} $in $exportDirs -- $cFlags -Wno-packed -Qunused-arguments -isystem ${config.RSIncludePath}",
|
Command: "rm -f $out && $sAbiDumper -o ${out} $in $exportDirs -- $cFlags -w -isystem ${config.RSIncludePath}",
|
||||||
CommandDeps: []string{"$sAbiDumper"},
|
CommandDeps: []string{"$sAbiDumper"},
|
||||||
},
|
},
|
||||||
"cFlags", "exportDirs")
|
"cFlags", "exportDirs")
|
||||||
|
@ -177,6 +178,7 @@ var (
|
||||||
"symbolFile", "arch", "api", "exportedHeaderFlags")
|
"symbolFile", "arch", "api", "exportedHeaderFlags")
|
||||||
|
|
||||||
_ = pctx.SourcePathVariable("sAbiDiffer", "prebuilts/build-tools/${config.HostPrebuiltTag}/bin/header-abi-diff")
|
_ = pctx.SourcePathVariable("sAbiDiffer", "prebuilts/build-tools/${config.HostPrebuiltTag}/bin/header-abi-diff")
|
||||||
|
|
||||||
// Abidiff check turned on in advice-only mode. Builds will not fail on abi incompatibilties / extensions.
|
// Abidiff check turned on in advice-only mode. Builds will not fail on abi incompatibilties / extensions.
|
||||||
sAbiDiff = pctx.AndroidStaticRule("sAbiDiff",
|
sAbiDiff = pctx.AndroidStaticRule("sAbiDiff",
|
||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
|
@ -184,6 +186,11 @@ var (
|
||||||
CommandDeps: []string{"$sAbiDiffer"},
|
CommandDeps: []string{"$sAbiDiffer"},
|
||||||
},
|
},
|
||||||
"referenceDump", "libName", "arch")
|
"referenceDump", "libName", "arch")
|
||||||
|
|
||||||
|
unzipRefSAbiDump = pctx.AndroidStaticRule("unzipRefSAbiDump",
|
||||||
|
blueprint.RuleParams{
|
||||||
|
Command: "gunzip -c $in > $out",
|
||||||
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -631,6 +638,17 @@ func TransformDumpToLinkedDump(ctx android.ModuleContext, sAbiDumps android.Path
|
||||||
return android.OptionalPathForPath(outputFile)
|
return android.OptionalPathForPath(outputFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func UnzipRefDump(ctx android.ModuleContext, zippedRefDump android.Path, baseName string) android.Path {
|
||||||
|
outputFile := android.PathForModuleOut(ctx, baseName+"_ref.lsdump")
|
||||||
|
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
|
||||||
|
Rule: unzipRefSAbiDump,
|
||||||
|
Description: "gunzip" + outputFile.Base(),
|
||||||
|
Output: outputFile,
|
||||||
|
Input: zippedRefDump,
|
||||||
|
})
|
||||||
|
return outputFile
|
||||||
|
}
|
||||||
|
|
||||||
func SourceAbiDiff(ctx android.ModuleContext, inputDump android.Path, referenceDump android.Path,
|
func SourceAbiDiff(ctx android.ModuleContext, inputDump android.Path, referenceDump android.Path,
|
||||||
baseName string) android.OptionalPath {
|
baseName string) android.OptionalPath {
|
||||||
outputFile := android.PathForModuleOut(ctx, baseName+".abidiff")
|
outputFile := android.PathForModuleOut(ctx, baseName+".abidiff")
|
||||||
|
|
12
cc/cc.go
12
cc/cc.go
|
@ -429,8 +429,7 @@ func (ctx *moduleContextImpl) vndk() bool {
|
||||||
|
|
||||||
// Create source abi dumps if the module belongs to the list of VndkLibraries.
|
// Create source abi dumps if the module belongs to the list of VndkLibraries.
|
||||||
func (ctx *moduleContextImpl) createVndkSourceAbiDump() bool {
|
func (ctx *moduleContextImpl) createVndkSourceAbiDump() bool {
|
||||||
return ctx.ctx.Device() && (inList(ctx.baseModuleName(), config.LLndkLibraries())) ||
|
return ctx.ctx.Device() && ((Bool(ctx.mod.Properties.Vendor_available)) || (inList(ctx.baseModuleName(), config.LLndkLibraries())))
|
||||||
(inList(ctx.baseModuleName(), config.VndkLibraries()))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ctx *moduleContextImpl) selectedStl() string {
|
func (ctx *moduleContextImpl) selectedStl() string {
|
||||||
|
@ -920,6 +919,9 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
|
||||||
depPaths.ReexportedFlags = append(depPaths.ReexportedFlags, flags)
|
depPaths.ReexportedFlags = append(depPaths.ReexportedFlags, flags)
|
||||||
depPaths.ReexportedFlagsDeps = append(depPaths.ReexportedFlagsDeps,
|
depPaths.ReexportedFlagsDeps = append(depPaths.ReexportedFlagsDeps,
|
||||||
genRule.GeneratedSourceFiles()...)
|
genRule.GeneratedSourceFiles()...)
|
||||||
|
// Add these re-exported flags to help header-abi-dumper to infer the abi exported by a library.
|
||||||
|
c.sabi.Properties.ReexportedIncludeFlags = append(c.sabi.Properties.ReexportedIncludeFlags, flags)
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ctx.ModuleErrorf("module %q is not a genrule", name)
|
ctx.ModuleErrorf("module %q is not a genrule", name)
|
||||||
|
@ -969,6 +971,12 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
|
||||||
if t.reexportFlags {
|
if t.reexportFlags {
|
||||||
depPaths.ReexportedFlags = append(depPaths.ReexportedFlags, flags...)
|
depPaths.ReexportedFlags = append(depPaths.ReexportedFlags, flags...)
|
||||||
depPaths.ReexportedFlagsDeps = append(depPaths.ReexportedFlagsDeps, deps...)
|
depPaths.ReexportedFlagsDeps = append(depPaths.ReexportedFlagsDeps, deps...)
|
||||||
|
// Add these re-exported flags to help header-abi-dumper to infer the abi exported by a library.
|
||||||
|
// Re-exported flags from shared library dependencies are not included as those shared libraries
|
||||||
|
// will be included in the vndk set.
|
||||||
|
if tag == staticExportDepTag || tag == headerExportDepTag {
|
||||||
|
c.sabi.Properties.ReexportedIncludeFlags = append(c.sabi.Properties.ReexportedIncludeFlags, flags...)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -317,6 +317,27 @@ func (library *libraryDecorator) compilerFlags(ctx ModuleContext, flags Flags) F
|
||||||
return library.baseCompiler.compilerFlags(ctx, flags)
|
return library.baseCompiler.compilerFlags(ctx, flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func extractExportIncludesFromFlags(flags []string) []string {
|
||||||
|
// This method is used in the generation of rules which produce
|
||||||
|
// abi-dumps for source files. Exported headers are needed to infer the
|
||||||
|
// abi exported by a library and filter out the rest of the abi dumped
|
||||||
|
// from a source. We extract the include flags exported by a library.
|
||||||
|
// This includes the flags exported which are re-exported from static
|
||||||
|
// library dependencies, exported header library dependencies and
|
||||||
|
// generated header dependencies. Re-exported shared library include
|
||||||
|
// flags are not in this set since shared library dependencies will
|
||||||
|
// themselves be included in the vndk. -isystem headers are not included
|
||||||
|
// since for bionic libraries, abi-filtering is taken care of by version
|
||||||
|
// scripts.
|
||||||
|
var exportedIncludes []string
|
||||||
|
for _, flag := range flags {
|
||||||
|
if strings.HasPrefix(flag, "-I") {
|
||||||
|
exportedIncludes = append(exportedIncludes, flag)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return exportedIncludes
|
||||||
|
}
|
||||||
|
|
||||||
func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) Objects {
|
func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) Objects {
|
||||||
if !library.buildShared() && !library.buildStatic() {
|
if !library.buildShared() && !library.buildStatic() {
|
||||||
if len(library.baseCompiler.Properties.Srcs) > 0 {
|
if len(library.baseCompiler.Properties.Srcs) > 0 {
|
||||||
|
@ -330,13 +351,15 @@ func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps Pa
|
||||||
}
|
}
|
||||||
return Objects{}
|
return Objects{}
|
||||||
}
|
}
|
||||||
if ctx.createVndkSourceAbiDump() || (library.sabi.Properties.CreateSAbiDumps && ctx.Device()) {
|
if (ctx.createVndkSourceAbiDump() || (library.sabi.Properties.CreateSAbiDumps && ctx.Device())) && !ctx.Vendor() {
|
||||||
exportIncludeDirs := android.PathsForModuleSrc(ctx, library.flagExporter.Properties.Export_include_dirs)
|
exportIncludeDirs := android.PathsForModuleSrc(ctx, library.flagExporter.Properties.Export_include_dirs)
|
||||||
var SourceAbiFlags []string
|
var SourceAbiFlags []string
|
||||||
for _, dir := range exportIncludeDirs.Strings() {
|
for _, dir := range exportIncludeDirs.Strings() {
|
||||||
SourceAbiFlags = append(SourceAbiFlags, "-I "+dir)
|
SourceAbiFlags = append(SourceAbiFlags, "-I"+dir)
|
||||||
|
}
|
||||||
|
for _, reexportedInclude := range extractExportIncludesFromFlags(library.sabi.Properties.ReexportedIncludeFlags) {
|
||||||
|
SourceAbiFlags = append(SourceAbiFlags, reexportedInclude)
|
||||||
}
|
}
|
||||||
|
|
||||||
flags.SAbiFlags = SourceAbiFlags
|
flags.SAbiFlags = SourceAbiFlags
|
||||||
total_length := len(library.baseCompiler.Properties.Srcs) + len(deps.GeneratedSources) + len(library.Properties.Shared.Srcs) +
|
total_length := len(library.baseCompiler.Properties.Srcs) + len(deps.GeneratedSources) + len(library.Properties.Shared.Srcs) +
|
||||||
len(library.Properties.Static.Srcs)
|
len(library.Properties.Static.Srcs)
|
||||||
|
@ -573,7 +596,7 @@ func (library *libraryDecorator) linkShared(ctx ModuleContext,
|
||||||
|
|
||||||
func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, objs Objects, fileName string) {
|
func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, objs Objects, fileName string) {
|
||||||
//Also take into account object re-use.
|
//Also take into account object re-use.
|
||||||
if len(objs.sAbiDumpFiles) > 0 && ctx.createVndkSourceAbiDump() {
|
if len(objs.sAbiDumpFiles) > 0 && ctx.createVndkSourceAbiDump() && !ctx.Vendor() {
|
||||||
refSourceDumpFile := android.PathForVndkRefAbiDump(ctx, "current", fileName, vndkVsNdk(ctx), true)
|
refSourceDumpFile := android.PathForVndkRefAbiDump(ctx, "current", fileName, vndkVsNdk(ctx), true)
|
||||||
versionScript := android.OptionalPathForModuleSrc(ctx, library.Properties.Version_script)
|
versionScript := android.OptionalPathForModuleSrc(ctx, library.Properties.Version_script)
|
||||||
var symbolFile android.OptionalPath
|
var symbolFile android.OptionalPath
|
||||||
|
@ -583,12 +606,16 @@ func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, objs Objec
|
||||||
exportIncludeDirs := android.PathsForModuleSrc(ctx, library.flagExporter.Properties.Export_include_dirs)
|
exportIncludeDirs := android.PathsForModuleSrc(ctx, library.flagExporter.Properties.Export_include_dirs)
|
||||||
var SourceAbiFlags []string
|
var SourceAbiFlags []string
|
||||||
for _, dir := range exportIncludeDirs.Strings() {
|
for _, dir := range exportIncludeDirs.Strings() {
|
||||||
SourceAbiFlags = append(SourceAbiFlags, "-I "+dir)
|
SourceAbiFlags = append(SourceAbiFlags, "-I"+dir)
|
||||||
|
}
|
||||||
|
for _, reexportedInclude := range extractExportIncludesFromFlags(library.sabi.Properties.ReexportedIncludeFlags) {
|
||||||
|
SourceAbiFlags = append(SourceAbiFlags, reexportedInclude)
|
||||||
}
|
}
|
||||||
exportedHeaderFlags := strings.Join(SourceAbiFlags, " ")
|
exportedHeaderFlags := strings.Join(SourceAbiFlags, " ")
|
||||||
library.sAbiOutputFile = TransformDumpToLinkedDump(ctx, objs.sAbiDumpFiles, symbolFile, "current", fileName, exportedHeaderFlags)
|
library.sAbiOutputFile = TransformDumpToLinkedDump(ctx, objs.sAbiDumpFiles, symbolFile, "current", fileName, exportedHeaderFlags)
|
||||||
if refSourceDumpFile.Valid() {
|
if refSourceDumpFile.Valid() {
|
||||||
library.sAbiDiff = SourceAbiDiff(ctx, library.sAbiOutputFile.Path(), refSourceDumpFile.Path(), fileName)
|
unzippedRefDump := UnzipRefDump(ctx, refSourceDumpFile.Path(), fileName)
|
||||||
|
library.sAbiDiff = SourceAbiDiff(ctx, library.sAbiOutputFile.Path(), unzippedRefDump, fileName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ func makeVarsProvider(ctx android.MakeVarsContext) {
|
||||||
ctx.Strict("RS_LLVM_PREBUILTS_VERSION", "${config.RSClangVersion}")
|
ctx.Strict("RS_LLVM_PREBUILTS_VERSION", "${config.RSClangVersion}")
|
||||||
ctx.Strict("RS_LLVM_PREBUILTS_BASE", "${config.RSClangBase}")
|
ctx.Strict("RS_LLVM_PREBUILTS_BASE", "${config.RSClangBase}")
|
||||||
ctx.Strict("RS_LLVM_PREBUILTS_PATH", "${config.RSLLVMPrebuiltsPath}")
|
ctx.Strict("RS_LLVM_PREBUILTS_PATH", "${config.RSLLVMPrebuiltsPath}")
|
||||||
|
ctx.Strict("RS_LLVM_INCLUDES", "${config.RSIncludePath}")
|
||||||
ctx.Strict("RS_CLANG", "${config.RSLLVMPrebuiltsPath}/clang")
|
ctx.Strict("RS_CLANG", "${config.RSLLVMPrebuiltsPath}/clang")
|
||||||
ctx.Strict("RS_LLVM_AS", "${config.RSLLVMPrebuiltsPath}/llvm-as")
|
ctx.Strict("RS_LLVM_AS", "${config.RSLLVMPrebuiltsPath}/llvm-as")
|
||||||
ctx.Strict("RS_LLVM_LINK", "${config.RSLLVMPrebuiltsPath}/llvm-link")
|
ctx.Strict("RS_LLVM_LINK", "${config.RSLLVMPrebuiltsPath}/llvm-link")
|
||||||
|
|
|
@ -22,7 +22,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type SAbiProperties struct {
|
type SAbiProperties struct {
|
||||||
CreateSAbiDumps bool `blueprint:"mutated"`
|
CreateSAbiDumps bool `blueprint:"mutated"`
|
||||||
|
ReexportedIncludeFlags []string
|
||||||
}
|
}
|
||||||
|
|
||||||
type sabi struct {
|
type sabi struct {
|
||||||
|
@ -45,7 +46,7 @@ func (sabimod *sabi) flags(ctx ModuleContext, flags Flags) Flags {
|
||||||
|
|
||||||
func sabiDepsMutator(mctx android.TopDownMutatorContext) {
|
func sabiDepsMutator(mctx android.TopDownMutatorContext) {
|
||||||
if c, ok := mctx.Module().(*Module); ok &&
|
if c, ok := mctx.Module().(*Module); ok &&
|
||||||
((inList(c.Name(), config.VndkLibraries())) || (inList(c.Name(), config.LLndkLibraries())) ||
|
(Bool(c.Properties.Vendor_available) || (inList(c.Name(), config.LLndkLibraries())) ||
|
||||||
(c.sabi != nil && c.sabi.Properties.CreateSAbiDumps)) {
|
(c.sabi != nil && c.sabi.Properties.CreateSAbiDumps)) {
|
||||||
mctx.VisitDirectDeps(func(m blueprint.Module) {
|
mctx.VisitDirectDeps(func(m blueprint.Module) {
|
||||||
tag := mctx.OtherModuleDependencyTag(m)
|
tag := mctx.OtherModuleDependencyTag(m)
|
||||||
|
|
Loading…
Reference in New Issue