Merge "Supported python build in host side."
diff --git a/cc/cc.go b/cc/cc.go
index f368a13..dd73504 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -950,9 +950,10 @@
 
 		if tag == reuseObjTag {
 			if l, ok := cc.compiler.(libraryInterface); ok {
-				objs, flags := l.reuseObjs()
+				objs, flags, deps := l.reuseObjs()
 				depPaths.Objs = depPaths.Objs.Append(objs)
 				depPaths.ReexportedFlags = append(depPaths.ReexportedFlags, flags...)
+				depPaths.ReexportedFlagsDeps = append(depPaths.ReexportedFlagsDeps, deps...)
 				return
 			}
 		}
diff --git a/cc/compiler.go b/cc/compiler.go
index 8afd1bd..f7e787c 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -219,7 +219,6 @@
 		if !(ctx.sdk() || ctx.vndk()) || ctx.Host() {
 			flags.SystemIncludeFlags = append(flags.SystemIncludeFlags,
 				"${config.CommonGlobalIncludes}",
-				"${config.CommonGlobalSystemIncludes}",
 				tc.IncludeFlags(),
 				"${config.CommonNativehelperInclude}")
 		}
diff --git a/cc/config/clang.go b/cc/config/clang.go
index 30ab1c6..3ff6b1b 100644
--- a/cc/config/clang.go
+++ b/cc/config/clang.go
@@ -105,6 +105,11 @@
 		// Bug: http://b/29823425 Disable -Wnull-dereference until the
 		// new instances detected by this warning are fixed.
 		"-Wno-null-dereference",
+
+		// Enable clang's thread-safety annotations in libcxx.
+		// Turn off -Wthread-safety-negative, to avoid breaking projects that use -Weverything.
+		"-D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS",
+		"-Wno-thread-safety-negative",
 	}, " "))
 
 	pctx.StaticVariable("ClangExtraTargetCflags", strings.Join([]string{
diff --git a/cc/config/global.go b/cc/config/global.go
index 774f3f7..8c24289 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -112,9 +112,6 @@
 			"libnativehelper/include",
 			"frameworks/native/include",
 			"frameworks/native/opengl/include",
-		})
-	pctx.PrefixedPathsForOptionalSourceVariable("CommonGlobalSystemIncludes", "-isystem ",
-		[]string{
 			"frameworks/av/include",
 		})
 	// This is used by non-NDK modules to get jni.h. export_include_dirs doesn't help
diff --git a/cc/library.go b/cc/library.go
index 1a5de61..12a866b 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -202,6 +202,7 @@
 	// For reusing static library objects for shared library
 	reuseObjects       Objects
 	reuseExportedFlags []string
+	reuseExportedDeps  android.Paths
 
 	// table-of-contents file to optimize out relinking when possible
 	tocFile android.OptionalPath
@@ -364,7 +365,7 @@
 	getWholeStaticMissingDeps() []string
 	static() bool
 	objs() Objects
-	reuseObjs() (Objects, []string)
+	reuseObjs() (Objects, []string, android.Paths)
 	toc() android.OptionalPath
 
 	// Returns true if the build options for the module have selected a static or shared build
@@ -623,6 +624,7 @@
 			library.reexportFlags(flags)
 			library.reuseExportedFlags = append(library.reuseExportedFlags, flags...)
 			library.reexportDeps(library.baseCompiler.deps) // TODO: restrict to aidl deps
+			library.reuseExportedDeps = append(library.reuseExportedDeps, library.baseCompiler.deps...)
 		}
 	}
 
@@ -635,6 +637,7 @@
 			library.reexportFlags(flags)
 			library.reuseExportedFlags = append(library.reuseExportedFlags, flags...)
 			library.reexportDeps(library.baseCompiler.deps) // TODO: restrict to proto deps
+			library.reuseExportedDeps = append(library.reuseExportedDeps, library.baseCompiler.deps...)
 		}
 	}
 
@@ -659,8 +662,8 @@
 	return library.objects
 }
 
-func (library *libraryDecorator) reuseObjs() (Objects, []string) {
-	return library.reuseObjects, library.reuseExportedFlags
+func (library *libraryDecorator) reuseObjs() (Objects, []string, android.Paths) {
+	return library.reuseObjects, library.reuseExportedFlags, library.reuseExportedDeps
 }
 
 func (library *libraryDecorator) toc() android.OptionalPath {
diff --git a/cc/makevars.go b/cc/makevars.go
index ce2ac5a..22b9013 100644
--- a/cc/makevars.go
+++ b/cc/makevars.go
@@ -77,7 +77,7 @@
 
 	ctx.Strict("AIDL_CPP", "${aidlCmd}")
 
-	includeFlags, err := ctx.Eval("${config.CommonGlobalIncludes} ${config.CommonGlobalSystemIncludes}")
+	includeFlags, err := ctx.Eval("${config.CommonGlobalIncludes}")
 	if err != nil {
 		panic(err)
 	}