Add libdexfiled_external to the debug Runtime APEX.

Follow up to http://r.android.com/943476. This library is only available in
debug builds of the Runtime APEX.

Test: Flash and boot with eng build
Test: adb shell ls apex/com.android.runtime/lib\*/libdexfiled_external.so
Change-Id: Ib6bbfacc19416ac1221a962f111b3937e61193e7
diff --git a/build/apex/Android.bp b/build/apex/Android.bp
index 95aea3c..82c8392 100644
--- a/build/apex/Android.bp
+++ b/build/apex/Android.bp
@@ -76,6 +76,7 @@
     "libadbconnectiond",
     "libartd",
     "libartd-compiler",
+    "libdexfiled_external",
     "libopenjdkjvmd",
     "libopenjdkjvmtid",
 ]
diff --git a/build/apex/art_apex_test.py b/build/apex/art_apex_test.py
index 93998e0..d3ba1c1 100755
--- a/build/apex/art_apex_test.py
+++ b/build/apex/art_apex_test.py
@@ -570,6 +570,7 @@
     self._checker.check_executable('oatdumpd')
 
     # Check ART internal libraries.
+    self._checker.check_native_library('libdexfiled_external')
     self._checker.check_prefer64_library('libartd-disassembler')
 
     # Check internal native library dependencies.
diff --git a/build/apex/ld.config.txt b/build/apex/ld.config.txt
index b1d7fec..25c8a65 100644
--- a/build/apex/ld.config.txt
+++ b/build/apex/ld.config.txt
@@ -32,11 +32,12 @@
 namespace.platform.search.paths = /system/${LIB}
 namespace.platform.asan.search.paths = /data/asan/system/${LIB}
 namespace.platform.links = default
-namespace.platform.link.default.shared_libs  = libdexfile_external.so
+namespace.platform.link.default.shared_libs  = libandroidicu.so
+namespace.platform.link.default.shared_libs += libdexfile_external.so
+namespace.platform.link.default.shared_libs += libdexfiled_external.so
 namespace.platform.link.default.shared_libs += libnativebridge.so
 namespace.platform.link.default.shared_libs += libnativehelper.so
 namespace.platform.link.default.shared_libs += libnativeloader.so
-namespace.platform.link.default.shared_libs += libandroidicu.so
 
 # TODO(b/122876336): Remove libpac.so once it's migrated to Webview
 namespace.platform.link.default.shared_libs += libpac.so
diff --git a/libartbase/base/globals.cc b/libartbase/base/globals.cc
index e6203a2..dfac92a 100644
--- a/libartbase/base/globals.cc
+++ b/libartbase/base/globals.cc
@@ -26,6 +26,11 @@
 
 #if !defined(_WIN32)
 // Check that we have not loaded both debug and release version of libartbase at the same time.
+//
+// This can be a cascade problem originating from a call to
+// LoadLibdexfileExternal in libdexfile_support: If it was called before any ART
+// libraries were loaded it will default to the non-debug version, which can
+// then clash with a later load of the debug version.
 static struct CheckLoadedBuild {
   CheckLoadedBuild() {
     bool debug_build_loaded = (dlopen("libartbased.so", RTLD_NOW | RTLD_NOLOAD) != nullptr);