diff options
-rw-r--r-- | android/arch.go | 12 | ||||
-rw-r--r-- | android/config.go | 4 | ||||
-rw-r--r-- | android/variable.go | 2 | ||||
-rw-r--r-- | ui/build/build.go | 1 | ||||
-rw-r--r-- | ui/build/config.go | 59 | ||||
-rw-r--r-- | ui/build/rbe.go | 47 | ||||
-rw-r--r-- | ui/build/rbe_test.go | 3 |
7 files changed, 63 insertions, 65 deletions
diff --git a/android/arch.go b/android/arch.go index cbf77c758..3587b469f 100644 --- a/android/arch.go +++ b/android/arch.go @@ -655,7 +655,8 @@ func archMutator(bpctx blueprint.BottomUpMutatorContext) { prefer32 := os == Windows // Determine the multilib selection for this module. - multilib, extraMultilib := decodeMultilib(base, os) + force_first_on_device := mctx.Config().ForceMultilibFirstOnDevice() + multilib, extraMultilib := decodeMultilib(base, os, force_first_on_device) // Convert the multilib selection into a list of Targets. targets, err := decodeMultilibTargets(multilib, osTargets, prefer32) @@ -730,7 +731,7 @@ func addTargetProperties(m Module, target Target, multiTargets []Target, primary // multilib from the factory's call to InitAndroidArchModule if none was set. For modules that // called InitAndroidMultiTargetsArchModule it always returns "common" for multilib, and returns // the actual multilib in extraMultilib. -func decodeMultilib(base *ModuleBase, os OsType) (multilib, extraMultilib string) { +func decodeMultilib(base *ModuleBase, os OsType, force_first_on_device bool) (multilib, extraMultilib string) { // First check the "android.compile_multilib" or "host.compile_multilib" properties. switch os.Class { case Device: @@ -749,6 +750,13 @@ func decodeMultilib(base *ModuleBase, os OsType) (multilib, extraMultilib string multilib = base.commonProperties.Default_multilib } + // If a device is configured with multiple targets, this option + // force all device targets that prefer32 to be compiled only as + // the first target. + if force_first_on_device && os.Class == Device && (multilib == "prefer32" || multilib == "first_prefer32") { + multilib = "first" + } + if base.commonProperties.UseTargetVariants { // Darwin has the concept of "universal binaries" which is implemented in Soong by // building both x86_64 and arm64 variants, and having select module types know how to diff --git a/android/config.go b/android/config.go index ba95c5a20..3c99659f9 100644 --- a/android/config.go +++ b/android/config.go @@ -1701,6 +1701,10 @@ func (c *deviceConfig) GenerateAidlNdkPlatformBackend() bool { return c.config.productVariables.GenerateAidlNdkPlatformBackend } +func (c *config) ForceMultilibFirstOnDevice() bool { + return c.productVariables.ForceMultilibFirstOnDevice +} + // The ConfiguredJarList struct provides methods for handling a list of (apex, jar) pairs. // Such lists are used in the build system for things like bootclasspath jars or system server jars. // The apex part is either an apex name, or a special names "platform" or "system_ext". Jar is a diff --git a/android/variable.go b/android/variable.go index 373891ae4..442068423 100644 --- a/android/variable.go +++ b/android/variable.go @@ -443,6 +443,8 @@ type productVariables struct { SepolicyFreezeTestExtraPrebuiltDirs []string `json:",omitempty"` GenerateAidlNdkPlatformBackend bool `json:",omitempty"` + + ForceMultilibFirstOnDevice bool `json:",omitempty"` } func boolPtr(v bool) *bool { diff --git a/ui/build/build.go b/ui/build/build.go index ec42b7004..aadf4af4e 100644 --- a/ui/build/build.go +++ b/ui/build/build.go @@ -266,7 +266,6 @@ func Build(ctx Context, config Config) { } if config.StartRBE() { - cleanupRBELogsDir(ctx, config) startRBE(ctx, config) defer DumpRBEMetrics(ctx, config, filepath.Join(config.LogsDir(), "rbe_metrics.pb")) } diff --git a/ui/build/config.go b/ui/build/config.go index 5765f2123..e271bfca2 100644 --- a/ui/build/config.go +++ b/ui/build/config.go @@ -19,14 +19,12 @@ import ( "encoding/json" "fmt" "io/ioutil" - "math/rand" "os" "os/exec" "path/filepath" "runtime" "strconv" "strings" - "syscall" "time" "android/soong/shared" @@ -44,15 +42,6 @@ const ( envConfigFetchTimeout = 10 * time.Second ) -var ( - rbeRandPrefix int -) - -func init() { - rand.Seed(time.Now().UnixNano()) - rbeRandPrefix = rand.Intn(1000) -} - type Config struct{ *configImpl } type configImpl struct { @@ -1155,25 +1144,34 @@ func (c *configImpl) StartRBE() bool { return true } -func (c *configImpl) rbeProxyLogsDir() string { - for _, f := range []string{"RBE_proxy_log_dir", "FLAG_output_dir"} { +func (c *configImpl) rbeLogDir() string { + for _, f := range []string{"RBE_log_dir", "FLAG_log_dir"} { if v, ok := c.environ.Get(f); ok { return v } } - buildTmpDir := shared.TempDirForOutDir(c.SoongOutDir()) - return filepath.Join(buildTmpDir, "rbe") + if c.Dist() { + return c.LogsDir() + } + return c.OutDir() } -func (c *configImpl) shouldCleanupRBELogsDir() bool { - // Perform a log directory cleanup only when the log directory - // is auto created by the build rather than user-specified. - for _, f := range []string{"RBE_proxy_log_dir", "FLAG_output_dir"} { - if _, ok := c.environ.Get(f); ok { - return false +func (c *configImpl) rbeStatsOutputDir() string { + for _, f := range []string{"RBE_output_dir", "FLAG_output_dir"} { + if v, ok := c.environ.Get(f); ok { + return v } } - return true + return c.rbeLogDir() +} + +func (c *configImpl) rbeLogPath() string { + for _, f := range []string{"RBE_log_path", "FLAG_log_path"} { + if v, ok := c.environ.Get(f); ok { + return v + } + } + return fmt.Sprintf("text://%v/reproxy_log.txt", c.rbeLogDir()) } func (c *configImpl) rbeExecRoot() string { @@ -1225,23 +1223,6 @@ func (c *configImpl) rbeAuth() (string, string) { return "RBE_use_application_default_credentials", "true" } -func (c *configImpl) rbeSockAddr(dir string) (string, error) { - maxNameLen := len(syscall.RawSockaddrUnix{}.Path) - base := fmt.Sprintf("reproxy_%v.sock", rbeRandPrefix) - - name := filepath.Join(dir, base) - if len(name) < maxNameLen { - return name, nil - } - - name = filepath.Join("/tmp", base) - if len(name) < maxNameLen { - return name, nil - } - - return "", fmt.Errorf("cannot generate a proxy socket address shorter than the limit of %v", maxNameLen) -} - func (c *configImpl) UseRemoteBuild() bool { return c.UseGoma() || c.UseRBE() } diff --git a/ui/build/rbe.go b/ui/build/rbe.go index 3e558f738..8f9a69991 100644 --- a/ui/build/rbe.go +++ b/ui/build/rbe.go @@ -16,9 +16,12 @@ package build import ( "fmt" + "math/rand" "os" "path/filepath" "runtime" + "syscall" + "time" "android/soong/ui/metrics" ) @@ -51,16 +54,34 @@ func rbeCommand(ctx Context, config Config, rbeCmd string) string { return cmdPath } +func sockAddr(dir string) (string, error) { + maxNameLen := len(syscall.RawSockaddrUnix{}.Path) + rand.Seed(time.Now().UnixNano()) + base := fmt.Sprintf("reproxy_%v.sock", rand.Intn(1000)) + + name := filepath.Join(dir, base) + if len(name) < maxNameLen { + return name, nil + } + + name = filepath.Join("/tmp", base) + if len(name) < maxNameLen { + return name, nil + } + + return "", fmt.Errorf("cannot generate a proxy socket address shorter than the limit of %v", maxNameLen) +} + func getRBEVars(ctx Context, config Config) map[string]string { vars := map[string]string{ - "RBE_log_dir": config.rbeProxyLogsDir(), + "RBE_log_path": config.rbeLogPath(), + "RBE_log_dir": config.rbeLogDir(), "RBE_re_proxy": config.rbeReproxy(), "RBE_exec_root": config.rbeExecRoot(), - "RBE_output_dir": config.rbeProxyLogsDir(), - "RBE_proxy_log_dir": config.rbeProxyLogsDir(), + "RBE_output_dir": config.rbeStatsOutputDir(), } if config.StartRBE() { - name, err := config.rbeSockAddr(absPath(ctx, config.TempDir())) + name, err := sockAddr(absPath(ctx, config.TempDir())) if err != nil { ctx.Fatalf("Error retrieving socket address: %v", err) return nil @@ -79,17 +100,6 @@ func getRBEVars(ctx Context, config Config) map[string]string { return vars } -func cleanupRBELogsDir(ctx Context, config Config) { - if !config.shouldCleanupRBELogsDir() { - return - } - - rbeTmpDir := config.rbeProxyLogsDir() - if err := os.RemoveAll(rbeTmpDir); err != nil { - fmt.Fprintln(ctx.Writer, "\033[33mUnable to remove RBE log directory: ", err, "\033[0m") - } -} - func startRBE(ctx Context, config Config) { ctx.BeginTrace(metrics.RunSetupTool, "rbe_bootstrap") defer ctx.EndTrace() @@ -100,11 +110,6 @@ func startRBE(ctx Context, config Config) { if n := ulimitOrFatal(ctx, config, "-n"); n < rbeLeastNFiles { ctx.Fatalf("max open files is insufficient: %d; want >= %d.\n", n, rbeLeastNFiles) } - if _, err := os.Stat(config.rbeProxyLogsDir()); os.IsNotExist(err) { - if err := os.MkdirAll(config.rbeProxyLogsDir(), 0744); err != nil { - ctx.Fatalf("Unable to create logs dir (%v) for RBE: %v", config.rbeProxyLogsDir, err) - } - } cmd := Command(ctx, config, "startRBE bootstrap", rbeCommand(ctx, config, bootstrapCmd)) @@ -146,7 +151,7 @@ func DumpRBEMetrics(ctx Context, config Config, filename string) { return } - outputDir := config.rbeProxyLogsDir() + outputDir := config.rbeStatsOutputDir() if outputDir == "" { ctx.Fatal("RBE output dir variable not defined. Aborting metrics dumping.") } diff --git a/ui/build/rbe_test.go b/ui/build/rbe_test.go index 266f76b35..8ff96bcbb 100644 --- a/ui/build/rbe_test.go +++ b/ui/build/rbe_test.go @@ -56,8 +56,7 @@ func TestDumpRBEMetrics(t *testing.T) { env := Environment(tt.env) env.Set("OUT_DIR", tmpDir) env.Set("RBE_DIR", tmpDir) - env.Set("RBE_output_dir", tmpDir) - env.Set("RBE_proxy_log_dir", tmpDir) + env.Set("RBE_output_dir", t.TempDir()) config := Config{&configImpl{ environ: &env, }} |