rust: Rust sanitized snapshots variations
This adds support for correctly handling Rust sanitized snapshots,
ensuring they only have one variation.
The presence of multiple variations were causing build failures
when a rust_fuzz module for host was defined and a snapshot
build was requested.
This also sets -Z link-native-libraries=no on host modules
(in addition to device modules) to avoid emitting extra linkage
flags due to link attributes.
Bug: 282897366
Test: SOONG_SDK_SNAPSHOT_USE_SRCJAR=true m
Change-Id: Idf980c29145f11c530ad635a4eb5b01a1730ac24
diff --git a/cc/snapshot_prebuilt.go b/cc/snapshot_prebuilt.go
index bb13310..e29c446 100644
--- a/cc/snapshot_prebuilt.go
+++ b/cc/snapshot_prebuilt.go
@@ -403,11 +403,11 @@
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 {
@@ -460,9 +460,9 @@
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
}
@@ -526,9 +526,9 @@
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
@@ -539,23 +539,23 @@
}
}
-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) {