Snap for 5647767 from 17226f7da5ad71e2d992733045c6d93925b47856 to qt-c2f2-release

Change-Id: If6ce2d86865574f6f6ac43c7357e455b38b29f48
diff --git a/Android.bp b/Android.bp
index e453d75..826fbd2 100644
--- a/Android.bp
+++ b/Android.bp
@@ -111,6 +111,7 @@
         },
     },
     check_elf_files: false,  // Bypass circular dependency between libc++
+    has_stubs: true,
 }
 
 libclang_rt_prebuilt_library_shared {
@@ -124,6 +125,7 @@
         },
     },
     check_elf_files: false,  // Bypass circular dependency between libc++
+    has_stubs: true,
 }
 
 libclang_rt_prebuilt_library_shared {
@@ -137,6 +139,7 @@
         },
     },
     check_elf_files: false,  // Bypass circular dependency between libc++
+    has_stubs: true,
 }
 
 libclang_rt_prebuilt_library_shared {
@@ -156,6 +159,7 @@
         },
     },
     check_elf_files: false,  // Bypass circular dependency between libc++
+    has_stubs: true,
 }
 
 libclang_rt_llndk_library {
@@ -364,6 +368,7 @@
         },
     },
     check_elf_files: false,  // Bypass circular dependency between libc++
+    has_stubs: true,
 }
 
 libclang_rt_prebuilt_library_static {
diff --git a/soong/clangprebuilts.go b/soong/clangprebuilts.go
index a802c23..86af1c7 100644
--- a/soong/clangprebuilts.go
+++ b/soong/clangprebuilts.go
@@ -72,6 +72,11 @@
 	return path.Join(clangDir, "lib64", "clang", releaseVersion, "lib", "linux")
 }
 
+func getSymbolFilePath(ctx android.LoadHookContext) string {
+	libDir := getClangResourceDir(ctx)
+	return path.Join(libDir, strings.TrimSuffix(ctx.ModuleName(), ".llndk")+".map.txt")
+}
+
 func trimVersionNumbers(ver string, retain int) string {
 	sep := "."
 	versions := strings.Split(ver, sep)
@@ -182,7 +187,11 @@
 	ctx.AppendProperties(p)
 }
 
-func libClangRtPrebuiltLibraryShared(ctx android.LoadHookContext) {
+type prebuiltLibrarySharedProps struct {
+	Has_stubs *bool
+}
+
+func libClangRtPrebuiltLibraryShared(ctx android.LoadHookContext, in *prebuiltLibrarySharedProps) {
 	if ctx.AConfig().IsEnvTrue("FORCE_BUILD_SANITIZER_SHARED_OBJECTS") {
 		return
 	}
@@ -202,6 +211,10 @@
 		}
 		Pack_relocations *bool
 		Stl              *string
+		Stubs            struct {
+			Symbol_file *string
+			Versions    []string
+		}
 	}
 
 	p := &props{}
@@ -217,6 +230,12 @@
 	disable := false
 	p.Pack_relocations = &disable
 	p.Stl = proptools.StringPtr("none")
+
+	if proptools.Bool(in.Has_stubs) {
+		p.Stubs.Versions = []string{"10000"}
+		p.Stubs.Symbol_file = proptools.StringPtr(getSymbolFilePath(ctx))
+	}
+
 	ctx.AppendProperties(p)
 }
 
@@ -224,11 +243,11 @@
 	libDir := getClangResourceDir(ctx)
 
 	type props struct {
-		Srcs []string
+		Srcs               []string
 		System_shared_libs []string
-		No_libcrt *bool
-		No_libgcc *bool
-		Stl *string
+		No_libcrt          *bool
+		No_libgcc          *bool
+		Stl                *string
 	}
 
 	name := strings.TrimPrefix(ctx.ModuleName(), "prebuilt_")
@@ -247,15 +266,12 @@
 }
 
 func libClangRtLLndkLibrary(ctx android.LoadHookContext) {
-	libDir := getClangResourceDir(ctx)
-
 	type props struct {
 		Symbol_file *string
 	}
 
 	p := &props{}
-	symbol_file := string(path.Join(libDir, strings.TrimSuffix(ctx.ModuleName(), ".llndk")+".map.txt"))
-	p.Symbol_file = proptools.StringPtr(symbol_file)
+	p.Symbol_file = proptools.StringPtr(getSymbolFilePath(ctx))
 	ctx.AppendProperties(p)
 }
 
@@ -293,7 +309,11 @@
 
 func libClangRtPrebuiltLibrarySharedFactory() android.Module {
 	module, _ := cc.NewPrebuiltSharedLibrary(android.HostAndDeviceSupported)
-	android.AddLoadHook(module, libClangRtPrebuiltLibraryShared)
+	props := &prebuiltLibrarySharedProps{}
+	module.AddProperties(props)
+	android.AddLoadHook(module, func(ctx android.LoadHookContext) {
+		libClangRtPrebuiltLibraryShared(ctx, props)
+	})
 	return module.Init()
 }