Introduce minimal static libc for baremetal Rust
LLVM/rustc compiling no_std code expects a few libc symbols to be
defined (memcpy, memset, memcmp). Previously, we used the arm64 library
directly; instead, make the dependency arch-agnostic by exporting it
from Bionic, making it easier to add more libc functions (that might not
be implemented by the optimized routines), as necessary.
Test: m pvmfw_bin && atest vmbase_example.integration_test
Change-Id: I1d2cc69a25bbb7eddc67357a028b7b79d4909e79
diff --git a/libc/Android.bp b/libc/Android.bp
index 82fc0bc..32d48f7 100644
--- a/libc/Android.bp
+++ b/libc/Android.bp
@@ -2262,6 +2262,37 @@
}
// ========================================================
+// libc dependencies for baremetal Rust projects.
+// ========================================================
+
+cc_defaults {
+ name: "librust_baremetal_defaults",
+ header_libs: ["libc_headers"],
+ include_dirs: [
+ "bionic/libc/async_safe/include",
+ "bionic/libc/platform",
+ ],
+ cflags: [
+ "-Wall",
+ "-Werror",
+ ],
+ system_shared_libs: [],
+ nocrt: true,
+ stl: "none",
+}
+
+cc_library_static {
+ name: "librust_baremetal",
+ defaults: ["librust_baremetal_defaults"],
+ whole_static_libs: [
+ "libarm-optimized-routines-mem",
+ ],
+ visibility: [
+ "//packages/modules/Virtualization/vmbase",
+ ],
+}
+
+// ========================================================
// NDK headers.
// ========================================================