Merge "Docs: Update link to new Community page location"
diff --git a/core/clang/mips.mk b/core/clang/mips.mk
index 70832a3..b2ea579 100644
--- a/core/clang/mips.mk
+++ b/core/clang/mips.mk
@@ -14,6 +14,9 @@
   -msynci \
   -mno-fused-madd
 
+# Temporary workaround until GDB supports compact branches.
+CLANG_CONFIG_mips_UNKNOWN_CFLAGS += -mcompact-branches=never
+
 # Temporary workaround for Mips clang++ problem,  creates
 #   relocated ptrs in read-only pic .gcc_exception_table;
 #   permanent fix pending at http://reviews.llvm.org/D9669
diff --git a/core/clang/mips64.mk b/core/clang/mips64.mk
index ba9c1d1..0a90428 100644
--- a/core/clang/mips64.mk
+++ b/core/clang/mips64.mk
@@ -14,6 +14,9 @@
   -msynci \
   -mno-fused-madd
 
+# Temporary workaround until GDB supports compact branches.
+CLANG_CONFIG_mips64_UNKNOWN_CFLAGS += -mcompact-branches=never
+
 # Temporary workaround for Mips clang++ problem creating
 #   relocated ptrs in read-only pic .gcc_exception_table;
 #   permanent fix pending at http://reviews.llvm.org/D9669
diff --git a/core/combo/HOST_darwin-x86.mk b/core/combo/HOST_darwin-x86.mk
index 8389bb8..e77fd21 100644
--- a/core/combo/HOST_darwin-x86.mk
+++ b/core/combo/HOST_darwin-x86.mk
@@ -78,12 +78,14 @@
         -o $@ \
         -install_name @rpath/$(notdir $@) \
         -Wl,-rpath,@loader_path/../$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_OUT_SHARED_LIBRARIES)) \
+        -Wl,-rpath,@loader_path/$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_OUT_SHARED_LIBRARIES)) \
         $(PRIVATE_LDFLAGS)
 endef
 
 define transform-host-o-to-executable-inner
 $(hide) $(PRIVATE_CXX) \
         -Wl,-rpath,@loader_path/../$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_OUT_SHARED_LIBRARIES)) \
+        -Wl,-rpath,@loader_path/$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_OUT_SHARED_LIBRARIES)) \
         -o $@ \
         -Wl,-headerpad_max_install_names \
         $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_LD_DIRS) \
diff --git a/core/combo/TARGET_linux-mips.mk b/core/combo/TARGET_linux-mips.mk
index 962aa45..87a6144 100644
--- a/core/combo/TARGET_linux-mips.mk
+++ b/core/combo/TARGET_linux-mips.mk
@@ -79,6 +79,15 @@
   TARGET_mips_CFLAGS += -fno-omit-frame-pointer
 endif
 
+# For mips r6 (both 32bit and 64bit), GDB cannot stop on a breakpoint
+# if it is set on a compact branch. Turn generation of compact
+# branches off, to allow GDB to work properly.
+# Note: JIC instruction is not affected by this flag.
+# TODO: Remove this after GDB is fixed.
+ifeq ($(TARGET_ARCH),mips64)
+TARGET_mips_CFLAGS += -mcompact-branches=never
+endif
+
 android_config_h := $(call select-android-config-h,linux-mips)
 
 $(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += \
diff --git a/core/combo/TARGET_linux-mips64.mk b/core/combo/TARGET_linux-mips64.mk
index 1116f46..f01cdd1 100644
--- a/core/combo/TARGET_linux-mips64.mk
+++ b/core/combo/TARGET_linux-mips64.mk
@@ -79,6 +79,15 @@
   TARGET_mips_CFLAGS += -fno-omit-frame-pointer
 endif
 
+# For mips r6 (both 32bit and 64bit), GDB cannot stop on a breakpoint
+# if it is set on a compact branch. Turn generation of compact
+# branches off, to allow GDB to work properly.
+# Note: JIC instruction is not affected by this flag.
+# TODO: Remove this after GDB is fixed.
+ifeq ($(TARGET_ARCH),mips64)
+TARGET_mips_CFLAGS += -mcompact-branches=never
+endif
+
 android_config_h := $(call select-android-config-h,linux-mips64)
 
 TARGET_GLOBAL_CFLAGS += \
diff --git a/core/combo/TARGET_linux-x86.mk b/core/combo/TARGET_linux-x86.mk
index 482889d..f6dbcb8 100644
--- a/core/combo/TARGET_linux-x86.mk
+++ b/core/combo/TARGET_linux-x86.mk
@@ -97,10 +97,6 @@
 			-include $(android_config_h) \
 			-I $(dir $(android_config_h))
 
-# Work around gcc 4.9 devirtualization bug, https://b.corp.google.com/19872411.
-$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += \
-			-fno-devirtualize \
-
 $(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += $(arch_variant_cflags)
 
 ifeq ($(ARCH_X86_HAVE_SSSE3),true)   # yes, really SSSE3, not SSE3!
diff --git a/core/combo/TARGET_linux-x86_64.mk b/core/combo/TARGET_linux-x86_64.mk
index c705b95..7b9cd7b 100644
--- a/core/combo/TARGET_linux-x86_64.mk
+++ b/core/combo/TARGET_linux-x86_64.mk
@@ -93,10 +93,6 @@
 			-no-canonical-prefixes \
 			-fno-canonical-system-headers
 
-# Work around gcc 4.9 devirtualization bug, https://b.corp.google.com/19872411.
-TARGET_GLOBAL_CFLAGS += \
-			-fno-devirtualize \
-
 # Help catch common 32/64-bit errors.
 TARGET_GLOBAL_CFLAGS += \
     -Werror=pointer-to-int-cast \
diff --git a/core/definitions.mk b/core/definitions.mk
index 6bb3a99..87c94c0 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -1395,6 +1395,7 @@
 $(hide) $(PRIVATE_CXX) \
 	-Wl,-rpath-link=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_OUT_INTERMEDIATE_LIBRARIES) \
 	-Wl,-rpath,\$$ORIGIN/../$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_OUT_SHARED_LIBRARIES)) \
+	-Wl,-rpath,\$$ORIGIN/$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_OUT_SHARED_LIBRARIES)) \
 	-shared -Wl,-soname,$(notdir $@) \
 	$($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_LD_DIRS) \
 	$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
@@ -1611,6 +1612,7 @@
 	$(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
 	-Wl,-rpath-link=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_OUT_INTERMEDIATE_LIBRARIES) \
 	-Wl,-rpath,\$$ORIGIN/../$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_OUT_SHARED_LIBRARIES)) \
+	-Wl,-rpath,\$$ORIGIN/$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_OUT_SHARED_LIBRARIES)) \
 	$($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_LD_DIRS) \
 	$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
 		$(PRIVATE_HOST_GLOBAL_LDFLAGS) \
diff --git a/core/dex_preopt_libart.mk b/core/dex_preopt_libart.mk
index 6f598be..1de72b7 100644
--- a/core/dex_preopt_libart.mk
+++ b/core/dex_preopt_libart.mk
@@ -105,7 +105,7 @@
 	--instruction-set=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_ARCH) \
 	--instruction-set-variant=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_CPU_VARIANT) \
 	--instruction-set-features=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES) \
-	--include-patch-information --runtime-arg -Xnorelocate --no-include-debug-symbols --no-include-cfi \
+	--include-patch-information --runtime-arg -Xnorelocate --no-generate-debug-info \
 	--abort-on-hard-verifier-error \
 	$(PRIVATE_DEX_PREOPT_FLAGS)
 endef
diff --git a/core/dex_preopt_libart_boot.mk b/core/dex_preopt_libart_boot.mk
index cfc7653..afd61eb 100644
--- a/core/dex_preopt_libart_boot.mk
+++ b/core/dex_preopt_libart_boot.mk
@@ -62,5 +62,5 @@
 		--instruction-set=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_ARCH) \
 		--instruction-set-variant=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_CPU_VARIANT) \
 		--instruction-set-features=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES) \
-		--android-root=$(PRODUCT_OUT)/system --include-patch-information --runtime-arg -Xnorelocate --no-include-debug-symbols --no-include-cfi \
+		--android-root=$(PRODUCT_OUT)/system --include-patch-information --runtime-arg -Xnorelocate --no-generate-debug-info \
 		$(PRODUCT_DEX_PREOPT_BOOT_FLAGS) $(COMPILED_CLASSES_FLAGS)
diff --git a/envsetup.sh b/envsetup.sh
index bec6993..88c7c5c 100644
--- a/envsetup.sh
+++ b/envsetup.sh
@@ -29,7 +29,7 @@
     T=$(gettop)
     local A
     A=""
-    for i in `cat $T/build/envsetup.sh | sed -n "/^[ \t]*function /s/function \([a-z_]*\).*/\1/p" | sort | uniq`; do
+    for i in `cat $T/build/envsetup.sh | sed -n "/^[[:blank:]]*function /s/function \([a-z_]*\).*/\1/p" | sort | uniq`; do
       A="$A $i"
     done
     echo $A
@@ -1426,9 +1426,9 @@
     local retval=$?
     if [ $retval -ne 0 ]
     then
-        echo -e "\e[0;31mFAILURE\e[00m"
+        echo $'\E'"[0;31mFAILURE\e[00m"
     else
-        echo -e "\e[0;32mSUCCESS\e[00m"
+        echo $'\E'"[0;32mSUCCESS\e[00m"
     fi
     return $retval
 }
@@ -1450,9 +1450,9 @@
     local secs=$(($tdiff % 60))
     local ncolors=$(tput colors 2>/dev/null)
     if [ -n "$ncolors" ] && [ $ncolors -ge 8 ]; then
-        color_failed="\e[0;31m"
-        color_success="\e[0;32m"
-        color_reset="\e[00m"
+        color_failed=$'\E'"[0;31m"
+        color_success=$'\E'"[0;32m"
+        color_reset=$'\E'"[00m"
     else
         color_failed=""
         color_success=""
@@ -1460,9 +1460,9 @@
     fi
     echo
     if [ $ret -eq 0 ] ; then
-        echo -n -e "${color_success}#### make completed successfully "
+        echo -n "${color_success}#### make completed successfully "
     else
-        echo -n -e "${color_failed}#### make failed to build some targets "
+        echo -n "${color_failed}#### make failed to build some targets "
     fi
     if [ $hours -gt 0 ] ; then
         printf "(%02g:%02g:%02g (hh:mm:ss))" $hours $mins $secs
@@ -1471,7 +1471,7 @@
     elif [ $secs -gt 0 ] ; then
         printf "(%s seconds)" $secs
     fi
-    echo -e " ####${color_reset}"
+    echo " ####${color_reset}"
     echo
     return $ret
 }
diff --git a/tools/post_process_props.py b/tools/post_process_props.py
index fa6106f..9dcaadf 100755
--- a/tools/post_process_props.py
+++ b/tools/post_process_props.py
@@ -37,11 +37,12 @@
   # (this is for userdebug builds)
   if prop.get("ro.debuggable") == "1":
     val = prop.get("persist.sys.usb.config")
-    if val == "":
-      val = "adb"
-    else:
-      val = val + ",adb"
-    prop.put("persist.sys.usb.config", val)
+    if "adb" not in val:
+      if val == "":
+        val = "adb"
+      else:
+        val = val + ",adb"
+      prop.put("persist.sys.usb.config", val)
   # UsbDeviceManager expects a value here.  If it doesn't get it, it will
   # default to "adb". That might not the right policy there, but it's better
   # to be explicit.