Loading cc/androidmk.go +2 −2 Original line number Diff line number Diff line Loading @@ -530,9 +530,9 @@ func (c *snapshotLibraryDecorator) AndroidMkEntries(ctx AndroidMkContext, entrie entries.SubName = "" if c.isSanitizerEnabled(cfi) { if c.IsSanitizerEnabled(cfi) { entries.SubName += ".cfi" } else if c.isSanitizerEnabled(Hwasan) { } else if c.IsSanitizerEnabled(Hwasan) { entries.SubName += ".hwasan" } Loading cc/linkable.go +12 −0 Original line number Diff line number Diff line Loading @@ -95,6 +95,18 @@ type Snapshottable interface { // IsSnapshotPrebuilt returns true if this module is a snapshot prebuilt. IsSnapshotPrebuilt() bool // IsSnapshotSanitizer returns true if this snapshot module implements SnapshotSanitizer. IsSnapshotSanitizer() bool // IsSnapshotSanitizerAvailable returns true if this snapshot module has a sanitizer source available (cfi, hwasan). IsSnapshotSanitizerAvailable(t SanitizerType) bool // SetSnapshotSanitizerVariation sets the sanitizer variation type for this snapshot module. SetSnapshotSanitizerVariation(t SanitizerType, enabled bool) // IsSnapshotUnsanitizedVariant returns true if this is the unsanitized snapshot module variant. IsSnapshotUnsanitizedVariant() bool } // LinkableInterface is an interface for a type of module that is linkable in a C++ library. Loading cc/sanitize.go +40 −13 Original line number Diff line number Diff line Loading @@ -1189,7 +1189,7 @@ func (s *sanitizerSplitMutator) markSanitizableApexesMutator(ctx android.TopDown if sanitizeable, ok := ctx.Module().(Sanitizeable); ok { enabled := sanitizeable.IsSanitizerEnabled(ctx.Config(), s.sanitizer.name()) ctx.VisitDirectDeps(func(dep android.Module) { if c, ok := dep.(*Module); ok && c.sanitize.isSanitizerEnabled(s.sanitizer) { if c, ok := dep.(PlatformSanitizeable); ok && c.IsSanitizerEnabled(s.sanitizer) { enabled = true } }) Loading Loading @@ -1243,12 +1243,10 @@ func (s *sanitizerSplitMutator) Split(ctx android.BaseModuleContext) []string { } } if c, ok := ctx.Module().(*Module); ok { //TODO: When Rust modules have vendor support, enable this path for PlatformSanitizeable if c, ok := ctx.Module().(LinkableInterface); ok { // Check if it's a snapshot module supporting sanitizer if ss, ok := c.linker.(snapshotSanitizer); ok { if ss.isSanitizerAvailable(s.sanitizer) { if c.IsSnapshotSanitizer() { if c.IsSnapshotSanitizerAvailable(s.sanitizer) { return []string{"", s.sanitizer.variationName()} } else { return []string{""} Loading Loading @@ -1280,8 +1278,8 @@ func (s *sanitizerSplitMutator) OutgoingTransition(ctx android.OutgoingTransitio func (s *sanitizerSplitMutator) IncomingTransition(ctx android.IncomingTransitionContext, incomingVariation string) string { if d, ok := ctx.Module().(PlatformSanitizeable); ok { if dm, ok := ctx.Module().(*Module); ok { if ss, ok := dm.linker.(snapshotSanitizer); ok && ss.isSanitizerAvailable(s.sanitizer) { if dm, ok := ctx.Module().(LinkableInterface); ok { if dm.IsSnapshotSanitizerAvailable(s.sanitizer) { return incomingVariation } } Loading Loading @@ -1396,19 +1394,19 @@ func (s *sanitizerSplitMutator) Mutate(mctx android.BottomUpMutatorContext, vari if sanitizerVariation { sanitizeable.AddSanitizerDependencies(mctx, s.sanitizer.name()) } } else if c, ok := mctx.Module().(*Module); ok { if ss, ok := c.linker.(snapshotSanitizer); ok && ss.isSanitizerAvailable(s.sanitizer) { if !ss.isUnsanitizedVariant() { } else if c, ok := mctx.Module().(LinkableInterface); ok { if c.IsSnapshotSanitizerAvailable(s.sanitizer) { if !c.IsSnapshotUnsanitizedVariant() { // Snapshot sanitizer may have only one variantion. // Skip exporting the module if it already has a sanitizer variation. c.SetPreventInstall() c.SetHideFromMake() return } c.linker.(snapshotSanitizer).setSanitizerVariation(s.sanitizer, sanitizerVariation) c.SetSnapshotSanitizerVariation(s.sanitizer, sanitizerVariation) // Export the static lib name to make if c.static() && c.ExportedToMake() { if c.Static() && c.ExportedToMake() { // use BaseModuleName which is the name for Make. if s.sanitizer == cfi { cfiStaticLibs(mctx.Config()).add(c, c.BaseModuleName()) Loading @@ -1420,6 +1418,35 @@ func (s *sanitizerSplitMutator) Mutate(mctx android.BottomUpMutatorContext, vari } } func (c *Module) IsSnapshotSanitizer() bool { if _, ok := c.linker.(SnapshotSanitizer); ok { return true } return false } func (c *Module) IsSnapshotSanitizerAvailable(t SanitizerType) bool { if ss, ok := c.linker.(SnapshotSanitizer); ok { return ss.IsSanitizerAvailable(t) } return false } func (c *Module) SetSnapshotSanitizerVariation(t SanitizerType, enabled bool) { if ss, ok := c.linker.(SnapshotSanitizer); ok { ss.SetSanitizerVariation(t, enabled) } else { panic(fmt.Errorf("Calling SetSnapshotSanitizerVariation on a non-snapshotLibraryDecorator: %s", c.Name())) } } func (c *Module) IsSnapshotUnsanitizedVariant() bool { if ss, ok := c.linker.(SnapshotSanitizer); ok { return ss.IsUnsanitizedVariant() } return false } func (c *Module) SanitizeNever() bool { return Bool(c.sanitize.Properties.SanitizeMutated.Never) } Loading cc/snapshot_prebuilt.go +16 −16 Original line number Diff line number Diff line Loading @@ -403,11 +403,11 @@ type SnapshotLibraryProperties struct { Sanitize_minimal_dep *bool `android:"arch_variant"` } type snapshotSanitizer interface { isSanitizerAvailable(t SanitizerType) bool setSanitizerVariation(t SanitizerType, enabled bool) isSanitizerEnabled(t SanitizerType) bool isUnsanitizedVariant() bool type SnapshotSanitizer interface { IsSanitizerAvailable(t SanitizerType) bool SetSanitizerVariation(t SanitizerType, enabled bool) IsSanitizerEnabled(t SanitizerType) bool IsUnsanitizedVariant() bool } type snapshotLibraryDecorator struct { Loading Loading @@ -460,9 +460,9 @@ func (p *snapshotLibraryDecorator) link(ctx ModuleContext, flags Flags, deps Pat return p.libraryDecorator.link(ctx, flags, deps, objs) } if p.isSanitizerEnabled(cfi) { if p.IsSanitizerEnabled(cfi) { p.properties = p.sanitizerProperties.Cfi } else if p.isSanitizerEnabled(Hwasan) { } else if p.IsSanitizerEnabled(Hwasan) { p.properties = p.sanitizerProperties.Hwasan } Loading Loading @@ -526,9 +526,9 @@ func (p *snapshotLibraryDecorator) nativeCoverage() bool { return false } var _ snapshotSanitizer = (*snapshotLibraryDecorator)(nil) var _ SnapshotSanitizer = (*snapshotLibraryDecorator)(nil) func (p *snapshotLibraryDecorator) isSanitizerAvailable(t SanitizerType) bool { func (p *snapshotLibraryDecorator) IsSanitizerAvailable(t SanitizerType) bool { switch t { case cfi: return p.sanitizerProperties.Cfi.Src != nil Loading @@ -539,23 +539,23 @@ func (p *snapshotLibraryDecorator) isSanitizerAvailable(t SanitizerType) bool { } } func (p *snapshotLibraryDecorator) setSanitizerVariation(t SanitizerType, enabled bool) { if !enabled || p.isSanitizerEnabled(t) { func (p *snapshotLibraryDecorator) SetSanitizerVariation(t SanitizerType, enabled bool) { if !enabled || p.IsSanitizerEnabled(t) { return } if !p.isUnsanitizedVariant() { if !p.IsUnsanitizedVariant() { panic(fmt.Errorf("snapshot Sanitizer must be one of Cfi or Hwasan but not both")) } p.sanitizerProperties.SanitizerVariation = t } func (p *snapshotLibraryDecorator) isSanitizerEnabled(t SanitizerType) bool { func (p *snapshotLibraryDecorator) IsSanitizerEnabled(t SanitizerType) bool { return p.sanitizerProperties.SanitizerVariation == t } func (p *snapshotLibraryDecorator) isUnsanitizedVariant() bool { return !p.isSanitizerEnabled(Asan) && !p.isSanitizerEnabled(Hwasan) func (p *snapshotLibraryDecorator) IsUnsanitizedVariant() bool { return !p.IsSanitizerEnabled(Asan) && !p.IsSanitizerEnabled(Hwasan) } func snapshotLibraryFactory(image SnapshotImage, moduleSuffix string) (*Module, *snapshotLibraryDecorator) { Loading rust/config/global.go +1 −1 Original line number Diff line number Diff line Loading @@ -54,11 +54,11 @@ var ( "-C symbol-mangling-version=v0", "--color always", "-Zdylib-lto", "-Z link-native-libraries=no", } deviceGlobalRustFlags = []string{ "-C panic=abort", "-Z link-native-libraries=no", // Generate additional debug info for AutoFDO "-Z debug-info-for-profiling", } Loading Loading
cc/androidmk.go +2 −2 Original line number Diff line number Diff line Loading @@ -530,9 +530,9 @@ func (c *snapshotLibraryDecorator) AndroidMkEntries(ctx AndroidMkContext, entrie entries.SubName = "" if c.isSanitizerEnabled(cfi) { if c.IsSanitizerEnabled(cfi) { entries.SubName += ".cfi" } else if c.isSanitizerEnabled(Hwasan) { } else if c.IsSanitizerEnabled(Hwasan) { entries.SubName += ".hwasan" } Loading
cc/linkable.go +12 −0 Original line number Diff line number Diff line Loading @@ -95,6 +95,18 @@ type Snapshottable interface { // IsSnapshotPrebuilt returns true if this module is a snapshot prebuilt. IsSnapshotPrebuilt() bool // IsSnapshotSanitizer returns true if this snapshot module implements SnapshotSanitizer. IsSnapshotSanitizer() bool // IsSnapshotSanitizerAvailable returns true if this snapshot module has a sanitizer source available (cfi, hwasan). IsSnapshotSanitizerAvailable(t SanitizerType) bool // SetSnapshotSanitizerVariation sets the sanitizer variation type for this snapshot module. SetSnapshotSanitizerVariation(t SanitizerType, enabled bool) // IsSnapshotUnsanitizedVariant returns true if this is the unsanitized snapshot module variant. IsSnapshotUnsanitizedVariant() bool } // LinkableInterface is an interface for a type of module that is linkable in a C++ library. Loading
cc/sanitize.go +40 −13 Original line number Diff line number Diff line Loading @@ -1189,7 +1189,7 @@ func (s *sanitizerSplitMutator) markSanitizableApexesMutator(ctx android.TopDown if sanitizeable, ok := ctx.Module().(Sanitizeable); ok { enabled := sanitizeable.IsSanitizerEnabled(ctx.Config(), s.sanitizer.name()) ctx.VisitDirectDeps(func(dep android.Module) { if c, ok := dep.(*Module); ok && c.sanitize.isSanitizerEnabled(s.sanitizer) { if c, ok := dep.(PlatformSanitizeable); ok && c.IsSanitizerEnabled(s.sanitizer) { enabled = true } }) Loading Loading @@ -1243,12 +1243,10 @@ func (s *sanitizerSplitMutator) Split(ctx android.BaseModuleContext) []string { } } if c, ok := ctx.Module().(*Module); ok { //TODO: When Rust modules have vendor support, enable this path for PlatformSanitizeable if c, ok := ctx.Module().(LinkableInterface); ok { // Check if it's a snapshot module supporting sanitizer if ss, ok := c.linker.(snapshotSanitizer); ok { if ss.isSanitizerAvailable(s.sanitizer) { if c.IsSnapshotSanitizer() { if c.IsSnapshotSanitizerAvailable(s.sanitizer) { return []string{"", s.sanitizer.variationName()} } else { return []string{""} Loading Loading @@ -1280,8 +1278,8 @@ func (s *sanitizerSplitMutator) OutgoingTransition(ctx android.OutgoingTransitio func (s *sanitizerSplitMutator) IncomingTransition(ctx android.IncomingTransitionContext, incomingVariation string) string { if d, ok := ctx.Module().(PlatformSanitizeable); ok { if dm, ok := ctx.Module().(*Module); ok { if ss, ok := dm.linker.(snapshotSanitizer); ok && ss.isSanitizerAvailable(s.sanitizer) { if dm, ok := ctx.Module().(LinkableInterface); ok { if dm.IsSnapshotSanitizerAvailable(s.sanitizer) { return incomingVariation } } Loading Loading @@ -1396,19 +1394,19 @@ func (s *sanitizerSplitMutator) Mutate(mctx android.BottomUpMutatorContext, vari if sanitizerVariation { sanitizeable.AddSanitizerDependencies(mctx, s.sanitizer.name()) } } else if c, ok := mctx.Module().(*Module); ok { if ss, ok := c.linker.(snapshotSanitizer); ok && ss.isSanitizerAvailable(s.sanitizer) { if !ss.isUnsanitizedVariant() { } else if c, ok := mctx.Module().(LinkableInterface); ok { if c.IsSnapshotSanitizerAvailable(s.sanitizer) { if !c.IsSnapshotUnsanitizedVariant() { // Snapshot sanitizer may have only one variantion. // Skip exporting the module if it already has a sanitizer variation. c.SetPreventInstall() c.SetHideFromMake() return } c.linker.(snapshotSanitizer).setSanitizerVariation(s.sanitizer, sanitizerVariation) c.SetSnapshotSanitizerVariation(s.sanitizer, sanitizerVariation) // Export the static lib name to make if c.static() && c.ExportedToMake() { if c.Static() && c.ExportedToMake() { // use BaseModuleName which is the name for Make. if s.sanitizer == cfi { cfiStaticLibs(mctx.Config()).add(c, c.BaseModuleName()) Loading @@ -1420,6 +1418,35 @@ func (s *sanitizerSplitMutator) Mutate(mctx android.BottomUpMutatorContext, vari } } func (c *Module) IsSnapshotSanitizer() bool { if _, ok := c.linker.(SnapshotSanitizer); ok { return true } return false } func (c *Module) IsSnapshotSanitizerAvailable(t SanitizerType) bool { if ss, ok := c.linker.(SnapshotSanitizer); ok { return ss.IsSanitizerAvailable(t) } return false } func (c *Module) SetSnapshotSanitizerVariation(t SanitizerType, enabled bool) { if ss, ok := c.linker.(SnapshotSanitizer); ok { ss.SetSanitizerVariation(t, enabled) } else { panic(fmt.Errorf("Calling SetSnapshotSanitizerVariation on a non-snapshotLibraryDecorator: %s", c.Name())) } } func (c *Module) IsSnapshotUnsanitizedVariant() bool { if ss, ok := c.linker.(SnapshotSanitizer); ok { return ss.IsUnsanitizedVariant() } return false } func (c *Module) SanitizeNever() bool { return Bool(c.sanitize.Properties.SanitizeMutated.Never) } Loading
cc/snapshot_prebuilt.go +16 −16 Original line number Diff line number Diff line Loading @@ -403,11 +403,11 @@ type SnapshotLibraryProperties struct { Sanitize_minimal_dep *bool `android:"arch_variant"` } type snapshotSanitizer interface { isSanitizerAvailable(t SanitizerType) bool setSanitizerVariation(t SanitizerType, enabled bool) isSanitizerEnabled(t SanitizerType) bool isUnsanitizedVariant() bool type SnapshotSanitizer interface { IsSanitizerAvailable(t SanitizerType) bool SetSanitizerVariation(t SanitizerType, enabled bool) IsSanitizerEnabled(t SanitizerType) bool IsUnsanitizedVariant() bool } type snapshotLibraryDecorator struct { Loading Loading @@ -460,9 +460,9 @@ func (p *snapshotLibraryDecorator) link(ctx ModuleContext, flags Flags, deps Pat return p.libraryDecorator.link(ctx, flags, deps, objs) } if p.isSanitizerEnabled(cfi) { if p.IsSanitizerEnabled(cfi) { p.properties = p.sanitizerProperties.Cfi } else if p.isSanitizerEnabled(Hwasan) { } else if p.IsSanitizerEnabled(Hwasan) { p.properties = p.sanitizerProperties.Hwasan } Loading Loading @@ -526,9 +526,9 @@ func (p *snapshotLibraryDecorator) nativeCoverage() bool { return false } var _ snapshotSanitizer = (*snapshotLibraryDecorator)(nil) var _ SnapshotSanitizer = (*snapshotLibraryDecorator)(nil) func (p *snapshotLibraryDecorator) isSanitizerAvailable(t SanitizerType) bool { func (p *snapshotLibraryDecorator) IsSanitizerAvailable(t SanitizerType) bool { switch t { case cfi: return p.sanitizerProperties.Cfi.Src != nil Loading @@ -539,23 +539,23 @@ func (p *snapshotLibraryDecorator) isSanitizerAvailable(t SanitizerType) bool { } } func (p *snapshotLibraryDecorator) setSanitizerVariation(t SanitizerType, enabled bool) { if !enabled || p.isSanitizerEnabled(t) { func (p *snapshotLibraryDecorator) SetSanitizerVariation(t SanitizerType, enabled bool) { if !enabled || p.IsSanitizerEnabled(t) { return } if !p.isUnsanitizedVariant() { if !p.IsUnsanitizedVariant() { panic(fmt.Errorf("snapshot Sanitizer must be one of Cfi or Hwasan but not both")) } p.sanitizerProperties.SanitizerVariation = t } func (p *snapshotLibraryDecorator) isSanitizerEnabled(t SanitizerType) bool { func (p *snapshotLibraryDecorator) IsSanitizerEnabled(t SanitizerType) bool { return p.sanitizerProperties.SanitizerVariation == t } func (p *snapshotLibraryDecorator) isUnsanitizedVariant() bool { return !p.isSanitizerEnabled(Asan) && !p.isSanitizerEnabled(Hwasan) func (p *snapshotLibraryDecorator) IsUnsanitizedVariant() bool { return !p.IsSanitizerEnabled(Asan) && !p.IsSanitizerEnabled(Hwasan) } func snapshotLibraryFactory(image SnapshotImage, moduleSuffix string) (*Module, *snapshotLibraryDecorator) { Loading
rust/config/global.go +1 −1 Original line number Diff line number Diff line Loading @@ -54,11 +54,11 @@ var ( "-C symbol-mangling-version=v0", "--color always", "-Zdylib-lto", "-Z link-native-libraries=no", } deviceGlobalRustFlags = []string{ "-C panic=abort", "-Z link-native-libraries=no", // Generate additional debug info for AutoFDO "-Z debug-info-for-profiling", } Loading