Refactor cc/rust to prep for Rust stubs
This CL largely handles this refactoring in preparation for Rust stubs
support.
Rust modules need to be able to communicate stubs information to cc, and
certain bits of cc needs to be exported so rust can reuse them.
A new VersionedLinkableInterface is added to capture most of the
stubs-related interface definitions.
Bug: 203478530
Test: m blueprint_tests
Change-Id: I380225402fa85a3c39e7b18deb657054b3a52fbe
diff --git a/rust/sanitize.go b/rust/sanitize.go
index b8f922f..50f55ce 100644
--- a/rust/sanitize.go
+++ b/rust/sanitize.go
@@ -53,6 +53,9 @@
// Used when we need to place libraries in their own directory, such as ASAN.
InSanitizerDir bool `blueprint:"mutated"`
+
+ // ForceDisable is set by the version mutator to disable sanitization of stubs variants
+ ForceDisable bool `blueprint:"mutated"`
}
var fuzzerFlags = []string{
@@ -103,6 +106,10 @@
func (sanitize *sanitize) begin(ctx BaseModuleContext) {
s := &sanitize.Properties.Sanitize
+ if sanitize.Properties.ForceDisable {
+ return
+ }
+
// Disable sanitizers for musl x86 modules, rustc does not support any sanitizers.
if ctx.Os() == android.LinuxMusl && ctx.Arch().ArchType == android.X86 {
s.Never = proptools.BoolPtr(true)
@@ -221,6 +228,10 @@
}
func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags, deps PathDeps) (Flags, PathDeps) {
+ if sanitize.Properties.ForceDisable {
+ return flags, deps
+ }
+
if !sanitize.Properties.SanitizerEnabled {
return flags, deps
}
@@ -253,6 +264,9 @@
if !mod.Enabled(mctx) {
return
}
+ if mod.sanitize.Properties.ForceDisable {
+ return
+ }
if Bool(mod.sanitize.Properties.Sanitize.Memtag_heap) && mod.Binary() {
noteDep := "note_memtag_heap_async"
@@ -364,7 +378,7 @@
// distinguish between the cases. It isn't needed though - both cases can be
// treated identically.
func (sanitize *sanitize) isSanitizerEnabled(t cc.SanitizerType) bool {
- if sanitize == nil || !sanitize.Properties.SanitizerEnabled {
+ if sanitize == nil || !sanitize.Properties.SanitizerEnabled || sanitize.Properties.ForceDisable {
return false
}
@@ -453,7 +467,7 @@
}
func (mod *Module) SanitizeNever() bool {
- return Bool(mod.sanitize.Properties.Sanitize.Never)
+ return Bool(mod.sanitize.Properties.Sanitize.Never) || mod.sanitize.Properties.ForceDisable
}
var _ cc.PlatformSanitizeable = (*Module)(nil)