Merge "Switch to clang-r346389b."
diff --git a/apex/apex.go b/apex/apex.go
index 0445c20..5ce0e05 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -136,7 +136,7 @@
 	pctx.HostBinToolVariable("zip2zip", "zip2zip")
 	pctx.HostBinToolVariable("zipalign", "zipalign")
 
-	android.RegisterModuleType("apex", apexBundleFactory)
+	android.RegisterModuleType("apex", ApexBundleFactory)
 
 	android.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
 		ctx.TopDown("apex_deps", apexDepsMutator)
@@ -684,8 +684,14 @@
 			} else {
 				readOnlyPaths = append(readOnlyPaths, pathInApex)
 			}
-			if !android.InList(f.installDir, executablePaths) {
-				executablePaths = append(executablePaths, f.installDir)
+			dir := f.installDir
+			for !android.InList(dir, executablePaths) && dir != "" {
+				executablePaths = append(executablePaths, dir)
+				dir, _ = filepath.Split(dir) // move up to the parent
+				if len(dir) > 0 {
+					// remove trailing slash
+					dir = dir[:len(dir)-1]
+				}
 			}
 		}
 		sort.Strings(readOnlyPaths)
@@ -871,7 +877,7 @@
 	}
 }
 
-func apexBundleFactory() android.Module {
+func ApexBundleFactory() android.Module {
 	module := &apexBundle{
 		outputFiles: map[apexPackaging]android.WritablePath{},
 	}
diff --git a/apex/apex_test.go b/apex/apex_test.go
index d1794ee..c7ef58e 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -28,7 +28,7 @@
 	defer teardown(buildDir)
 
 	ctx := android.NewTestArchContext()
-	ctx.RegisterModuleType("apex", android.ModuleFactoryAdaptor(apexBundleFactory))
+	ctx.RegisterModuleType("apex", android.ModuleFactoryAdaptor(ApexBundleFactory))
 	ctx.RegisterModuleType("apex_key", android.ModuleFactoryAdaptor(apexKeyFactory))
 
 	ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
@@ -40,6 +40,7 @@
 	ctx.RegisterModuleType("cc_library_shared", android.ModuleFactoryAdaptor(cc.LibrarySharedFactory))
 	ctx.RegisterModuleType("cc_object", android.ModuleFactoryAdaptor(cc.ObjectFactory))
 	ctx.RegisterModuleType("toolchain_library", android.ModuleFactoryAdaptor(cc.ToolchainLibraryFactory))
+	ctx.RegisterModuleType("prebuilt_etc", android.ModuleFactoryAdaptor(android.PrebuiltEtcFactory))
 	ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
 		ctx.BottomUp("link", cc.LinkageMutator).Parallel()
 		ctx.BottomUp("version", cc.VersionMutator).Parallel()
@@ -94,6 +95,7 @@
 		"apex_manifest.json":                        nil,
 		"system/sepolicy/apex/myapex-file_contexts": nil,
 		"mylib.cpp":                                 nil,
+		"myprebuilt":                                nil,
 	})
 	_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
 	android.FailIfErrored(t, errs)
@@ -415,3 +417,33 @@
 	ensureContains(t, mylibCFlags, "__LIBDL_API__=27")
 	ensureContains(t, mylibSharedCFlags, "__LIBDL_API__=27")
 }
+
+func TestFilesInSubDir(t *testing.T) {
+	ctx := testApex(t, `
+		apex {
+			name: "myapex",
+			key: "myapex.key",
+			prebuilts: ["myetc"],
+		}
+
+		apex_key {
+			name: "myapex.key",
+			public_key: "testkey.avbpubkey",
+			private_key: "testkey.pem",
+		}
+
+		prebuilt_etc {
+			name: "myetc",
+			src: "myprebuilt",
+			sub_dir: "foo/bar",
+		}
+	`)
+
+	generateFsRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("generateFsConfig")
+	dirs := strings.Split(generateFsRule.Args["exec_paths"], " ")
+
+	// Ensure that etc, etc/foo, and etc/foo/bar are all listed
+	ensureListContains(t, dirs, "etc")
+	ensureListContains(t, dirs, "etc/foo")
+	ensureListContains(t, dirs, "etc/foo/bar")
+}
diff --git a/cc/config/clang.go b/cc/config/clang.go
index 46d8528..ae13fa2 100644
--- a/cc/config/clang.go
+++ b/cc/config/clang.go
@@ -91,9 +91,7 @@
 	"-Wl,-m,aarch64_elf64_le_vec",
 })
 
-var ClangLibToolingUnknownCflags = sorted([]string{
-	"-fno-sanitize=implicit-integer-sign-change",
-})
+var ClangLibToolingUnknownCflags = sorted([]string{})
 
 func init() {
 	pctx.StaticVariable("ClangExtraCflags", strings.Join([]string{
diff --git a/ui/build/paths/config.go b/ui/build/paths/config.go
index 12daee3..592c2eb 100644
--- a/ui/build/paths/config.go
+++ b/ui/build/paths/config.go
@@ -84,7 +84,6 @@
 	"date":      Allowed,
 	"dd":        Allowed,
 	"diff":      Allowed,
-	"dirname":   Allowed,
 	"du":        Allowed,
 	"echo":      Allowed,
 	"egrep":     Allowed,
@@ -96,7 +95,6 @@
 	"git":       Allowed,
 	"grep":      Allowed,
 	"gzip":      Allowed,
-	"head":      Allowed,
 	"hexdump":   Allowed,
 	"hostname":  Allowed,
 	"jar":       Allowed,
@@ -107,7 +105,6 @@
 	"lsof":      Allowed,
 	"m4":        Allowed,
 	"md5sum":    Allowed,
-	"mkdir":     Allowed,
 	"mktemp":    Allowed,
 	"mv":        Allowed,
 	"openssl":   Allowed,
@@ -161,8 +158,11 @@
 	"cat":      Toybox,
 	"cmp":      Toybox,
 	"comm":     Toybox,
+	"dirname":  Toybox,
 	"env":      Toybox,
+	"head":     Toybox,
 	"id":       Toybox,
+	"mkdir":    Toybox,
 	"od":       Toybox,
 	"paste":    Toybox,
 	"pwd":      Toybox,