Revert "Use prebuilt Runtime (Bionic) APEX and SDK (reland)."

Reason for revert: Breaks several test systems that need TARGET_BUILD_UNBUNDLED.
Reverted Changes:
I0a5023be9:Add scaffolding for Runtime (Bionic) SDK.
I085dc634a:Enable TARGET_BUILD_UNBUNDLED in master-art.
I2f68dff3e:Avoid stderr warnings from Bionic in the run tests...
I98f93d501:Drop Bionic from the tree - should now use prebuil...
I9c5c7edd4:Use prebuilt Runtime (Bionic) APEX and SDK (reland...
Id6513d953:Update mainline prebuilts to build 6582130.

Change-Id: If5176eff22ec68cedc70b951780f40a059d35a01
diff --git a/Android.mk b/Android.mk
index 63eb01e..d8340bd 100644
--- a/Android.mk
+++ b/Android.mk
@@ -474,6 +474,23 @@
 .PHONY: build-art-target
 build-art-target: $(TARGET_OUT_EXECUTABLES)/art $(ART_TARGET_DEPENDENCIES) $(TARGET_CORE_IMG_OUTS)
 
+########################################################################
+# Workaround for not using symbolic links for linker and bionic libraries
+# in a minimal setup (eg buildbot or golem).
+########################################################################
+
+PRIVATE_BIONIC_FILES := \
+  bin/bootstrap/linker \
+  bin/bootstrap/linker64 \
+  lib/bootstrap/libc.so \
+  lib/bootstrap/libm.so \
+  lib/bootstrap/libdl.so \
+  lib/bootstrap/libdl_android.so \
+  lib64/bootstrap/libc.so \
+  lib64/bootstrap/libm.so \
+  lib64/bootstrap/libdl.so \
+  lib64/bootstrap/libdl_android.so \
+
 PRIVATE_ART_APEX_DEPENDENCY_FILES := \
   bin/dalvikvm32 \
   bin/dalvikvm64 \
@@ -538,18 +555,6 @@
   lib64/libprofile.so \
   lib64/libvixl.so \
 
-PRIVATE_RUNTIME_APEX_DEPENDENCY_FILES := \
-  bin/linker \
-  bin/linker64 \
-  lib/bionic/libc.so \
-  lib/bionic/libdl.so \
-  lib/bionic/libdl_android.so \
-  lib/bionic/libm.so \
-  lib64/bionic/libc.so \
-  lib64/bionic/libdl.so \
-  lib64/bionic/libdl_android.so \
-  lib64/bionic/libm.so \
-
 PRIVATE_CONSCRYPT_APEX_DEPENDENCY_LIBS := \
   lib/libcrypto.so \
   lib/libjavacrypto.so \
@@ -597,9 +602,18 @@
   done
 endef
 
-# Copy or extract some required files from APEXes to the `system` (TARGET_OUT)
-# directory. This is dangerous as these files could inadvertently stay in this
-# directory and be included in a system image.
+# Generate copies of Bionic bootstrap artifacts and ART APEX
+# libraries in the `system` (TARGET_OUT) directory. This is dangerous
+# as these files could inadvertently stay in this directory and be
+# included in a system image.
+#
+# Copy some libraries into `$(TARGET_OUT)/lib(64)` (the
+# `/system/lib(64)` directory to be sync'd to the target) for ART testing
+# purposes:
+# - Bionic bootstrap libraries, copied from
+#   `$(TARGET_OUT)/lib(64)/bootstrap` (the `/system/lib(64)/bootstrap`
+#   directory to be sync'd to the target);
+# - Programs and libraries from various APEXes.
 #
 # This target is only used by Golem now.
 #
@@ -611,21 +625,20 @@
 # ART APEX.
 .PHONY: standalone-apex-files
 standalone-apex-files: deapexer \
+                       libc.bootstrap \
+                       libdl.bootstrap \
+                       libdl_android.bootstrap \
+                       libm.bootstrap \
+                       linker \
                        $(RELEASE_ART_APEX) \
-                       $(RUNTIME_APEX) \
                        $(CONSCRYPT_APEX) \
                        $(I18N_APEX)
+	for f in $(PRIVATE_BIONIC_FILES); do \
+	  tf=$(TARGET_OUT)/$$f; \
+	  if [ -f $$tf ]; then cp -f $$tf $$(echo $$tf | sed 's,bootstrap/,,'); fi; \
+	done
 	$(call extract-from-apex,$(RELEASE_ART_APEX),\
 	  $(PRIVATE_ART_APEX_DEPENDENCY_LIBS) $(PRIVATE_ART_APEX_DEPENDENCY_FILES))
-	# The Runtime APEX has the Bionic libs in ${LIB}/bionic subdirectories,
-	# so we need to move them up a level after extraction.
-	$(call extract-from-apex,$(RUNTIME_APEX),\
-	  $(PRIVATE_RUNTIME_APEX_DEPENDENCY_FILES)) && \
-	  for libdir in $(TARGET_OUT)/lib $(TARGET_OUT)/lib64; do \
-	    if [ -d $$libdir/bionic ]; then \
-	      mv -f $$libdir/bionic/*.so $$libdir; \
-	    fi || exit 1; \
-	  done
 	$(call extract-from-apex,$(CONSCRYPT_APEX),\
 	  $(PRIVATE_CONSCRYPT_APEX_DEPENDENCY_LIBS))
 	$(call extract-from-apex,$(I18N_APEX),\
@@ -638,8 +651,10 @@
 # Also include libartbenchmark, we always include it when running golem.
 # libstdc++ is needed when building for ART_TARGET_LINUX.
 
-# Also include the Bionic libraries (libc, libdl, libdl_android, libm) and
-# linker.
+# Also include the bootstrap Bionic libraries (libc, libdl, libdl_android,
+# libm). These are required as the "main" libc, libdl, libdl_android, and libm
+# have moved to the ART APEX. This is a temporary change needed until Golem
+# fully supports the ART APEX.
 #
 # TODO(b/129332183): Remove this when Golem has full support for the
 # ART APEX.
@@ -675,6 +690,7 @@
                         $(TARGET_OUT)/etc/public.libraries.txt \
                         $(ART_TARGET_SHARED_LIBRARY_BENCHMARK) \
                         libartpalette-system \
+                        libc.bootstrap libdl.bootstrap libdl_android.bootstrap libm.bootstrap \
                         icu-data-art-test-i18n \
                         tzdata-art-test-tzdata tzlookup.xml-art-test-tzdata \
                         tz_version-art-test-tzdata icu_overlay-art-test-tzdata \
diff --git a/build/Android.common_path.mk b/build/Android.common_path.mk
index 3ff2612..54e337e 100644
--- a/build/Android.common_path.mk
+++ b/build/Android.common_path.mk
@@ -120,8 +120,6 @@
 # Testing ART APEX, used in ART device testing.
 TESTING_ART_APEX := com.android.art.testing
 
-# Runtime (Bionic) APEX
-RUNTIME_APEX := com.android.runtime
 # Conscrypt APEX
 CONSCRYPT_APEX := com.android.conscrypt
 # i18n APEX
diff --git a/tools/buildbot-build.sh b/tools/buildbot-build.sh
index dd8c188..3c39619 100755
--- a/tools/buildbot-build.sh
+++ b/tools/buildbot-build.sh
@@ -91,8 +91,9 @@
   make_command="build/soong/soong_ui.bash --make-mode $j_arg $extra_args $showcommands build-art-target-tests $common_targets"
   make_command+=" libnetd_client-target toybox sh"
   make_command+=" debuggerd su gdbserver"
+  make_command+=" libstdc++ "
   # vogar requires the class files for conscrypt.
-  make_command+=" conscrypt"
+  make_command+=" conscrypt "
   make_command+=" ${ANDROID_PRODUCT_OUT#"${ANDROID_BUILD_TOP}/"}/system/etc/public.libraries.txt"
   # Targets required to generate a linker configuration for device within the
   # chroot environment. The *.libraries.txt targets are required by
@@ -101,9 +102,14 @@
   # work in an unbundled tree.
   make_command+=" host_linkerconfig_all_targets sanitizer.libraries.txt vndkcorevariant.libraries.txt"
   # Additional targets needed for the chroot environment.
-  make_command+=" event-log-tags"
-  # Needed to extract prebuilt APEXes.
-  make_command+=" deapexer"
+  make_command+=" crash_dump event-log-tags"
+  # Needed to extract prebuilts apexes.
+  make_command+=" deapexer "
+  # Build the bootstrap Bionic artifacts links (linker, libc, libdl, libm).
+  # These targets create these symlinks:
+  # - from /system/bin/linker(64) to /apex/com.android.runtime/bin/linker(64); and
+  # - from /system/lib(64)/$lib to /apex/com.android.runtime/lib(64)/$lib.
+  make_command+=" linker libc.bootstrap libdl.bootstrap libdl_android.bootstrap libm.bootstrap"
   # Build/install the required APEXes.
   make_command+=" ${apexes[*]}"
 fi
@@ -196,23 +202,6 @@
       $ANDROID_PRODUCT_OUT/system/usr/share/zoneinfo/tzdata
   fi
 
-  # Create system symlinks for the Runtime APEX. Normally handled by
-  # installSymlinkToRuntimeApex in soong/cc/binary.go, but we have to replicate
-  # it here since we don't run the install rules for the Runtime APEX.
-  for b in linker{,_asan}{,64}; do
-    echo "Symlinking /apex/com.android.runtime/bin/$b to /system/bin"
-    ln -sf /apex/com.android.runtime/bin/$b $ANDROID_PRODUCT_OUT/system/bin/$b
-  done
-  for p in $ANDROID_PRODUCT_OUT/system/apex/com.android.runtime/lib{,64}/bionic/*; do
-    lib_dir=$(expr $p : '.*/\(lib[0-9]*\)/.*')
-    lib_file=$(basename $p)
-    src=/apex/com.android.runtime/${lib_dir}/bionic/${lib_file}
-    dst=$ANDROID_PRODUCT_OUT/system/${lib_dir}/${lib_file}
-    echo "Symlinking $src into /system/${lib_dir}"
-    mkdir -p $(dirname $dst)
-    ln -sf $src $dst
-  done
-
   # Create linker config files. We run linkerconfig on host to avoid problems
   # building it statically for device in an unbundled tree.