Merge "Remove the common bionic libc kernel directory."
diff --git a/android/variable.go b/android/variable.go
index b0639ae..d2dc5b9 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -58,6 +58,10 @@
 		Schedboost struct {
 			Cflags []string
 		}
+
+		Binder32bit struct {
+			Cflags []string
+		}
 	} `android:"arch_variant"`
 }
 
@@ -96,6 +100,7 @@
 	HostStaticBinaries         *bool `json:",omitempty"`
 	Cpusets                    *bool `json:",omitempty"`
 	Schedboost                 *bool `json:",omitempty"`
+	Binder32bit                *bool `json:",omitempty"`
 
 	SanitizeHost   *[]string `json:",omitempty"`
 	SanitizeDevice *[]string `json:",omitempty"`
diff --git a/cc/androidmk.go b/cc/androidmk.go
index 70e1f47..4f76dc9 100644
--- a/cc/androidmk.go
+++ b/cc/androidmk.go
@@ -99,6 +99,7 @@
 		}
 
 		fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+outputFile.Ext())
+		fmt.Fprintln(w, "LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE)$(LOCAL_MODULE_SUFFIX)")
 
 		fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=")
 
diff --git a/cc/cc.go b/cc/cc.go
index acc807f..51760fc 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -402,6 +402,9 @@
 	// local file name to pass to the linker as -force_symbols_weak_list
 	Force_symbols_weak_list *string `android:"arch_variant"`
 
+	// rename host libraries to prevent overlap with system installed libraries
+	Unique_host_soname *bool
+
 	VariantName string `blueprint:"mutated"`
 }
 
@@ -1605,11 +1608,23 @@
 		&library.stripper.StripProperties)
 }
 
+func (library *libraryLinker) getLibName(ctx ModuleContext) string {
+	name := ctx.ModuleName()
+
+	if ctx.Host() && Bool(library.Properties.Unique_host_soname) {
+		if !strings.HasSuffix(name, "-host") {
+			name = name + "-host"
+		}
+	}
+
+	return name + library.Properties.VariantName
+}
+
 func (library *libraryLinker) flags(ctx ModuleContext, flags Flags) Flags {
 	flags = library.baseLinker.flags(ctx, flags)
 
 	if !library.static() {
-		libName := ctx.ModuleName() + library.Properties.VariantName
+		libName := library.getLibName(ctx)
 		// GCC for Android assumes that -shared means -Bsymbolic, use -Wl,-shared instead
 		sharedFlag := "-Wl,-shared"
 		if flags.Clang || ctx.Host() {
@@ -1729,7 +1744,7 @@
 		}
 	}
 
-	fileName := ctx.ModuleName() + library.Properties.VariantName + flags.Toolchain.ShlibSuffix()
+	fileName := library.getLibName(ctx) + flags.Toolchain.ShlibSuffix()
 	outputFile := android.PathForModuleOut(ctx, fileName)
 	ret := outputFile