summaryrefslogtreecommitdiff
path: root/cc
diff options
context:
space:
mode:
Diffstat (limited to 'cc')
-rw-r--r--cc/api_level.go24
-rw-r--r--cc/binary.go2
-rw-r--r--cc/builder.go5
-rw-r--r--cc/cc.go36
-rw-r--r--cc/cc_test.go5
-rw-r--r--cc/config/global.go5
-rw-r--r--cc/image.go7
-rw-r--r--cc/library.go52
-rw-r--r--cc/linker.go31
-rw-r--r--cc/llndk_library.go11
-rwxr-xr-xcc/ndkstubgen/test_ndkstubgen.py29
-rw-r--r--cc/sanitize.go3
-rw-r--r--cc/symbolfile/__init__.py84
-rw-r--r--cc/symbolfile/test_symbolfile.py56
14 files changed, 122 insertions, 228 deletions
diff --git a/cc/api_level.go b/cc/api_level.go
index 69a0d3ae4..3dac571a9 100644
--- a/cc/api_level.go
+++ b/cc/api_level.go
@@ -41,12 +41,25 @@ func MinApiForArch(ctx android.EarlyModuleContext,
}
}
+// Native API levels cannot be less than the MinApiLevelForArch. This function
+// sets the lower bound of the API level with the MinApiLevelForArch.
+func nativeClampedApiLevel(ctx android.BaseModuleContext,
+ apiLevel android.ApiLevel) android.ApiLevel {
+
+ min := MinApiForArch(ctx, ctx.Arch().ArchType)
+
+ if apiLevel.LessThan(min) {
+ return min
+ }
+
+ return apiLevel
+}
+
func nativeApiLevelFromUser(ctx android.BaseModuleContext,
raw string) (android.ApiLevel, error) {
- min := MinApiForArch(ctx, ctx.Arch().ArchType)
if raw == "minimum" {
- return min, nil
+ return MinApiForArch(ctx, ctx.Arch().ArchType), nil
}
value, err := android.ApiLevelFromUser(ctx, raw)
@@ -54,15 +67,12 @@ func nativeApiLevelFromUser(ctx android.BaseModuleContext,
return android.NoneApiLevel, err
}
- if value.LessThan(min) {
- return min, nil
- }
-
- return value, nil
+ return nativeClampedApiLevel(ctx, value), nil
}
func nativeApiLevelOrPanic(ctx android.BaseModuleContext,
raw string) android.ApiLevel {
+
value, err := nativeApiLevelFromUser(ctx, raw)
if err != nil {
panic(err.Error())
diff --git a/cc/binary.go b/cc/binary.go
index 2ac9a45bc..4b77bea64 100644
--- a/cc/binary.go
+++ b/cc/binary.go
@@ -505,7 +505,7 @@ func (binary *binaryDecorator) install(ctx ModuleContext, file android.Path) {
// The original path becomes a symlink to the corresponding file in the
// runtime APEX.
translatedArch := ctx.Target().NativeBridge == android.NativeBridgeEnabled
- if InstallToBootstrap(ctx.baseModuleName(), ctx.Config()) && !ctx.Host() && ctx.directlyInAnyApex() &&
+ if InstallToBootstrap(ctx.baseModuleName(), ctx.Config()) && !ctx.Host() && !ctx.isSdkVariant() &&
!translatedArch && ctx.apexVariationName() == "" && !ctx.inRamdisk() && !ctx.inRecovery() &&
!ctx.inVendorRamdisk() {
diff --git a/cc/builder.go b/cc/builder.go
index 2948ca316..b98bef9be 100644
--- a/cc/builder.go
+++ b/cc/builder.go
@@ -945,7 +945,7 @@ func transformObjToDynamicBinary(ctx android.ModuleContext,
func transformDumpToLinkedDump(ctx android.ModuleContext, sAbiDumps android.Paths, soFile android.Path,
baseName string, exportedIncludeDirs []string, symbolFile android.OptionalPath,
excludedSymbolVersions, excludedSymbolTags, includedSymbolTags []string,
- api string, isLlndk bool) android.Path {
+ api string) android.Path {
outputFile := android.PathForModuleOut(ctx, baseName+".lsdump")
@@ -966,9 +966,6 @@ func transformDumpToLinkedDump(ctx android.ModuleContext, sAbiDumps android.Path
for _, tag := range includedSymbolTags {
symbolFilterStr += " --include-symbol-tag " + tag
}
- if isLlndk {
- symbolFilterStr += " --symbol-tag-policy MatchTagOnly"
- }
apiLevelsJson := android.GetApiLevelsJson(ctx)
implicits = append(implicits, apiLevelsJson)
symbolFilterStr += " --api-map " + apiLevelsJson.String()
diff --git a/cc/cc.go b/cc/cc.go
index 76d01a527..65ab68604 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -341,15 +341,14 @@ type BaseProperties struct {
// If true, always create an sdk variant and don't create a platform variant.
Sdk_variant_only *bool
- AndroidMkSharedLibs []string `blueprint:"mutated"`
- AndroidMkStaticLibs []string `blueprint:"mutated"`
- AndroidMkRlibs []string `blueprint:"mutated"`
- AndroidMkRuntimeLibs []string `blueprint:"mutated"`
- AndroidMkWholeStaticLibs []string `blueprint:"mutated"`
- AndroidMkHeaderLibs []string `blueprint:"mutated"`
- HideFromMake bool `blueprint:"mutated"`
- PreventInstall bool `blueprint:"mutated"`
- ApexesProvidingSharedLibs []string `blueprint:"mutated"`
+ AndroidMkSharedLibs []string `blueprint:"mutated"`
+ AndroidMkStaticLibs []string `blueprint:"mutated"`
+ AndroidMkRlibs []string `blueprint:"mutated"`
+ AndroidMkRuntimeLibs []string `blueprint:"mutated"`
+ AndroidMkWholeStaticLibs []string `blueprint:"mutated"`
+ AndroidMkHeaderLibs []string `blueprint:"mutated"`
+ HideFromMake bool `blueprint:"mutated"`
+ PreventInstall bool `blueprint:"mutated"`
// Set by DepsMutator.
AndroidMkSystemSharedLibs []string `blueprint:"mutated"`
@@ -548,7 +547,6 @@ type ModuleContextIntf interface {
apexSdkVersion() android.ApiLevel
bootstrap() bool
nativeCoverage() bool
- directlyInAnyApex() bool
isPreventInstall() bool
isCfiAssemblySupportEnabled() bool
getSharedFlags() *SharedFlags
@@ -1692,10 +1690,6 @@ func (ctx *moduleContextImpl) nativeCoverage() bool {
return ctx.mod.nativeCoverage()
}
-func (ctx *moduleContextImpl) directlyInAnyApex() bool {
- return ctx.mod.DirectlyInAnyApex()
-}
-
func (ctx *moduleContextImpl) isPreventInstall() bool {
return ctx.mod.Properties.PreventInstall
}
@@ -1885,7 +1879,7 @@ var (
// Returns true if a stub library could be installed in multiple apexes
func (c *Module) stubLibraryMultipleApexViolation(ctx android.ModuleContext) bool {
// If this is not an apex variant, no check necessary
- if !c.InAnyApex() {
+ if info, ok := android.ModuleProvider(ctx, android.ApexInfoProvider); !ok || info.IsForPlatform() {
return false
}
// If this is not a stub library, no check necessary
@@ -3290,18 +3284,6 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
c.Properties.AndroidMkHeaderLibs = append(
c.Properties.AndroidMkHeaderLibs, makeLibName)
case libDepTag.shared():
- if lib := moduleLibraryInterface(dep); lib != nil {
- if lib.buildStubs() && dep.(android.ApexModule).InAnyApex() {
- // Add the dependency to the APEX(es) providing the library so that
- // m <module> can trigger building the APEXes as well.
- depApexInfo, _ := android.OtherModuleProvider(ctx, dep, android.ApexInfoProvider)
- for _, an := range depApexInfo.InApexVariants {
- c.Properties.ApexesProvidingSharedLibs = append(
- c.Properties.ApexesProvidingSharedLibs, an)
- }
- }
- }
-
// Note: the order of libs in this list is not important because
// they merely serve as Make dependencies and do not affect this lib itself.
c.Properties.AndroidMkSharedLibs = append(
diff --git a/cc/cc_test.go b/cc/cc_test.go
index 144b90b94..98af7b655 100644
--- a/cc/cc_test.go
+++ b/cc/cc_test.go
@@ -40,9 +40,6 @@ func TestMain(m *testing.M) {
var prepareForCcTest = android.GroupFixturePreparers(
PrepareForIntegrationTestWithCc,
- android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- variables.VendorApiLevel = StringPtr("202404")
- }),
)
var apexVariationName = "apex28"
@@ -1008,7 +1005,7 @@ func TestLlndkLibrary(t *testing.T) {
android.AssertArrayString(t, "variants for llndk stubs", expected, actual)
params := result.ModuleForTests("libllndk", "android_vendor_arm_armv7-a-neon_shared").Description("generate stub")
- android.AssertSame(t, "use Vendor API level for default stubs", "999999", params.Args["apiLevel"])
+ android.AssertSame(t, "use Vendor API level for default stubs", "35", params.Args["apiLevel"])
checkExportedIncludeDirs := func(module, variant string, expectedSystemDirs []string, expectedDirs ...string) {
t.Helper()
diff --git a/cc/config/global.go b/cc/config/global.go
index 36690d6be..27aac959a 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -290,14 +290,13 @@ var (
"-Wno-error=deprecated", // in external/googletest/googletest
// Disabling until the warning is fixed in libc++abi header files b/366180429
"-Wno-deprecated-dynamic-exception-spec",
- // New warnings to be fixed after clang-r475365
- "-Wno-error=enum-constexpr-conversion", // http://b/243964282
// New warnings to be fixed after clang-r522817
"-Wno-error=invalid-offsetof",
"-Wno-error=thread-safety-reference-return",
// Allow using VLA CXX extension.
"-Wno-vla-cxx-extension",
+ "-Wno-cast-function-type-mismatch",
}
noOverride64GlobalCflags = []string{}
@@ -386,7 +385,7 @@ var (
// prebuilts/clang default settings.
ClangDefaultBase = "prebuilts/clang/host"
- ClangDefaultVersion = "clang-r530567"
+ ClangDefaultVersion = "clang-r536225"
ClangDefaultShortVersion = "19"
// Directories with warnings from Android.bp files.
diff --git a/cc/image.go b/cc/image.go
index ee4048390..9766af3df 100644
--- a/cc/image.go
+++ b/cc/image.go
@@ -179,9 +179,6 @@ type ImageMutatableModule interface {
// SnapshotVersion returns the snapshot version for this module.
SnapshotVersion(mctx android.ImageInterfaceContext) string
- // SdkVersion returns the SDK version for this module.
- SdkVersion() string
-
// ExtraVariants returns the list of extra variants this module requires.
ExtraVariants() []string
@@ -370,7 +367,7 @@ func MutateImage(mctx android.ImageInterfaceContext, m ImageMutatableModule) {
if m.HasProductVariant() {
productVariantNeeded = true
}
- } else if vendorSpecific && m.SdkVersion() == "" {
+ } else if vendorSpecific {
// This will be available in /vendor (or /odm) only
vendorVariantNeeded = true
} else {
@@ -380,7 +377,7 @@ func MutateImage(mctx android.ImageInterfaceContext, m ImageMutatableModule) {
coreVariantNeeded = true
}
- if coreVariantNeeded && productSpecific && m.SdkVersion() == "" {
+ if coreVariantNeeded && productSpecific {
// The module has "product_specific: true" that does not create core variant.
coreVariantNeeded = false
productVariantNeeded = true
diff --git a/cc/library.go b/cc/library.go
index 4ce506e90..ea8794644 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -566,10 +566,16 @@ func (library *libraryDecorator) getHeaderAbiCheckerProperties(m *Module) header
func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) Objects {
if ctx.IsLlndk() {
- futureVendorApiLevel := android.ApiLevelOrPanic(ctx, "999999")
+ // Get the matching SDK version for the vendor API level.
+ version, err := android.GetSdkVersionForVendorApiLevel(ctx.Config().VendorApiLevel())
+ if err != nil {
+ panic(err)
+ }
+
+ // This is the vendor variant of an LLNDK library, build the LLNDK stubs.
nativeAbiResult := parseNativeAbiDefinition(ctx,
String(library.Properties.Llndk.Symbol_file),
- futureVendorApiLevel, "--llndk")
+ nativeClampedApiLevel(ctx, version), "--llndk")
objs := compileStubLibrary(ctx, flags, nativeAbiResult.stubSrc)
if !Bool(library.Properties.Llndk.Unversioned) {
library.versionScriptPath = android.OptionalPathForPath(
@@ -656,7 +662,7 @@ func (library *libraryDecorator) compileModuleLibApiStubs(ctx ModuleContext, fla
// However, having this distinction helps guard accidental
// promotion or demotion of API and also helps the API review process b/191371676
var flag string
- if ctx.Module().(android.ApexModule).NotInPlatform() {
+ if ctx.notInPlatform() {
flag = "--apex"
} else {
flag = "--systemapi"
@@ -740,6 +746,7 @@ type versionedInterface interface {
hasLLNDKStubs() bool
hasLLNDKHeaders() bool
hasVendorPublicLibrary() bool
+ isLLNDKMovedToApex() bool
}
var _ libraryInterface = (*libraryDecorator)(nil)
@@ -1284,15 +1291,14 @@ func (library *libraryDecorator) llndkIncludeDirsForAbiCheck(ctx ModuleContext,
func (library *libraryDecorator) linkLlndkSAbiDumpFiles(ctx ModuleContext,
deps PathDeps, sAbiDumpFiles android.Paths, soFile android.Path, libFileName string,
excludeSymbolVersions, excludeSymbolTags []string,
- vendorApiLevel string) android.Path {
- // NDK symbols in version 34 are LLNDK symbols. Those in version 35 are not.
+ sdkVersionForVendorApiLevel string) android.Path {
return transformDumpToLinkedDump(ctx,
sAbiDumpFiles, soFile, libFileName+".llndk",
library.llndkIncludeDirsForAbiCheck(ctx, deps),
android.OptionalPathForModuleSrc(ctx, library.Properties.Llndk.Symbol_file),
append([]string{"*_PLATFORM", "*_PRIVATE"}, excludeSymbolVersions...),
append([]string{"platform-only"}, excludeSymbolTags...),
- []string{"llndk=" + vendorApiLevel}, "34", true /* isLlndk */)
+ []string{"llndk"}, sdkVersionForVendorApiLevel)
}
func (library *libraryDecorator) linkApexSAbiDumpFiles(ctx ModuleContext,
@@ -1305,7 +1311,7 @@ func (library *libraryDecorator) linkApexSAbiDumpFiles(ctx ModuleContext,
android.OptionalPathForModuleSrc(ctx, library.Properties.Stubs.Symbol_file),
append([]string{"*_PLATFORM", "*_PRIVATE"}, excludeSymbolVersions...),
append([]string{"platform-only"}, excludeSymbolTags...),
- []string{"apex", "systemapi"}, sdkVersion, false /* isLlndk */)
+ []string{"apex", "systemapi"}, sdkVersion)
}
func getRefAbiDumpFile(ctx android.ModuleInstallPathContext,
@@ -1443,7 +1449,7 @@ func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, deps PathD
android.OptionalPathForModuleSrc(ctx, library.symbolFileForAbiCheck(ctx)),
headerAbiChecker.Exclude_symbol_versions,
headerAbiChecker.Exclude_symbol_tags,
- []string{} /* includeSymbolTags */, currSdkVersion, false /* isLlndk */)
+ []string{} /* includeSymbolTags */, currSdkVersion)
var llndkDump, apexVariantDump android.Path
tags := classifySourceAbiDump(ctx.Module().(*Module))
@@ -1451,12 +1457,17 @@ func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, deps PathD
for _, tag := range tags {
if tag == llndkLsdumpTag && currVendorVersion != "" {
if llndkDump == nil {
+ sdkVersion, err := android.GetSdkVersionForVendorApiLevel(currVendorVersion)
+ if err != nil {
+ ctx.ModuleErrorf("Cannot create %s llndk dump: %s", fileName, err)
+ return
+ }
// TODO(b/323447559): Evaluate if replacing sAbiDumpFiles with implDump is faster
llndkDump = library.linkLlndkSAbiDumpFiles(ctx,
deps, objs.sAbiDumpFiles, soFile, fileName,
headerAbiChecker.Exclude_symbol_versions,
headerAbiChecker.Exclude_symbol_tags,
- currVendorVersion)
+ nativeClampedApiLevel(ctx, sdkVersion).String())
}
addLsdumpPath(ctx.Config(), string(tag)+":"+llndkDump.String())
} else if tag == apexLsdumpTag {
@@ -1750,21 +1761,17 @@ func (library *libraryDecorator) installSymlinkToRuntimeApex(ctx ModuleContext,
func (library *libraryDecorator) install(ctx ModuleContext, file android.Path) {
if library.shared() {
- if library.hasStubsVariants() && !ctx.Host() && ctx.directlyInAnyApex() {
+ translatedArch := ctx.Target().NativeBridge == android.NativeBridgeEnabled
+ if library.hasStubsVariants() && !ctx.Host() && !ctx.isSdkVariant() &&
+ InstallToBootstrap(ctx.baseModuleName(), ctx.Config()) && !library.buildStubs() &&
+ !translatedArch && !ctx.inRamdisk() && !ctx.inVendorRamdisk() && !ctx.inRecovery() {
// Bionic libraries (e.g. libc.so) is installed to the bootstrap subdirectory.
// The original path becomes a symlink to the corresponding file in the
// runtime APEX.
- translatedArch := ctx.Target().NativeBridge == android.NativeBridgeEnabled
- if InstallToBootstrap(ctx.baseModuleName(), ctx.Config()) && !library.buildStubs() &&
- !translatedArch && !ctx.inRamdisk() && !ctx.inVendorRamdisk() && !ctx.inRecovery() {
- if ctx.Device() {
- library.installSymlinkToRuntimeApex(ctx, file)
- }
- library.baseInstaller.subDir = "bootstrap"
+ if ctx.Device() {
+ library.installSymlinkToRuntimeApex(ctx, file)
}
- } else if ctx.directlyInAnyApex() && ctx.IsLlndk() && !isBionic(ctx.baseModuleName()) {
- // Skip installing LLNDK (non-bionic) libraries moved to APEX.
- ctx.Module().HideFromMake()
+ library.baseInstaller.subDir = "bootstrap"
}
library.baseInstaller.install(ctx, file)
@@ -1848,6 +1855,11 @@ func (library *libraryDecorator) hasLLNDKHeaders() bool {
return Bool(library.Properties.Llndk.Llndk_headers)
}
+// isLLNDKMovedToApex returns true if this cc_library module sets the llndk.moved_to_apex property.
+func (library *libraryDecorator) isLLNDKMovedToApex() bool {
+ return Bool(library.Properties.Llndk.Moved_to_apex)
+}
+
// hasVendorPublicLibrary returns true if this cc_library module has a variant that will build
// vendor public library stubs.
func (library *libraryDecorator) hasVendorPublicLibrary() bool {
diff --git a/cc/linker.go b/cc/linker.go
index f9d58ea20..b96d13983 100644
--- a/cc/linker.go
+++ b/cc/linker.go
@@ -235,13 +235,16 @@ type BaseLinkerProperties struct {
// Generate compact dynamic relocation table, default true.
Pack_relocations *bool `android:"arch_variant"`
- // local file name to pass to the linker as --version-script
+ // local file name to pass to the linker as --version-script. Not supported on darwin, and will fail to build
+ // if provided to the darwin variant of a module.
Version_script *string `android:"path,arch_variant"`
- // local file name to pass to the linker as --dynamic-list
+ // local file name to pass to the linker as --dynamic-list. Not supported on darwin, and will fail to build
+ // if provided to the darwin variant of a module.
Dynamic_list *string `android:"path,arch_variant"`
- // local files to pass to the linker as --script
+ // local files to pass to the linker as --script. Not supported on darwin or windows, and will fail to build
+ // if provided to the darwin or windows variant of a module.
Linker_scripts []string `android:"path,arch_variant"`
// list of static libs that should not be used to build this module
@@ -560,7 +563,7 @@ func (linker *baseLinker) linkerFlags(ctx ModuleContext, flags Flags) Flags {
if versionScript.Valid() {
if ctx.Darwin() {
- ctx.PropertyErrorf("version_script", "Not supported on Darwin")
+ ctx.AddMissingDependencies([]string{"version_script_not_supported_on_darwin"})
} else {
flags.Local.LdFlags = append(flags.Local.LdFlags,
config.VersionScriptFlagPrefix+versionScript.String())
@@ -578,7 +581,7 @@ func (linker *baseLinker) linkerFlags(ctx ModuleContext, flags Flags) Flags {
dynamicList := android.OptionalPathForModuleSrc(ctx, linker.Properties.Dynamic_list)
if dynamicList.Valid() {
if ctx.Darwin() {
- ctx.PropertyErrorf("dynamic_list", "Not supported on Darwin")
+ ctx.AddMissingDependencies([]string{"dynamic_list_not_supported_on_darwin"})
} else {
flags.Local.LdFlags = append(flags.Local.LdFlags,
"-Wl,--dynamic-list,"+dynamicList.String())
@@ -587,13 +590,17 @@ func (linker *baseLinker) linkerFlags(ctx ModuleContext, flags Flags) Flags {
}
linkerScriptPaths := android.PathsForModuleSrc(ctx, linker.Properties.Linker_scripts)
- if len(linkerScriptPaths) > 0 && (ctx.Darwin() || ctx.Windows()) {
- ctx.PropertyErrorf("linker_scripts", "Only supported for ELF files")
- } else {
- for _, linkerScriptPath := range linkerScriptPaths {
- flags.Local.LdFlags = append(flags.Local.LdFlags,
- "-Wl,--script,"+linkerScriptPath.String())
- flags.LdFlagsDeps = append(flags.LdFlagsDeps, linkerScriptPath)
+ if len(linkerScriptPaths) > 0 {
+ if ctx.Darwin() {
+ ctx.AddMissingDependencies([]string{"linker_scripts_not_supported_on_darwin"})
+ } else if ctx.Windows() {
+ ctx.PropertyErrorf("linker_scripts", "Only supported for ELF files")
+ } else {
+ for _, linkerScriptPath := range linkerScriptPaths {
+ flags.Local.LdFlags = append(flags.Local.LdFlags,
+ "-Wl,--script,"+linkerScriptPath.String())
+ flags.LdFlagsDeps = append(flags.LdFlagsDeps, linkerScriptPath)
+ }
}
}
}
diff --git a/cc/llndk_library.go b/cc/llndk_library.go
index c7950f9ff..162dd5429 100644
--- a/cc/llndk_library.go
+++ b/cc/llndk_library.go
@@ -57,17 +57,18 @@ type llndkLibraryProperties struct {
// if true, make this module available to provide headers to other modules that set
// llndk.symbol_file.
Llndk_headers *bool
+
+ // moved_to_apex marks this module has having been distributed through an apex module.
+ Moved_to_apex *bool
}
func makeLlndkVars(ctx android.MakeVarsContext) {
- // Make uses LLNDK_MOVED_TO_APEX_LIBRARIES to avoid installing libraries on /system if
- // they been moved to an apex.
+ // Make uses LLNDK_MOVED_TO_APEX_LIBRARIES to generate the linker config.
movedToApexLlndkLibraries := make(map[string]bool)
ctx.VisitAllModules(func(module android.Module) {
if library := moduleLibraryInterface(module); library != nil && library.hasLLNDKStubs() {
- // Skip bionic libs, they are handled in different manner
- name := library.implementationModuleName(module.(*Module).BaseModuleName())
- if module.(android.ApexModule).DirectlyInAnyApex() && !isBionic(name) {
+ if library.isLLNDKMovedToApex() {
+ name := library.implementationModuleName(module.(*Module).BaseModuleName())
movedToApexLlndkLibraries[name] = true
}
}
diff --git a/cc/ndkstubgen/test_ndkstubgen.py b/cc/ndkstubgen/test_ndkstubgen.py
index 22f31d9f1..6c24b4f19 100755
--- a/cc/ndkstubgen/test_ndkstubgen.py
+++ b/cc/ndkstubgen/test_ndkstubgen.py
@@ -473,16 +473,17 @@ class IntegrationTest(unittest.TestCase):
VERSION_35 { # introduced=35
global:
wiggle;
- waggle;
- waggle; # llndk=202404
- bubble; # llndk=202404
- duddle;
- duddle; # llndk=202504
+ waggle; # llndk
} VERSION_34;
+ VERSION_36 { # introduced=36
+ global:
+ abc;
+ xyz; # llndk
+ } VERSION_35;
"""))
f = copy(self.filter)
f.llndk = True
- f.api = 202404
+ f.api = 35
parser = symbolfile.SymbolFileParser(input_file, {}, f)
versions = parser.parse()
@@ -497,8 +498,8 @@ class IntegrationTest(unittest.TestCase):
expected_src = textwrap.dedent("""\
void foo() {}
void bar() {}
+ void wiggle() {}
void waggle() {}
- void bubble() {}
""")
self.assertEqual(expected_src, src_file.getvalue())
@@ -510,8 +511,8 @@ class IntegrationTest(unittest.TestCase):
};
VERSION_35 {
global:
+ wiggle;
waggle;
- bubble;
} VERSION_34;
""")
self.assertEqual(expected_version, version_file.getvalue())
@@ -521,15 +522,15 @@ class IntegrationTest(unittest.TestCase):
LIBANDROID {
global:
foo; # introduced=34
- bar; # introduced=35
- bar; # llndk=202404
- baz; # introduced=35
+ bar; # introduced=35 llndk
+ baz; # introduced=V
+ qux; # introduced=36
};
"""))
f = copy(self.filter)
f.llndk = True
- f.api = 202404
- parser = symbolfile.SymbolFileParser(input_file, {}, f)
+ f.api = 35
+ parser = symbolfile.SymbolFileParser(input_file, {'V': 35}, f)
versions = parser.parse()
src_file = io.StringIO()
@@ -543,6 +544,7 @@ class IntegrationTest(unittest.TestCase):
expected_src = textwrap.dedent("""\
void foo() {}
void bar() {}
+ void baz() {}
""")
self.assertEqual(expected_src, src_file.getvalue())
@@ -551,6 +553,7 @@ class IntegrationTest(unittest.TestCase):
global:
foo;
bar;
+ baz;
};
""")
self.assertEqual(expected_version, version_file.getvalue())
diff --git a/cc/sanitize.go b/cc/sanitize.go
index f0d734376..d8d8c7aef 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -1504,9 +1504,6 @@ func sanitizerRuntimeMutator(mctx android.BottomUpMutatorContext) {
if Bool(sanProps.Memtag_globals) {
sanitizers = append(sanitizers, "memtag-globals")
- // TODO(mitchp): For now, enable memtag-heap with memtag-globals because the linker
- // isn't new enough (https://reviews.llvm.org/differential/changeset/?ref=4243566).
- sanitizers = append(sanitizers, "memtag-heap")
}
if Bool(sanProps.Fuzzer) {
diff --git a/cc/symbolfile/__init__.py b/cc/symbolfile/__init__.py
index 4553616ac..f2bd18690 100644
--- a/cc/symbolfile/__init__.py
+++ b/cc/symbolfile/__init__.py
@@ -103,24 +103,13 @@ class Tags:
@property
def has_llndk_tags(self) -> bool:
"""Returns True if any LL-NDK tags are set."""
- for tag in self.tags:
- if tag == 'llndk' or tag.startswith('llndk='):
- return True
- return False
+ return 'llndk' in self.tags
@property
def has_platform_only_tags(self) -> bool:
"""Returns True if any platform-only tags are set."""
return 'platform-only' in self.tags
- def copy_introduced_from(self, tags: Tags) -> None:
- """Copies introduced= or introduced-*= tags."""
- for tag in tags:
- if tag.startswith('introduced=') or tag.startswith('introduced-'):
- name, _ = split_tag(tag)
- if not any(self_tag.startswith(name + '=') for self_tag in self.tags):
- self.tags += (tag,)
-
@dataclass
class Symbol:
@@ -158,8 +147,6 @@ def is_api_level_tag(tag: Tag) -> bool:
"""Returns true if this tag has an API level that may need decoding."""
if tag.startswith('llndk-deprecated='):
return True
- if tag.startswith('llndk='):
- return True
if tag.startswith('introduced='):
return True
if tag.startswith('introduced-'):
@@ -245,21 +232,19 @@ class Filter:
self.systemapi = systemapi
self.ndk = ndk
+ def _symbol_in_arch_api(self, tags: Tags) -> bool:
+ if not symbol_in_arch(tags, self.arch):
+ return True
+ if not symbol_in_api(tags, self.arch, self.api):
+ return True
+ return False
+
def _should_omit_tags(self, tags: Tags) -> bool:
"""Returns True if the tagged object should be omitted.
This defines the rules shared between version tagging and symbol tagging.
"""
- # LLNDK mode/tags follow the similar filtering except that API level checking
- # is based llndk= instead of introduced=.
- if self.llndk:
- if tags.has_mode_tags and not tags.has_llndk_tags:
- return True
- if not symbol_in_arch(tags, self.arch):
- return True
- if not symbol_in_llndk_api(tags, self.arch, self.api):
- return True
- return False
+ # The apex and llndk tags will only exclude APIs from other modes. If in
# APEX or LLNDK mode and neither tag is provided, we fall back to the
# default behavior because all NDK symbols are implicitly available to
# APEX and LLNDK.
@@ -268,12 +253,10 @@ class Filter:
return False
if self.systemapi and tags.has_systemapi_tags:
return False
+ if self.llndk and tags.has_llndk_tags:
+ return self._symbol_in_arch_api(tags)
return True
- if not symbol_in_arch(tags, self.arch):
- return True
- if not symbol_in_api(tags, self.arch, self.api):
- return True
- return False
+ return self._symbol_in_arch_api(tags)
def should_omit_version(self, version: Version) -> bool:
"""Returns True if the version section should be omitted.
@@ -286,10 +269,6 @@ class Filter:
return True
if version.tags.has_platform_only_tags:
return True
- # Include all versions when targeting LLNDK because LLNDK symbols are self-versioned.
- # Empty version block will be handled separately.
- if self.llndk:
- return False
return self._should_omit_tags(version.tags)
def should_omit_symbol(self, symbol: Symbol) -> bool:
@@ -302,6 +281,7 @@ class Filter:
return self._should_omit_tags(symbol.tags)
+
def symbol_in_arch(tags: Tags, arch: Arch) -> bool:
"""Returns true if the symbol is present for the given architecture."""
has_arch_tags = False
@@ -316,14 +296,6 @@ def symbol_in_arch(tags: Tags, arch: Arch) -> bool:
# for the tagged architectures.
return not has_arch_tags
-def symbol_in_llndk_api(tags: Iterable[Tag], arch: Arch, api: int) -> bool:
- """Returns true if the symbol is present for the given LLNDK API level."""
- # Check llndk= first.
- for tag in tags:
- if tag.startswith('llndk='):
- return api >= int(get_tag_value(tag))
- # If not, we keep old behavior: NDK symbols in <= 34 are LLNDK symbols.
- return symbol_in_api(tags, arch, 34)
def symbol_in_api(tags: Iterable[Tag], arch: Arch, api: int) -> bool:
"""Returns true if the symbol is present for the given API level."""
@@ -400,7 +372,6 @@ class SymbolFileParser:
f'Unexpected contents at top level: {self.current_line}')
self.check_no_duplicate_symbols(versions)
- self.check_llndk_introduced(versions)
return versions
def check_no_duplicate_symbols(self, versions: Iterable[Version]) -> None:
@@ -429,31 +400,6 @@ class SymbolFileParser:
raise MultiplyDefinedSymbolError(
sorted(list(multiply_defined_symbols)))
- def check_llndk_introduced(self, versions: Iterable[Version]) -> None:
- """Raises errors when llndk= is missing for new llndk symbols."""
- if not self.filter.llndk:
- return
-
- def assert_llndk_with_version(tags: Tags, name: str) -> None:
- has_llndk_introduced = False
- for tag in tags:
- if tag.startswith('llndk='):
- has_llndk_introduced = True
- break
- if not has_llndk_introduced:
- raise ParseError(f'{name}: missing version. `llndk=yyyymm`')
-
- arch = self.filter.arch
- for version in versions:
- # llndk symbols >= introduced=35 should be tagged
- # explicitly with llndk=yyyymm.
- for symbol in version.symbols:
- if not symbol.tags.has_llndk_tags:
- continue
- if symbol_in_api(symbol.tags, arch, 34):
- continue
- assert_llndk_with_version(symbol.tags, symbol.name)
-
def parse_version(self) -> Version:
"""Parses a single version section and returns a Version object."""
assert self.current_line is not None
@@ -487,9 +433,7 @@ class SymbolFileParser:
else:
raise ParseError('Unknown visiblity label: ' + visibility)
elif global_scope and not cpp_symbols:
- symbol = self.parse_symbol()
- symbol.tags.copy_introduced_from(tags)
- symbols.append(symbol)
+ symbols.append(self.parse_symbol())
else:
# We're in a hidden scope or in 'extern "C++"' block. Ignore
# everything.
diff --git a/cc/symbolfile/test_symbolfile.py b/cc/symbolfile/test_symbolfile.py
index 8b412b98a..14bb737ee 100644
--- a/cc/symbolfile/test_symbolfile.py
+++ b/cc/symbolfile/test_symbolfile.py
@@ -344,45 +344,6 @@ class OmitSymbolTest(unittest.TestCase):
self.assertInclude(f_llndk, s_none)
self.assertInclude(f_llndk, s_llndk)
- def test_omit_llndk_versioned(self) -> None:
- f_ndk = self.filter
- f_ndk.api = 35
-
- f_llndk = copy(f_ndk)
- f_llndk.llndk = True
- f_llndk.api = 202404
-
- s = Symbol('foo', Tags())
- s_llndk = Symbol('foo', Tags.from_strs(['llndk']))
- s_llndk_202404 = Symbol('foo', Tags.from_strs(['llndk=202404']))
- s_34 = Symbol('foo', Tags.from_strs(['introduced=34']))
- s_34_llndk = Symbol('foo', Tags.from_strs(['introduced=34', 'llndk']))
- s_35 = Symbol('foo', Tags.from_strs(['introduced=35']))
- s_35_llndk_202404 = Symbol('foo', Tags.from_strs(['introduced=35', 'llndk=202404']))
- s_35_llndk_202504 = Symbol('foo', Tags.from_strs(['introduced=35', 'llndk=202504']))
-
- # When targeting NDK, omit LLNDK tags
- self.assertInclude(f_ndk, s)
- self.assertOmit(f_ndk, s_llndk)
- self.assertOmit(f_ndk, s_llndk_202404)
- self.assertInclude(f_ndk, s_34)
- self.assertOmit(f_ndk, s_34_llndk)
- self.assertInclude(f_ndk, s_35)
- self.assertOmit(f_ndk, s_35_llndk_202404)
- self.assertOmit(f_ndk, s_35_llndk_202504)
-
- # When targeting LLNDK, old symbols without any mode tags are included as LLNDK
- self.assertInclude(f_llndk, s)
- # When targeting LLNDK, old symbols with #llndk are included as LLNDK
- self.assertInclude(f_llndk, s_llndk)
- self.assertInclude(f_llndk, s_llndk_202404)
- self.assertInclude(f_llndk, s_34)
- self.assertInclude(f_llndk, s_34_llndk)
- # When targeting LLNDK, new symbols(>=35) should be tagged with llndk-introduced=.
- self.assertOmit(f_llndk, s_35)
- self.assertInclude(f_llndk, s_35_llndk_202404)
- self.assertOmit(f_llndk, s_35_llndk_202504)
-
def test_omit_apex(self) -> None:
f_none = self.filter
f_apex = copy(f_none)
@@ -494,8 +455,8 @@ class SymbolFileParseTest(unittest.TestCase):
# should_omit_tags() can differently based on introduced API level when treating
# LLNDK-available symbols.
expected_symbols = [
- Symbol('baz', Tags.from_strs(['introduced=35'])),
- Symbol('qux', Tags.from_strs(['apex', 'llndk', 'introduced=35'])),
+ Symbol('baz', Tags()),
+ Symbol('qux', Tags.from_strs(['apex', 'llndk'])),
]
self.assertEqual(expected_symbols, version.symbols)
@@ -643,19 +604,6 @@ class SymbolFileParseTest(unittest.TestCase):
]
self.assertEqual(expected_symbols, version.symbols)
- def test_parse_llndk_version_is_missing(self) -> None:
- input_file = io.StringIO(textwrap.dedent("""\
- VERSION_1 { # introduced=35
- foo;
- bar; # llndk
- };
- """))
- f = copy(self.filter)
- f.llndk = True
- parser = symbolfile.SymbolFileParser(input_file, {}, f)
- with self.assertRaises(symbolfile.ParseError):
- parser.parse()
-
def main() -> None:
suite = unittest.TestLoader().loadTestsFromName(__name__)