Merge "Add back the llvm-ar P flag"
diff --git a/rust/rust.go b/rust/rust.go
index 5a2514e..62ccfc7 100644
--- a/rust/rust.go
+++ b/rust/rust.go
@@ -173,6 +173,24 @@
 
 	android.InitDefaultableModule(mod)
 
+	// Explicitly disable unsupported targets.
+	android.AddLoadHook(mod, func(ctx android.LoadHookContext) {
+		disableTargets := struct {
+			Target struct {
+				Darwin struct {
+					Enabled *bool
+				}
+				Linux_bionic struct {
+					Enabled *bool
+				}
+			}
+		}{}
+		disableTargets.Target.Darwin.Enabled = proptools.BoolPtr(false)
+		disableTargets.Target.Linux_bionic.Enabled = proptools.BoolPtr(false)
+
+		ctx.AppendProperties(&disableTargets)
+	})
+
 	return mod
 }