1// 2// Copyright (C) 2020 The Android Open Source Project 3// 4// Licensed under the Apache License, Version 2.0 (the "License"); 5// you may not use this file except in compliance with the License. 6// You may obtain a copy of the License at 7// 8// http://www.apache.org/licenses/LICENSE-2.0 9// 10// Unless required by applicable law or agreed to in writing, software 11// distributed under the License is distributed on an "AS IS" BASIS, 12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13// See the License for the specific language governing permissions and 14// limitations under the License. 15// 16 17// We introduce this namespace so that native bridge guest libraries are built 18// only for targets that explicitly use this namespace via PRODUCT_SOONG_NAMESPACES 19// and checkbuild. 20soong_namespace { 21} 22 23package { 24 default_applicable_licenses: ["Android-Apache-2.0"], 25} 26 27cc_library { 28 defaults: [ 29 "native_bridge_stub_library_defaults", 30 // Definitions come from bionic/libc/Android.bp that force 31 // the usage of the correct native allocator. 32 "libc_native_allocator_defaults", 33 ], 34 name: "libnative_bridge_guest_libc", 35 overrides: ["libc"], 36 stem: "libc", 37 38 srcs: [ 39 ":libc_sources_shared", 40 "__cxa_thread_atexit_impl.cpp", 41 "__libc_add_main_thread.cpp", 42 "__libc_init_scudo.cpp", 43 "__libc_set_target_sdk_version.cpp", 44 "exit.c", 45 "malloc_init.cpp", 46 ], 47 48 include_dirs: [ 49 "bionic/libc", 50 "bionic/libc/arch-common/bionic", 51 "bionic/libc/async_safe/include", 52 "bionic/libc/bionic", 53 "bionic/libc/stdio", 54 "bionic/libstdc++/include", 55 ], 56 57 cflags: [ 58 "-D_LIBC=1", 59 "-fno-emulated-tls", // Required for GWP-Asan. 60 ], 61 62 product_variables: { 63 platform_sdk_version: { 64 asflags: ["-DPLATFORM_SDK_VERSION=%d"], 65 cflags: ["-DPLATFORM_SDK_VERSION=%d"], 66 }, 67 }, 68 69 arch: { 70 arm: { 71 srcs: [ 72 ":libc_sources_shared_arm", 73 "stubs_arm.cpp", 74 ], 75 76 cflags: [ 77 "-DCRT_LEGACY_WORKAROUND", 78 ], 79 80 version_script: ":libc.arm.map", 81 no_libcrt: true, 82 83 shared: { 84 // For backwards-compatibility, some arm32 builtins are exported from libc.so. 85 static_libs: ["libclang_rt.builtins-arm-android-exported"], 86 }, 87 88 // Arm 32 bit does not produce complete exidx unwind information 89 // so keep the .debug_frame which is relatively small and does 90 // include needed unwind information. 91 // See b/132992102 for details. 92 strip: { 93 keep_symbols_and_debug_frame: true, 94 }, 95 }, 96 arm64: { 97 srcs: ["stubs_arm64.cpp"], 98 99 version_script: ":libc.arm64.map", 100 101 // Leave the symbols in the shared library so that stack unwinders can produce 102 // meaningful name resolution. 103 strip: { 104 keep_symbols: true, 105 }, 106 } 107 }, 108 109 nocrt: true, 110 111 required: ["tzdata"], 112 113 whole_static_libs: [ 114 "gwp_asan", 115 "libc_init_dynamic", 116 "libc_common_shared", 117 "libunwind-exported", 118 ], 119 120 shared_libs: [ 121 "ld-android", 122 "libdl", 123 ], 124 125 static_libs: [ 126 "libdl_android", 127 ], 128 129 system_shared_libs: [], 130 stl: "none", 131 132 strip: { 133 keep_symbols: true, 134 }, 135 136 sanitize: { 137 never: true, 138 }, 139 140 // lld complains about duplicate symbols in libcrt and libgcc. Suppress the 141 // warning since this is intended right now. 142 // Bug: 117558759 143 ldflags: ["-Wl,-z,muldefs"], 144} 145