Update to remove direct include of jemalloc_new.
In order to support scudo for non-svelte malloc and jemalloc5 for
svelte malloc, do not include jemalloc_new directly. Move that to
the export_include_dirs for libjemalloc5.
Also, change the way to enable scudo so that it only enables it
for the non-svelte config for now.
Bug: 137795072
Test: Builds
Change-Id: I3d68b443fe4d6b21729795649d0dcf66b7e95e03
diff --git a/libc/Android.bp b/libc/Android.bp
index 0950ebd..ef1bbe8 100644
--- a/libc/Android.bp
+++ b/libc/Android.bp
@@ -86,25 +86,27 @@
},
}
+libc_scudo_product_variables = {
+ malloc_not_svelte: {
+ cflags: ["-DUSE_SCUDO"],
+ whole_static_libs: ["libscudo"],
+ exclude_static_libs: [
+ "libjemalloc5",
+ "libc_jemalloc_wrapper",
+ ],
+ },
+}
+
// Defaults for native allocator libs/includes to make it
// easier to change.
-// To enable scudo, change the below to libc_scudo_defaults
-// and comment out the defaults line in libc_scudo shared
-// library.
+// Enable scudo for non-svelte config by adding the line:
+// product_variables: libc_scudo_product_variables,
+// to the cc_defaults below. And remove the defaults line
+// in the libc_scudo library.
// ========================================================
cc_defaults {
name: "libc_native_allocator_defaults",
- defaults: ["libc_jemalloc5_defaults"],
-}
-
-cc_defaults {
- name: "libc_jemalloc5_defaults",
-
- include_dirs: [
- "external/jemalloc_new/include",
- ],
-
whole_static_libs: [
"libjemalloc5",
"libc_jemalloc_wrapper",
@@ -119,30 +121,9 @@
srcs: ["bionic/jemalloc_wrapper.cpp"],
cflags: ["-fvisibility=hidden"],
- include_dirs: [
- "external/jemalloc_new/include",
- ],
-}
-
-cc_defaults {
- name: "libc_scudo_defaults",
-
- cflags: [
- "-DUSE_SCUDO_SVELTE",
- ],
-
- product_variables: {
- malloc_not_svelte: {
- cflags: [
- "-UUSE_SCUDO_SVELTE",
- "-DUSE_SCUDO",
- ],
- },
- },
-
- whole_static_libs: [
- "libscudo",
- ],
+ // Used to pull in the jemalloc include directory so that if the
+ // library is removed, the include directory is also removed.
+ static_libs: ["libjemalloc5"],
}
// ========================================================