rust: Add support for host fuzzers.

Adds support for host-based Rust fuzzers.

Bug: 282897366
Test: SANITZE_HOST="address" m <host_fuzzer>
Test: run fuzzer
Change-Id: Ibb951f651ef12e763778ebbf12e66769a7113920
diff --git a/rust/compiler.go b/rust/compiler.go
index 06ae12f..8d89c48 100644
--- a/rust/compiler.go
+++ b/rust/compiler.go
@@ -320,6 +320,15 @@
 		flags.LinkFlags = append(flags.LinkFlags, cc.RpathFlags(ctx)...)
 	}
 
+	if !ctx.toolchain().Bionic() && ctx.Os() != android.LinuxMusl && !ctx.Windows() {
+		// Add -ldl, -lpthread, -lm and -lrt to host builds to match the default behavior of device
+		// builds. This is irrelevant for the Windows target as these are Posix specific.
+		flags.LinkFlags = append(flags.LinkFlags,
+			"-ldl",
+			"-lpthread",
+			"-lm",
+		)
+	}
 	return flags
 }