From 74a14581164fc2e1700143ad1be06086e64414ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-Cl=C3=A9ment=20Tosi?= Date: Fri, 9 Dec 2022 18:49:29 +0000 Subject: [PATCH] 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 --- libc/Android.bp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/libc/Android.bp b/libc/Android.bp index 82fc0bcac..32d48f715 100644 --- a/libc/Android.bp +++ b/libc/Android.bp @@ -2261,6 +2261,37 @@ cc_library_static { defaults: ["crt_and_memtag_defaults"], } +// ======================================================== +// 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. // ========================================================