diff --git a/bench_test.go b/bench_test.go index f8e5f96..7a9199e 100644 --- a/bench_test.go +++ b/bench_test.go @@ -79,12 +79,12 @@ func BenchmarkBuild(b *testing.B) { garbleCache := filepath.Join(tdir, "garble-cache") qt.Assert(b, qt.IsNil(os.RemoveAll(garbleCache))) qt.Assert(b, qt.IsNil(os.Mkdir(garbleCache, 0o777))) - env := append(os.Environ(), + env := []string{ "RUN_GARBLE_MAIN=true", - "GOCACHE="+goCache, - "GARBLE_CACHE="+garbleCache, + "GOCACHE=" + goCache, + "GARBLE_CACHE=" + garbleCache, "GARBLE_WRITE_ALLOCS=true", - ) + } args := []string{"build", "-v", "-o=" + outputBin, sourceDir} for _, cached := range []bool{false, true} { @@ -95,7 +95,7 @@ func BenchmarkBuild(b *testing.B) { } cmd := exec.Command(os.Args[0], args...) - cmd.Env = env + cmd.Env = append(cmd.Environ(), env...) cmd.Dir = sourceDir cachedStart := time.Now() diff --git a/internal/linker/linker.go b/internal/linker/linker.go index dccba86..bc8fa82 100644 --- a/internal/linker/linker.go +++ b/internal/linker/linker.go @@ -196,7 +196,7 @@ func buildLinker(workingDir string, overlay map[string]string, outputLinkPath st // go version -m ~/tip/pkg/tool/linux_amd64/link // // and which can be done from Go via debug/buildinfo.ReadFile. - cmd.Env = append(os.Environ(), + cmd.Env = append(cmd.Environ(), "GOENV=off", "GOOS=", "GOARCH=", "GOEXPERIMENT=", "GOFLAGS=", ) // Building cmd/link is possible from anywhere, but to avoid any possible side effects build in a temp directory diff --git a/scripts/bench_literals.go b/scripts/bench_literals.go index d75505b..58d103c 100644 --- a/scripts/bench_literals.go +++ b/scripts/bench_literals.go @@ -142,7 +142,7 @@ func main() { garbleBin := buildTestGarble(tdir) args := append([]string{"-seed", garbleSeed, "-literals", "test", "-bench"}, os.Args[1:]...) cmd := exec.Command(garbleBin, args...) - cmd.Env = append(os.Environ(), + cmd.Env = append(cmd.Environ(), // Explicitly specify package for obfuscation to avoid affecting testing package. "GOGARBLE="+moduleName, "GARBLE_TEST_LITERALS_OBFUSCATOR_MAP="+strings.Join(packageToObfuscatorIndex, ","),