Clean up libbase(_header) dependencies in libdexfile_support.
We must not depend dynamically on non-NDK libraries in
libdexfile_support, because it becomes a prebuilt that has to work on
older platforms. (Removing the libbase dependency is a NOP change since
no symbols from it are used now.)
We also must not re-export any platform header files, because they'll
then get added to the include path for the caller and may hide the
headers they should be using.
Plenty of platform and external headers are still exported by the
libdexfile and libdexfile_static prebuilts, but the former isn't a real
problem and the latter is an already known problem. Add some comments
to discuss both.
Test: Build prebuilts on internal git_master-art and use the S
prebuilts in a SCv2 tree with ag/19239336 and
https://r.android.com/2267725
Bug: 282171830
Bug: 169885605
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:f34513630c38f485454d93b6f6c5c86aed117b44)
Merged-In: Ibff288cd14400015456b04b805efbfd6d76a89a3
Change-Id: Ibff288cd14400015456b04b805efbfd6d76a89a3
diff --git a/libdexfile/Android.bp b/libdexfile/Android.bp
index 4e76549..9c2acac 100644
--- a/libdexfile/Android.bp
+++ b/libdexfile/Android.bp
@@ -216,6 +216,14 @@
"com.android.art.debug",
"test_broken_com.android.art",
],
+
+ // This library is exported in stub form by art-module-sdk, and it brings
+ // with it all the exported headers from libartbase and libbase, many of
+ // which are transitive dependencies outside ART. Those may conflict with
+ // other versions of the headers that the caller is using in their build,
+ // but in this case it's fine since external users only depend on this
+ // through runtime_libs (see comment for libdexfile_support), which doesn't
+ // propagate include dirs.
stubs: {
symbol_file: "libdexfile.map.txt",
versions: ["1"],
@@ -332,8 +340,6 @@
defaults: ["art_defaults"],
visibility: ["//visibility:public"],
host_supported: true,
- header_libs: ["libbase_headers"],
- export_header_lib_headers: ["libbase_headers"],
export_include_dirs: ["external/include"],
target: {
@@ -435,11 +441,12 @@
"external/dex_file_supp.cc",
],
runtime_libs: ["libdexfile"],
- shared_libs: [
- "liblog",
- "libbase",
- ],
+ // Only NDK libs may be dynamic, because this becomes a prebuilt that must work on S+.
+ shared_libs: ["liblog"],
header_libs: ["libdexfile_external_headers"],
+ // Do not export any headers outside the ART module - they get included in
+ // the prebuilt SDK and may conflict with different versions of themselves
+ // in the build that the SDK user is using.
export_header_lib_headers: ["libdexfile_external_headers"],
apex_available: [
@@ -544,6 +551,13 @@
// For use by external packages allowed to link in static libdexfile_support.
// This is not allowed in any module that may end up in an APEX or platform
// image, so visibility is restrictive.
+//
+// TODO(b/169885605): This library brings with it all the exported headers from
+// libdexfile_support_static_defaults into the prebuilt SDK created by
+// art-module-sdk, many of which are transitive dependencies outside ART. Those
+// may conflict with other versions that the caller is using in their build. One
+// way to deal with that is to provide minimal headers without any transitive
+// dependencies on other headers.
cc_library_static {
name: "libdexfile_static",
host_supported: true,
diff --git a/libdexfile/external/dex_file_supp.cc b/libdexfile/external/dex_file_supp.cc
index 23fc88a..617dc88 100644
--- a/libdexfile/external/dex_file_supp.cc
+++ b/libdexfile/external/dex_file_supp.cc
@@ -21,9 +21,6 @@
#include <mutex>
#include <sys/stat.h>
-#include <android-base/mapped_file.h>
-#include <android-base/stringprintf.h>
-
#ifndef STATIC_LIB
// Not used in the static lib, so avoid a dependency on this header in
// libdexfile_support_static.
diff --git a/libdexfile/external/include/art_api/dex_file_support.h b/libdexfile/external/include/art_api/dex_file_support.h
index 2361bf9..d283929 100644
--- a/libdexfile/external/include/art_api/dex_file_support.h
+++ b/libdexfile/external/include/art_api/dex_file_support.h
@@ -22,8 +22,6 @@
#include <memory>
#include <string>
-#include <android-base/macros.h>
-
#include "art_api/dex_file_external.h"
namespace art_api {
@@ -128,7 +126,11 @@
ADexFile* const self_;
- DISALLOW_COPY_AND_ASSIGN(DexFile);
+ // Have to expand DISALLOW_COPY_AND_ASSIGN here, since we cannot depend on
+ // libbase headers without re-exporting them, and that may make them override
+ // the non-ABI compatible headers that the libdexfile_support user may have.
+ DexFile(const DexFile&) = delete;
+ void operator=(const DexFile&) = delete;
};
} // namespace dex