1package { 2 default_applicable_licenses: ["Android-Apache-2.0"], 3} 4 5// The hierarchy of Soong modules to produce a vmbase-based binary is 6// 7// 0. rlibs may be used to provide high-level code (see "vmbase_rlib_defaults"); 8// 1. rust_ffi_static packages low-level Rust code and any rlib into a static 9// library (see "vmbase_ffi_defaults") that cc_binary supports; 10// 2. cc_library_static may be used for extra C code (see "vmbase_cc_defaults"); 11// 3. cc_binary produces an ELF from the (single) Rust-wrapping static library, 12// optional extra C libraries, and linker script (see "vmbase_elf_defaults"); 13// 4. raw_binary strips the ELF into an image that can be loaded to memory; 14 15// Used by intermediate rust_library_rlib for vmbase-based binaries. 16rust_defaults { 17 name: "vmbase_rlib_defaults", 18 defaults: ["avf_build_flags_rust"], 19 edition: "2021", 20 prefer_rlib: true, 21 host_supported: false, 22 enabled: false, 23 no_stdlibs: true, 24 stdlibs: [ 25 "libcompiler_builtins.rust_sysroot", 26 "libcore.rust_sysroot", 27 ], 28 target: { 29 android_arm64: { 30 enabled: true, 31 }, 32 }, 33} 34 35// Used by the "top-level" rust_ffi_static of vmbase-based binaries. 36rust_defaults { 37 name: "vmbase_ffi_defaults", 38 defaults: ["vmbase_rlib_defaults"], 39} 40 41// Used by extra cc_library_static linked into the final ELF. 42cc_defaults { 43 name: "vmbase_cc_defaults", 44 defaults: ["avf_build_flags_cc"], 45 nocrt: true, 46 no_libcrt: true, 47 system_shared_libs: [], 48 stl: "none", 49 installable: false, 50 enabled: false, 51 target: { 52 android_arm64: { 53 enabled: true, 54 }, 55 }, 56 sanitize: { 57 hwaddress: false, 58 }, 59 native_coverage: false, 60 // TODO(b/346974429): Workaround pvmfw failure when enabling full LTO 61 lto_O0: true, 62} 63 64// Used by cc_binary when producing the ELF of a vmbase-based binary. 65cc_defaults { 66 name: "vmbase_elf_defaults", 67 defaults: ["vmbase_cc_defaults"], 68 static_executable: true, 69 static_libs: [ 70 "libvmbase_entry", 71 ], 72} 73 74rust_library_rlib { 75 name: "libvmbase", 76 defaults: ["vmbase_rlib_defaults"], 77 crate_name: "vmbase", 78 srcs: ["src/lib.rs"], 79 rustlibs: [ 80 "libbuddy_system_allocator", 81 "libcfg_if", 82 "libhypervisor_backends", 83 "liblibfdt_nostd", 84 "liblog_rust_nostd", 85 "libonce_cell_nostd", 86 "libsafe_mmio", 87 "libspin_nostd", 88 "libstatic_assertions", 89 "libthiserror_nostd", 90 "libtinyvec_nostd", 91 "libuuid_nostd", 92 "libvirtio_drivers", 93 "libzerocopy_nostd", 94 "libzeroize_nostd", 95 ], 96 whole_static_libs: [ 97 "librust_baremetal", 98 ], 99 target: { 100 android_arm64: { 101 rustlibs: [ 102 "libaarch64_paging", 103 "libsmccc", 104 ], 105 // TODO(b/277859415, b/277860860): Drop "compat_android_13". 106 features: [ 107 "compat_android_13", 108 "cpu_feat_hafdbs", 109 ], 110 }, 111 }, 112} 113 114cc_library_static { 115 name: "libvmbase_entry", 116 defaults: ["vmbase_cc_defaults"], 117 srcs: [], 118 target: { 119 android_arm64: { 120 srcs: [ 121 "asm/aarch64/entry.S", 122 "asm/aarch64/exceptions.S", 123 "asm/aarch64/exceptions_panic.S", 124 ], 125 }, 126 }, 127} 128 129filegroup { 130 name: "vmbase_sections", 131 srcs: ["sections.ld"], 132} 133