Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b7cfc8ea authored by Ramy Medhat's avatar Ramy Medhat Committed by Patrice Arruda
Browse files

Generate RBE socket address randomly for each invocation of soong.

Test: started soong multiple times and saw different socket files in
out/soong/.temp

Bug: b/140638454
Change-Id: Ib0087dd3867bdbf584c6868196070840cff291aa
Merged-In: Ib0087dd3867bdbf584c6868196070840cff291aa
parent 11c7e806
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -187,7 +187,8 @@ func NewConfig(ctx Context, args ...string) Config {
	// Tell python not to spam the source tree with .pyc files.
	ret.environ.Set("PYTHONDONTWRITEBYTECODE", "1")

	ret.environ.Set("TMPDIR", absPath(ctx, ret.TempDir()))
	tmpDir := absPath(ctx, ret.TempDir())
	ret.environ.Set("TMPDIR", tmpDir)

	// Always set ASAN_SYMBOLIZER_PATH so that ASAN-based tools can symbolize any crashes
	symbolizerPath := filepath.Join("prebuilts/clang/host", ret.HostPrebuiltTag(),
@@ -261,6 +262,12 @@ func NewConfig(ctx Context, args ...string) Config {

	ret.environ.Set("BUILD_DATETIME_FILE", buildDateTimeFile)

	if ret.UseRBE() {
		for k, v := range getRBEVars(ctx, tmpDir) {
			ret.environ.Set(k, v)
		}
	}

	c := Config{ret}
	storeConfigMetrics(ctx, c)
	return c
+8 −0
Original line number Diff line number Diff line
@@ -15,8 +15,11 @@
package build

import (
	"fmt"
	"math/rand"
	"os"
	"path/filepath"
	"time"

	"android/soong/ui/metrics"
)
@@ -49,6 +52,11 @@ func rbeCommand(ctx Context, config Config, rbeCmd string) string {
	return cmdPath
}

func getRBEVars(ctx Context, tmpDir string) map[string]string {
	rand.Seed(time.Now().UnixNano())
	return map[string]string{"RBE_server_address": fmt.Sprintf("unix://%v/reproxy_%v.sock", tmpDir, rand.Intn(1000))}
}

func startRBE(ctx Context, config Config) {
	ctx.BeginTrace(metrics.RunSetupTool, "rbe_bootstrap")
	defer ctx.EndTrace()