Remove ExtractCodeAndPrelink and switch Portable to MCLinker

Change-Id: Ia2459c7da6b79e0a1c0f1148c6e28ad9cbbe27a2
diff --git a/build/Android.libart-compiler.mk b/build/Android.libart-compiler.mk
index 9e11e22..8f0ccf8 100644
--- a/build/Android.libart-compiler.mk
+++ b/build/Android.libart-compiler.mk
@@ -48,6 +48,7 @@
 	src/compiler/dex/ralloc.cc \
 	src/compiler/dex/ssa_transformation.cc \
 	src/compiler/dex/write_elf.cc \
+	src/compiler/driver/dex_compilation_unit.cc \
 	src/compiler/invoke_stubs/portable/stub_compiler.cc \
 	src/compiler/invoke_stubs/quick/jni_internal_arm.cc \
 	src/compiler/invoke_stubs/quick/jni_internal_mips.cc \
@@ -184,9 +185,22 @@
 ifeq ($(ART_BUILD_TARGET_DEBUG),true)
   $(eval $(call build-libart-compiler,target,debug))
 endif
-ifeq ($(ART_BUILD_HOST_NDEBUG),true)
+# We always build dex2oat and dependencies, even if the host build is otherwise disabled, since they are used to cross compile for the target.
+ifeq ($(ART_BUILD_NDEBUG),true)
   $(eval $(call build-libart-compiler,host,ndebug))
 endif
-ifeq ($(ART_BUILD_HOST_DEBUG),true)
+ifeq ($(ART_BUILD_DEBUG),true)
   $(eval $(call build-libart-compiler,host,debug))
 endif
+
+# Rule to build /system/lib/libcompiler-rt.a
+# Usually static libraries are not installed on the device.
+ifeq ($(ART_USE_PORTABLE_COMPILER),true)
+ifeq ($(ART_BUILD_TARGET),true)
+# TODO: Move to external/compiler-rt
+$(eval $(call copy-one-file, $(call intermediates-dir-for,STATIC_LIBRARIES,libcompiler-rt,,)/libcompiler-rt.a, $(TARGET_OUT_SHARED_LIBRARIES)/libcompiler-rt.a))
+
+$(DEX2OAT): $(TARGET_OUT_SHARED_LIBRARIES)/libcompiler-rt.a
+
+endif
+endif